From 0a30d76c65e7e5d307dbc33e8f66a619149666de Mon Sep 17 00:00:00 2001 From: Alberto Ricart Date: Thu, 26 Oct 2023 10:38:10 -0500 Subject: [PATCH 1/2] [DOC] updated readme [BENCH] updated bench to use `noAsyncTraces` --- README.md | 8 +++++--- examples/bench.js | 6 +++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 74ab5645..d8aa6ec1 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ all functionality starts with a connection. To connect to a server you use the `connect()` function. It returns a connection that you can use to interact with the server. You can customize the behavior of -the client by specifying many [`ConnectionOptions`](#Connection_Options). +the client by specifying many [`ConnectionOptions`](#connection-options). By default, a connection will attempt a connection on `127.0.0.1:4222`. If the connection is dropped, the client will attempt to reconnect. You can customize @@ -608,7 +608,7 @@ You can specify several options when creating a subscription: - `max`: maximum number of messages to receive - auto unsubscribe - `timeout`: how long to wait for the first message -- `queue`: the [queue group](#Queue-Groups) name the subscriber belongs to +- `queue`: the [queue group](#queue-groups) name the subscriber belongs to - `callback`: a function with the signature `(err: NatsError|null, msg: Msg) => void;` that should be used for handling the message. Subscriptions with callbacks are NOT iterators. @@ -780,15 +780,17 @@ The following is the list of connection options and default values. | `authenticator` | none | Specifies the authenticator function that sets the client credentials. | | `debug` | `false` | If `true`, the client prints protocol interactions to the console. Useful for debugging. | | `ignoreClusterUpdates` | `false` | If `true` the client will ignore any cluster updates provided by the server. | +| `ignoreAuthErrorAbort` | `false` | Prevents client connection aborts if the client fails more than twice in a row with an authentication error | | `inboxPrefix` | `"_INBOX"` | Sets de prefix for automatically created inboxes - `createInbox(prefix)` | | `maxPingOut` | `2` | Max number of pings the client will allow unanswered before raising a stale connection error. | | `maxReconnectAttempts` | `10` | Sets the maximum number of reconnect attempts. The value of `-1` specifies no limit. | | `name` | | Optional client name - recommended to be set to a unique client name. | +| `noAsyncTraces` | `false` | When `true` the client will not add additional context to errors associated with request operations. Setting this option to `true` will improve greatly improve performance of request/reply and JetStream publishers. | | `noEcho` | `false` | Subscriptions receive messages published by the client. Requires server support (1.2.0). If set to true, and the server does not support the feature, an error with code `NO_ECHO_NOT_SUPPORTED` is emitted, and the connection is aborted. Note that it is possible for this error to be emitted on reconnect when the server reconnects to a server that does not support the feature. | | `noRandomize` | `false` | If set, the order of user-specified servers is randomized. | | `pass` | | Sets the password for a connection. | | `pedantic` | `false` | Turns on strict subject format checks. | -| `pingInterval` | `120000` | Number of milliseconds between client-sent pings. | +| `pingInterval` | `120000` | Number of milliseconds between client-s
ent pings. | | `port` | `4222` | Port to connect to (only used if `servers` is not specified). | | `reconnect` | `true` | If false, client will not attempt reconnecting. | | `reconnectDelayHandler` | Generated function | A function that returns the number of millis to wait before the next connection to a server it connected to `()=>number`. | diff --git a/examples/bench.js b/examples/bench.js index 986dedb7..744872ee 100755 --- a/examples/bench.js +++ b/examples/bench.js @@ -53,7 +53,11 @@ const pendingLimit = parseInt(argv.pendingLimit) * 1024; const metrics = []; for (let i = 0; i < iters; i++) { - const nc = await connect({ servers: server, debug: argv.debug }); + const nc = await connect({ + servers: server, + debug: argv.debug, + noAsyncTraces: true, + }); const opts = { msgs: count, size: bytes, From 8283cbe1094b977e6188e27e7e8e8ccefa9e5c02 Mon Sep 17 00:00:00 2001 From: Alberto Ricart Date: Thu, 26 Oct 2023 10:53:09 -0500 Subject: [PATCH 2/2] fixed random break added [ci skip] --- README.md | 56 +++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index d8aa6ec1..46492584 100644 --- a/README.md +++ b/README.md @@ -775,35 +775,35 @@ more performant or appropriate. The following is the list of connection options and default values. -| Option | Default | Description | -| ----------------------- | ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `authenticator` | none | Specifies the authenticator function that sets the client credentials. | -| `debug` | `false` | If `true`, the client prints protocol interactions to the console. Useful for debugging. | -| `ignoreClusterUpdates` | `false` | If `true` the client will ignore any cluster updates provided by the server. | -| `ignoreAuthErrorAbort` | `false` | Prevents client connection aborts if the client fails more than twice in a row with an authentication error | -| `inboxPrefix` | `"_INBOX"` | Sets de prefix for automatically created inboxes - `createInbox(prefix)` | -| `maxPingOut` | `2` | Max number of pings the client will allow unanswered before raising a stale connection error. | -| `maxReconnectAttempts` | `10` | Sets the maximum number of reconnect attempts. The value of `-1` specifies no limit. | -| `name` | | Optional client name - recommended to be set to a unique client name. | -| `noAsyncTraces` | `false` | When `true` the client will not add additional context to errors associated with request operations. Setting this option to `true` will improve greatly improve performance of request/reply and JetStream publishers. | +| Option | Default | Description | +| ----------------------- | ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `authenticator` | none | Specifies the authenticator function that sets the client credentials. | +| `debug` | `false` | If `true`, the client prints protocol interactions to the console. Useful for debugging. | +| `ignoreClusterUpdates` | `false` | If `true` the client will ignore any cluster updates provided by the server. | +| `ignoreAuthErrorAbort` | `false` | Prevents client connection aborts if the client fails more than twice in a row with an authentication error | +| `inboxPrefix` | `"_INBOX"` | Sets de prefix for automatically created inboxes - `createInbox(prefix)` | +| `maxPingOut` | `2` | Max number of pings the client will allow unanswered before raising a stale connection error. | +| `maxReconnectAttempts` | `10` | Sets the maximum number of reconnect attempts. The value of `-1` specifies no limit. | +| `name` | | Optional client name - recommended to be set to a unique client name. | +| `noAsyncTraces` | `false` | When `true` the client will not add additional context to errors associated with request operations. Setting this option to `true` will greatly improve performance of request/reply and JetStream publishers. | | `noEcho` | `false` | Subscriptions receive messages published by the client. Requires server support (1.2.0). If set to true, and the server does not support the feature, an error with code `NO_ECHO_NOT_SUPPORTED` is emitted, and the connection is aborted. Note that it is possible for this error to be emitted on reconnect when the server reconnects to a server that does not support the feature. | -| `noRandomize` | `false` | If set, the order of user-specified servers is randomized. | -| `pass` | | Sets the password for a connection. | -| `pedantic` | `false` | Turns on strict subject format checks. | -| `pingInterval` | `120000` | Number of milliseconds between client-s
ent pings. | -| `port` | `4222` | Port to connect to (only used if `servers` is not specified). | -| `reconnect` | `true` | If false, client will not attempt reconnecting. | -| `reconnectDelayHandler` | Generated function | A function that returns the number of millis to wait before the next connection to a server it connected to `()=>number`. | -| `reconnectJitter` | `100` | Number of millis to randomize after `reconnectTimeWait`. | -| `reconnectJitterTLS` | `1000` | Number of millis to randomize after `reconnectTimeWait` when TLS options are specified. | -| `reconnectTimeWait` | `2000` | If disconnected, the client will wait the specified number of milliseconds between reconnect attempts. | -| `servers` | `"localhost:4222"` | String or Array of hostport for servers. | -| `timeout` | 20000 | Number of milliseconds the client will wait for a connection to be established. If it fails it will emit a `connection_timeout` event with a NatsError that provides the hostport of the server where the connection was attempted. | -| `tls` | TlsOptions | A configuration object for requiring a TLS connection (not applicable to nats.ws). | -| `token` | | Sets a authorization token for a connection. | -| `user` | | Sets the username for a connection. | -| `verbose` | `false` | Turns on `+OK` protocol acknowledgements. | -| `waitOnFirstConnect` | `false` | If `true` the client will fall back to a reconnect mode if it fails its first connection attempt. | +| `noRandomize` | `false` | If set, the order of user-specified servers is randomized. | +| `pass` | | Sets the password for a connection. | +| `pedantic` | `false` | Turns on strict subject format checks. | +| `pingInterval` | `120000` | Number of milliseconds between client-sent pings. | +| `port` | `4222` | Port to connect to (only used if `servers` is not specified). | +| `reconnect` | `true` | If false, client will not attempt reconnecting. | +| `reconnectDelayHandler` | Generated function | A function that returns the number of millis to wait before the next connection to a server it connected to `()=>number`. | +| `reconnectJitter` | `100` | Number of millis to randomize after `reconnectTimeWait`. | +| `reconnectJitterTLS` | `1000` | Number of millis to randomize after `reconnectTimeWait` when TLS options are specified. | +| `reconnectTimeWait` | `2000` | If disconnected, the client will wait the specified number of milliseconds between reconnect attempts. | +| `servers` | `"localhost:4222"` | String or Array of hostport for servers. | +| `timeout` | 20000 | Number of milliseconds the client will wait for a connection to be established. If it fails it will emit a `connection_timeout` event with a NatsError that provides the hostport of the server where the connection was attempted. | +| `tls` | TlsOptions | A configuration object for requiring a TLS connection (not applicable to nats.ws). | +| `token` | | Sets a authorization token for a connection. | +| `user` | | Sets the username for a connection. | +| `verbose` | `false` | Turns on `+OK` protocol acknowledgements. | +| `waitOnFirstConnect` | `false` | If `true` the client will fall back to a reconnect mode if it fails its first connection attempt. | ### TlsOptions