Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] implemented noResolve connect option #626

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ 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. |
Expand All @@ -770,6 +770,7 @@ The following is the list of connection options and default values.
| `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. |
| `noResolve` | | If set to true, will not resolve host names. |
| `pass` | | Sets the password for a connection. |
| `pedantic` | `false` | Turns on strict subject format checks. |
| `pingInterval` | `120000` | Number of milliseconds between client-sent pings. |
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"cjs-jetstream": "deno run --allow-all ./bin/cjs-fix-imports.ts -o jetstream/ ./.deps/nats.deno/jetstream/",
"cjs": "npm run cjs-nbc && npm run cjs-jetstream",
"clean": "shx rm -Rf ./lib/* ./nats-base-client ./.deps",
"clone-nbc": "shx mkdir -p ./.deps && cd ./.deps && git clone --branch v1.26.0 https://github.com/nats-io/nats.deno.git",
"clone-nbc": "shx mkdir -p ./.deps && cd ./.deps && git clone --branch main https://github.com/nats-io/nats.deno.git",
"fmt": "deno fmt ./src/ ./examples/ ./test/",
"prepack": "npm run clone-nbc && npm run cjs && npm run check-package && npm run build",
"ava": "nyc ava --verbose -T 60000",
Expand Down
2 changes: 1 addition & 1 deletion src/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function connect(opts: ConnectionOptions = {}): Promise<NatsConnection> {
factory: (): Transport => {
return new NodeTransport();
},
dnsResolveFn: nodeResolveHost,
dnsResolveFn: opts.noResolve === true ? undefined : nodeResolveHost,
} as TransportFactory);
return NatsConnectionImpl.connect(opts);
}
11 changes: 10 additions & 1 deletion test/basics.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const {
);
const net = require("net");

const { deferred, delay, nuid } = require(
const { deferred, delay, nuid, getResolveFn } = require(
"../lib/nats-base-client/internal_mod",
);
const { Lock } = require("./helpers/lock");
Expand Down Expand Up @@ -796,3 +796,12 @@ test("basics - js fetch on stopped server doesn't close", async (t) => {
await nc.close();
await ns.stop();
});

test("basics - noResolve", async (t) => {
const ns = await NatsServer.start();
const nc = await connect({port: ns.port, noResolve: true});
t.plan(1);
t.is(getResolveFn(), undefined);
await nc.close();
await ns.stop();
})
Loading