diff --git a/core/README.md b/core/README.md index d6068611..d299763d 100644 --- a/core/README.md +++ b/core/README.md @@ -107,7 +107,7 @@ is working. ```typescript // import the connect function from a transport -import { connect } from "jsr:@nats-io/nats-transport-deno@3.0.0-4"; +import { connect } from "jsr:@nats-io/transport-deno@3.0.0-7"; const servers = [ {}, @@ -179,7 +179,7 @@ the server. ```typescript // import the connect function from a transport -import { connect } from "jsr:@nats-io/nats-transport-deno@3.0.0-4"; +import { connect } from "jsr:@nats-io/transport-deno@3.0.0-7"; // to create a connection to a nats-server: const nc = await connect({ servers: "demo.nats.io:4222" }); @@ -241,8 +241,8 @@ All subscriptions are independent. If two different subscriptions match a subject, both will get to process the message: ```typescript -import { connect } from "jsr:@nats-io/nats-transport-deno@3.0.0-4"; -import type { Subscription } from "jsr:@nats-io/nats-transport-deno@3.0.0-4"; +import { connect } from "jsr:@nats-io/transport-deno@3.0.0-7"; +import type { Subscription } from "jsr:@nats-io/transport-deno@3.0.0-7"; const nc = await connect({ servers: "demo.nats.io:4222" }); // subscriptions can have wildcard subjects @@ -418,11 +418,11 @@ independent unit. Note that non-queue subscriptions are also independent of subscriptions in a queue group. ```typescript -import { connect } from "jsr:@nats-io/nats-transport-deno@3.0.0-5"; +import { connect } from "jsr:@nats-io/transport-deno@3.0.0-7"; import type { NatsConnection, Subscription, -} from "jsr:@nats-io/nats-transport-deno@3.0.0-4"; +} from "jsr:@nats-io/transport-deno@3.0.0-7"; async function createService( name: string, @@ -541,29 +541,33 @@ If you send a request for which there's no interest, the request will be immediately rejected: ```typescript -import { connect, ErrorCode } from "jsr:@nats-io/nats-transport-deno@3.0.0-5"; -import type { NatsError } from "jsr:@nats-io/nats-transport-deno@3.0.0-5"; - -const nc = await connect( - { - servers: `demo.nats.io`, - }, -); +import { connect } from "jsr:@nats-io/transport-deno@3.0.0-7"; +import { + NoRespondersError, + RequestError, + TimeoutError, +} from "jsr:@nats-io/transport-deno@3.0.0-7"; + +const nc = await connect({ + servers: `demo.nats.io`, +}); try { const m = await nc.request("hello.world"); console.log(m.data); } catch (err) { - const nerr = err as NatsError; - switch (nerr.code) { - case ErrorCode.NoResponders: - console.log("no one is listening to 'hello.world'"); - break; - case ErrorCode.Timeout: + if (err instanceof RequestError) { + if (err.cause instanceof TimeoutError) { console.log("someone is listening but didn't respond"); - break; - default: - console.log("request failed", err); + } else if (err.cause instanceof NoRespondersError) { + console.log("no one is listening to 'hello.world'"); + } else { + console.log( + `failed due to unknown error: ${(err.cause as Error)?.message}`, + ); + } + } else { + console.log(`request failed: ${(err as Error).message}`); } } @@ -591,7 +595,7 @@ Setting the `user`/`pass` or `token` options, simply initializes an ```typescript // if the connection requires authentication, provide `user` and `pass` or // `token` options in the NatsConnectionOptions -import { connect } from "jsr:@nats-io/nats-transport-deno@3.0.0-5"; +import { connect } from "jsr:@nats-io/transport-deno@3.0.0-5"; const nc1 = await connect({ servers: "127.0.0.1:4222", @@ -680,8 +684,8 @@ You can specify several options when creating a subscription: - `timeout`: how long to wait for the first message - `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. + `(err: Error|null, msg: Msg) => void;` that should be used for handling the + message. Subscriptions with callbacks are NOT iterators. #### Auto Unsubscribe diff --git a/core/examples/snippets/autounsub.ts b/core/examples/snippets/autounsub.ts index 15b1dc41..c65b506a 100644 --- a/core/examples/snippets/autounsub.ts +++ b/core/examples/snippets/autounsub.ts @@ -14,8 +14,8 @@ */ // import the connect function from a transport -import { connect } from "jsr:@nats-io/nats-transport-deno@3.0.0-5"; -import type { Subscription } from "jsr:@nats-io/nats-transport-deno@3.0.0-5"; +import { connect } from "jsr:@nats-io/transport-deno@3.0.0-7"; +import type { Subscription } from "jsr:@nats-io/transport-deno@3.0.0-7"; // create a connection const nc = await connect({ servers: "demo.nats.io:4222" }); diff --git a/core/examples/snippets/basics.ts b/core/examples/snippets/basics.ts index b46c0c58..e7a3214e 100644 --- a/core/examples/snippets/basics.ts +++ b/core/examples/snippets/basics.ts @@ -14,7 +14,7 @@ */ // import the connect function from a transport -import { connect } from "jsr:@nats-io/nats-transport-deno@3.0.0-5"; +import { connect } from "jsr:@nats-io/transport-deno@3.0.0-7"; // to create a connection to a nats-server: const nc = await connect({ servers: "demo.nats.io:4222" }); diff --git a/core/examples/snippets/connect.ts b/core/examples/snippets/connect.ts index d1e95378..938d5c58 100644 --- a/core/examples/snippets/connect.ts +++ b/core/examples/snippets/connect.ts @@ -14,7 +14,7 @@ */ // import the connect function from a transport -import { connect } from "jsr:@nats-io/nats-transport-deno@3.0.0-5"; +import { connect } from "jsr:@nats-io/transport-deno@3.0.0-7"; const servers = [ {}, diff --git a/core/examples/snippets/headers.ts b/core/examples/snippets/headers.ts index ed3322bc..1a1b6d2e 100644 --- a/core/examples/snippets/headers.ts +++ b/core/examples/snippets/headers.ts @@ -19,7 +19,7 @@ import { Empty, headers, nuid, -} from "jsr:@nats-io/nats-transport-deno@3.0.0-5"; +} from "jsr:@nats-io/transport-deno@3.0.0-7"; const nc = await connect( { diff --git a/core/examples/snippets/json.ts b/core/examples/snippets/json.ts index a05984be..4bd7e484 100644 --- a/core/examples/snippets/json.ts +++ b/core/examples/snippets/json.ts @@ -14,7 +14,7 @@ */ // import the connect function from a transport -import { connect } from "jsr:@nats-io/nats-transport-deno@3.0.0-5"; +import { connect } from "jsr:@nats-io/transport-deno@3.0.0-7"; // to create a connection to a nats-server: const nc = await connect({ servers: "demo.nats.io:4222" }); @@ -30,7 +30,7 @@ const sub = nc.subscribe("people"); for await (const m of sub) { // typescript will see this as a Person const p = m.json(); - console.log(`[${sub.getProcessed()}]: ${p.name}`); + console.log(p); } })(); diff --git a/core/examples/snippets/no_responders.ts b/core/examples/snippets/no_responders.ts index cbca427d..79a2906d 100644 --- a/core/examples/snippets/no_responders.ts +++ b/core/examples/snippets/no_responders.ts @@ -1,5 +1,24 @@ -import { connect, ErrorCode } from "jsr:@nats-io/nats-transport-deno@3.0.0-5"; -import type { NatsError } from "jsr:@nats-io/nats-transport-deno@3.0.0-5"; +/* + * Copyright 2024 Synadia Communications, Inc + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { connect } from "jsr:@nats-io/transport-deno@3.0.0-7"; +import { + NoRespondersError, + RequestError, + TimeoutError, +} from "jsr:@nats-io/transport-deno@3.0.0-7"; const nc = await connect( { @@ -11,16 +30,18 @@ try { const m = await nc.request("hello.world"); console.log(m.data); } catch (err) { - const nerr = err as NatsError; - switch (nerr.code) { - case ErrorCode.NoResponders: - console.log("no one is listening to 'hello.world'"); - break; - case ErrorCode.Timeout: + if (err instanceof RequestError) { + if (err.cause instanceof TimeoutError) { console.log("someone is listening but didn't respond"); - break; - default: - console.log("request failed", err); + } else if (err.cause instanceof NoRespondersError) { + console.log("no one is listening to 'hello.world'"); + } else { + console.log( + `failed due to unknown error: ${(err.cause as Error)?.message}`, + ); + } + } else { + console.log(`request failed: ${(err as Error).message}`); } } diff --git a/core/examples/snippets/queuegroups.ts b/core/examples/snippets/queuegroups.ts index a7848970..98877d42 100644 --- a/core/examples/snippets/queuegroups.ts +++ b/core/examples/snippets/queuegroups.ts @@ -12,11 +12,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { connect } from "jsr:@nats-io/nats-transport-deno@3.0.0-5"; +import { connect } from "jsr:@nats-io/transport-deno@3.0.0-7"; import type { NatsConnection, Subscription, -} from "jsr:@nats-io/nats-transport-deno@3.0.0-4"; +} from "jsr:@nats-io/transport-deno@3.0.0-7"; async function createService( name: string, diff --git a/core/examples/snippets/service.ts b/core/examples/snippets/service.ts index 07593023..1d5cee35 100644 --- a/core/examples/snippets/service.ts +++ b/core/examples/snippets/service.ts @@ -14,8 +14,8 @@ */ // import the connect function from a transport -import { connect } from "jsr:@nats-io/nats-transport-deno@3.0.0-5"; -import type { Subscription } from "jsr:@nats-io/nats-transport-deno@3.0.0-5"; +import { connect } from "jsr:@nats-io/transport-deno@3.0.0-7"; +import type { Subscription } from "jsr:@nats-io/transport-deno@3.0.0-7"; // create a connection const nc = await connect({ servers: "demo.nats.io" }); diff --git a/core/examples/snippets/service_client.ts b/core/examples/snippets/service_client.ts index ad5edfea..a2089b54 100644 --- a/core/examples/snippets/service_client.ts +++ b/core/examples/snippets/service_client.ts @@ -14,7 +14,7 @@ */ // import the connect function from a transport -import { connect, Empty } from "jsr:@nats-io/nats-transport-deno@3.0.0-5"; +import { connect, Empty } from "jsr:@nats-io/transport-deno@3.0.0-7"; // create a connection const nc = await connect({ servers: "demo.nats.io:4222" }); diff --git a/core/examples/snippets/stream.ts b/core/examples/snippets/stream.ts index 24025748..970e7adf 100644 --- a/core/examples/snippets/stream.ts +++ b/core/examples/snippets/stream.ts @@ -14,7 +14,7 @@ */ // import the connect function from a transport -import { connect } from "jsr:@nats-io/nats-transport-deno@3.0.0-5"; +import { connect } from "jsr:@nats-io/transport-deno@3.0.0-7"; // to create a connection to a nats-server: const nc = await connect({ servers: "demo.nats.io" }); diff --git a/core/examples/snippets/sub_timeout.ts b/core/examples/snippets/sub_timeout.ts index 1e525df6..bd75802a 100644 --- a/core/examples/snippets/sub_timeout.ts +++ b/core/examples/snippets/sub_timeout.ts @@ -14,7 +14,7 @@ */ // import the connect function from a transport -import { connect, ErrorCode } from "jsr:@nats-io/nats-transport-deno@3.0.0-5"; +import { connect, TimeoutError } from "jsr:@nats-io/transport-deno@3.0.0-7"; // to create a connection to a nats-server: const nc = await connect({ servers: "demo.nats.io:4222" }); @@ -27,7 +27,7 @@ const sub = nc.subscribe("hello", { timeout: 1000 }); // handle the messages } })().catch((err) => { - if (err.code === ErrorCode.Timeout) { + if (err instanceof TimeoutError) { console.log(`sub timed out!`); } else { console.log(`sub iterator got an error!`); diff --git a/core/examples/snippets/unsub.ts b/core/examples/snippets/unsub.ts index 60f3d7bc..a232cf87 100644 --- a/core/examples/snippets/unsub.ts +++ b/core/examples/snippets/unsub.ts @@ -14,7 +14,7 @@ */ // import the connect function from a transport -import { connect } from "jsr:@nats-io/nats-transport-deno@3.0.0-5"; +import { connect } from "jsr:@nats-io/transport-deno@3.0.0-7"; // to create a connection to a nats-server: const nc = await connect({ servers: "demo.nats.io:4222" }); @@ -38,9 +38,9 @@ const manual = nc.subscribe("hello"); const done = (async () => { console.log("waiting for a message on `hello` with a payload of `stop`"); for await (const m of manual) { - const d = sc.decode(m.data); - console.log("manual", manual.getProcessed(), d); - if (d === "stop") { + const payload = m.string(); + console.log("manual", manual.getProcessed(), payload); + if (payload === "stop") { manual.unsubscribe(); } } diff --git a/core/examples/snippets/wildcard_subscriptions.ts b/core/examples/snippets/wildcard_subscriptions.ts index df60c439..47629d0b 100644 --- a/core/examples/snippets/wildcard_subscriptions.ts +++ b/core/examples/snippets/wildcard_subscriptions.ts @@ -13,8 +13,8 @@ * limitations under the License. */ -import { connect } from "jsr:@nats-io/nats-transport-deno@3.0.0-5"; -import type { Subscription } from "jsr:@nats-io/nats-transport-deno@3.0.0-5"; +import { connect } from "jsr:@nats-io/transport-deno@3.0.0-7"; +import type { Subscription } from "jsr:@nats-io/transport-deno@3.0.0-7"; const nc = await connect({ servers: "demo.nats.io:4222" }); diff --git a/jetstream/examples/01_consumers.ts b/jetstream/examples/01_consumers.ts index 1dd292a8..cbbaa810 100644 --- a/jetstream/examples/01_consumers.ts +++ b/jetstream/examples/01_consumers.ts @@ -13,8 +13,8 @@ * limitations under the License. */ -import { connect } from "jsr:@nats-io/nats-transport-deno@3.0.0-5"; -import { jetstream } from "../src/mod.ts"; +import { connect } from "jsr:@nats-io/transport-deno@3.0.0-7"; +import { jetstream } from "jsr:@nats-io/jetstream@3.0.0-18"; import { setupStreamAndConsumer } from "./util.ts"; // create a connection diff --git a/jetstream/examples/02_next.ts b/jetstream/examples/02_next.ts index 17c66f5a..94d645f6 100644 --- a/jetstream/examples/02_next.ts +++ b/jetstream/examples/02_next.ts @@ -13,8 +13,8 @@ * limitations under the License. */ -import { connect } from "jsr:@nats-io/nats-transport-deno@3.0.0-5"; -import { jetstream } from "../src/mod.ts"; +import { connect } from "jsr:@nats-io/transport-deno@3.0.0-7"; +import { jetstream } from "jsr:@nats-io/jetstream@3.0.0-18"; import { setupStreamAndConsumer } from "./util.ts"; // create a connection diff --git a/jetstream/examples/03_batch.ts b/jetstream/examples/03_batch.ts index 8c1656b3..686f70a8 100644 --- a/jetstream/examples/03_batch.ts +++ b/jetstream/examples/03_batch.ts @@ -13,8 +13,8 @@ * limitations under the License. */ -import { connect } from "jsr:@nats-io/nats-transport-deno@3.0.0-5"; -import { jetstream } from "../src/mod.ts"; +import { connect } from "jsr:@nats-io/transport-deno@3.0.0-7"; +import { jetstream } from "jsr:@nats-io/jetstream@3.0.0-18"; import { setupStreamAndConsumer } from "./util.ts"; // create a connection diff --git a/jetstream/examples/04_consume.ts b/jetstream/examples/04_consume.ts index 4f4a333a..601bf339 100644 --- a/jetstream/examples/04_consume.ts +++ b/jetstream/examples/04_consume.ts @@ -13,8 +13,8 @@ * limitations under the License. */ -import { connect } from "jsr:@nats-io/nats-transport-deno@3.0.0-5"; -import { jetstream } from "../src/mod.ts"; +import { connect } from "jsr:@nats-io/transport-deno@3.0.0-7"; +import { jetstream } from "jsr:@nats-io/jetstream@3.0.0-18"; import { setupStreamAndConsumer } from "./util.ts"; // create a connection @@ -39,6 +39,6 @@ while (true) { m.ack(); } } catch (err) { - console.log(`consume failed: ${err.message}`); + console.log(`consume failed: ${(err as Error).message}`); } } diff --git a/jetstream/examples/05_consume.ts b/jetstream/examples/05_consume.ts index 8feccfd1..d1b0ca4b 100644 --- a/jetstream/examples/05_consume.ts +++ b/jetstream/examples/05_consume.ts @@ -13,8 +13,8 @@ * limitations under the License. */ -import { connect } from "jsr:@nats-io/nats-transport-deno@3.0.0-5"; -import { jetstream } from "../src/mod.ts"; +import { connect } from "jsr:@nats-io/transport-deno@3.0.0-7"; +import { jetstream } from "jsr:@nats-io/jetstream@3.0.0-18"; import { setupStreamAndConsumer } from "./util.ts"; // create a connection diff --git a/jetstream/examples/06_heartbeats.ts b/jetstream/examples/06_heartbeats.ts index 488728f4..fc52d40e 100644 --- a/jetstream/examples/06_heartbeats.ts +++ b/jetstream/examples/06_heartbeats.ts @@ -13,8 +13,8 @@ * limitations under the License. */ -import { connect } from "jsr:@nats-io/nats-transport-deno@3.0.0-5"; -import { ConsumerEvents, jetstream } from "../src/mod.ts"; +import { connect } from "jsr:@nats-io/transport-deno@3.0.0-7"; +import { ConsumerEvents, jetstream } from "jsr:@nats-io/jetstream@3.0.0-18"; import { setupStreamAndConsumer } from "./util.ts"; // create a connection diff --git a/jetstream/examples/07_consume_jobs.ts b/jetstream/examples/07_consume_jobs.ts index f6dc5e53..f158bb94 100644 --- a/jetstream/examples/07_consume_jobs.ts +++ b/jetstream/examples/07_consume_jobs.ts @@ -13,10 +13,10 @@ * limitations under the License. */ -import { connect, delay } from "jsr:@nats-io/nats-transport-deno@3.0.0-5"; +import { connect, delay } from "jsr:@nats-io/transport-deno@3.0.0-7"; import { SimpleMutex } from "jsr:@nats-io/nats-core@3.0.0-17/internal"; -import { jetstream } from "../src/mod.ts"; -import type { JsMsg } from "../src/mod.ts"; +import { jetstream } from "jsr:@nats-io/jetstream@3.0.0-18"; +import type { JsMsg } from "jsr:@nats-io/jetstream@3.0.0-18"; import { setupStreamAndConsumer } from "./util.ts"; // create a connection diff --git a/jetstream/examples/08_consume_process.ts b/jetstream/examples/08_consume_process.ts index 44bcb53b..9af823b4 100644 --- a/jetstream/examples/08_consume_process.ts +++ b/jetstream/examples/08_consume_process.ts @@ -13,9 +13,9 @@ * limitations under the License. */ -import { connect } from "jsr:@nats-io/nats-transport-deno@3.0.0-5"; +import { connect } from "jsr:@nats-io/transport-deno@3.0.0-7"; import { setupStreamAndConsumer } from "./util.ts"; -import { jetstream } from "../src/mod.ts"; +import { jetstream } from "jsr:@nats-io/jetstream@3.0.0-18"; // create a connection const nc = await connect(); diff --git a/jetstream/examples/js_readme_publish_examples.ts b/jetstream/examples/js_readme_publish_examples.ts index c36725d8..a8adb1f5 100644 --- a/jetstream/examples/js_readme_publish_examples.ts +++ b/jetstream/examples/js_readme_publish_examples.ts @@ -1,5 +1,20 @@ -import { connect, Empty } from "jsr:@nats-io/nats-transport-deno@3.0.0-5"; -import { jetstream, jetstreamManager } from "../src/mod.ts"; +/* + * Copyright 2024 Synadia Communications, Inc + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { connect, Empty } from "jsr:@nats-io/transport-deno@3.0.0-7"; +import { jetstream, jetstreamManager } from "jsr:@nats-io/jetstream@3.0.0-18"; import type { PubAck } from "../src/mod.ts"; const nc = await connect(); diff --git a/jetstream/examples/jsm_readme_jsm_example.ts b/jetstream/examples/jsm_readme_jsm_example.ts index 6969f06f..41fcdf83 100644 --- a/jetstream/examples/jsm_readme_jsm_example.ts +++ b/jetstream/examples/jsm_readme_jsm_example.ts @@ -1,5 +1,20 @@ +/* + * Copyright 2024 Synadia Communications, Inc + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import { connect, Empty } from "jsr:@nats-io/nats-transport-deno@3.0.0-5"; -import { AckPolicy, jetstreamManager } from "../src/mod.ts"; +import { AckPolicy, jetstreamManager } from "jsr:@nats-io/jetstream@3.0.0-18"; const nc = await connect(); const jsm = await jetstreamManager(nc); diff --git a/package.json b/package.json deleted file mode 100644 index e8951e30..00000000 --- a/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "workspaces": [ - "./core", - "./jetstream", - "./kv", - "./obj", - "./services", - "./transport-node" - ] -} diff --git a/transport-node/examples/bench.js b/transport-node/examples/bench.js index 8794f2c8..075ad2fb 100755 --- a/transport-node/examples/bench.js +++ b/transport-node/examples/bench.js @@ -1,9 +1,23 @@ +/* + * Copyright 2024 Synadia Communications, Inc + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #!/usr/bin/env node const parse = require("minimist"); -const { Nuid, connect } = require("../index"); -const { Bench, Metric } = require("../lib/nats-base-client/bench"); -const { process } = require("node:process"); +const { Bench, Metric, connect, Nuid } = require("../lib/mod"); +const process = require("node:process"); const defaults = { s: "127.0.0.1:4222", @@ -43,7 +57,7 @@ const argv = parse( if (argv.h || argv.help || (!argv.sub && !argv.pub && !argv.req && !argv.rep)) { console.log( - "usage: bench.ts [--json] [--callbacks] [--csv] [--csvheader] [--pub] [--sub] [--req (--asyncRequests)] [--count <#messages>=100000] [--payload <#bytes>=128] [--iterations <#loop>=1>] [--server server] [--subject ]\n", + "usage: bench.js [--json] [--callbacks] [--csv] [--csvheader] [--pub] [--sub] [--req (--asyncRequests)] [--count <#messages>=100000] [--payload <#bytes>=128] [--iterations <#loop>=1>] [--server server] [--subject ]\n", ); process.exit(0); } diff --git a/transport-node/examples/nats-events.js b/transport-node/examples/nats-events.js index 2a17d1cc..f91c2a80 100755 --- a/transport-node/examples/nats-events.js +++ b/transport-node/examples/nats-events.js @@ -1,6 +1,21 @@ +/* + * Copyright 2024 Synadia Communications, Inc + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #!/usr/bin/env node -const { process } = require("node:process"); +const process = require("node:process"); const parse = require("minimist"); const { connect } = require("../index"); diff --git a/transport-node/examples/nats-pub.js b/transport-node/examples/nats-pub.js index 3ea22378..d64a3f8e 100755 --- a/transport-node/examples/nats-pub.js +++ b/transport-node/examples/nats-pub.js @@ -1,12 +1,26 @@ +/* + * Copyright 2024 Synadia Communications, Inc + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #!/usr/bin/env node const parse = require("minimist"); -const { connect, StringCodec, headers, credsAuthenticator } = require( +const { connect, StringCodec, headers, credsAuthenticator, delay } = require( "../index", ); -const { delay } = require("./util"); const fs = require("node:fs"); -const { process } = require("node:process"); +const process = require("node:process"); const argv = parse( process.argv.slice(2), diff --git a/transport-node/examples/nats-rep.js b/transport-node/examples/nats-rep.js index 292957b5..491d5577 100755 --- a/transport-node/examples/nats-rep.js +++ b/transport-node/examples/nats-rep.js @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Synadia Communications, Inc + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #!/usr/bin/env node const parse = require("minimist"); @@ -5,7 +20,7 @@ const { connect, StringCodec, headers, credsAuthenticator } = require( "../index", ); const fs = require("node:fs"); -const { process } = require("node:process"); +const process = require("node:process"); const argv = parse( process.argv.slice(2), diff --git a/transport-node/examples/nats-req.js b/transport-node/examples/nats-req.js index df314a70..503acea2 100755 --- a/transport-node/examples/nats-req.js +++ b/transport-node/examples/nats-req.js @@ -1,12 +1,26 @@ +/* + * Copyright 2024 Synadia Communications, Inc + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #!/usr/bin/env node const parse = require("minimist"); -const { connect, StringCodec, headers, credsAuthenticator } = require( +const { connect, StringCodec, headers, credsAuthenticator, delay } = require( "../index", ); -const { delay } = require("./util"); const fs = require("node:fs"); -const { process } = require("node:process"); +const process = require("node:process"); const argv = parse( process.argv.slice(2), diff --git a/transport-node/examples/nats-sub.js b/transport-node/examples/nats-sub.js index 07fdd191..5a85ff4f 100755 --- a/transport-node/examples/nats-sub.js +++ b/transport-node/examples/nats-sub.js @@ -1,9 +1,24 @@ +/* + * Copyright 2024 Synadia Communications, Inc + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #!/usr/bin/env node const parse = require("minimist"); const { connect, StringCodec, credsAuthenticator } = require("../index"); const fs = require("node:fs"); -const { process } = require("node:process"); +const process = require("node:process"); const argv = parse( process.argv.slice(2), diff --git a/transport-node/examples/util.js b/transport-node/examples/util.js index cb2b646f..9d257a7f 100644 --- a/transport-node/examples/util.js +++ b/transport-node/examples/util.js @@ -1,10 +1,17 @@ -exports.delay = function delay(ms) { - return new Promise((resolve) => { - setTimeout(() => { - resolve(); - }, ms); - }); -}; +/* + * Copyright 2024 Synadia Communications, Inc + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ exports.Performance = class Performance { timers;