Skip to content

Commit

Permalink
Preparing for update (#575)
Browse files Browse the repository at this point in the history
* [CHORE] updated lib mod.ts to re-export jetstream/mod (as jetstream was moved to jetstream/ dir), and also fix directly importing deps from specific files that were relocated.

[TEST] removed the test that required only Uint8Array (now strings are also possible)

* bump version, align benches
  • Loading branch information
aricart committed Jun 16, 2023
1 parent 404ff95 commit a662822
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 22 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ benchmark/
coverage/
lib/
nats-base-client/
jetstream/
node_modules/
debug/
7 changes: 4 additions & 3 deletions examples/bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const defaults = {
json: false,
csv: false,
csvheader: false,
pending: 1024 * 32,
pendingLimit: 32,
};

const argv = parse(
Expand Down Expand Up @@ -50,14 +50,15 @@ const server = argv.server;
const count = parseInt(argv.count);
const bytes = parseInt(argv.payload);
const iters = parseInt(argv.iterations);
const pl = parseInt(argv.pendingLimit) * 1024;
const pendingLimit = parseInt(argv.pendingLimit) * 1024;
const metrics = [];

(async () => {
for (let i = 0; i < iters; i++) {
const nc = await connect(
{ servers: server, debug: argv.debug, pending: argv.pending },
{ servers: server, debug: argv.debug },
);
nc.protocol.pendingLimit = pendingLimit;
const opts = {
msgs: count,
size: bytes,
Expand Down
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@
"MAINTAINERS.md"
],
"scripts": {
"build": "tsc",
"cjs": "deno run --allow-all bin/cjs-fix-imports.ts -o nats-base-client/ ./.deps/nats.deno/nats-base-client/ && deno run --allow-all bin/cjs-fix-imports.ts -o jetstream/ ./.deps/nats.deno/jetstream/",
"build": "tsc",
"cjs-nbc": "deno run --allow-all ./bin/cjs-fix-imports.ts -o nats-base-client/ ./.deps/nats.deno/nats-base-client",
"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 dev https://github.com/nats-io/nats.deno.git",
"clone-nbc": "shx mkdir -p ./.deps && cd ./.deps && git clone --branch v1.15.0 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 Expand Up @@ -85,7 +87,9 @@
"src/**/*.ts",
"lib/src/**/*.js",
"nats-base-client/**/*.ts",
"lib/nats-base-client/**/*.js"
"lib/nats-base-client/**/*.js",
"jetstream/**/*.ts",
"lib/jetstream/**/*.js"
],
"exclude": [
"nats-base-client/bench.ts",
Expand Down
3 changes: 2 additions & 1 deletion src/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ if (typeof globalThis.ReadableStream === "undefined") {
}

export { connect } from "./connect";
export * from "./nats-base-client";
export * from "../nats-base-client/mod";
export * from "../jetstream/mod";
9 changes: 0 additions & 9 deletions test/basics.js
Original file line number Diff line number Diff line change
Expand Up @@ -667,15 +667,6 @@ test("basics - subject is required", async (t) => {
await ns.stop();
});

test("basics - payload is only Uint8Array", async (t) => {
const nc = await connect({ servers: u });
t.throws(() => {
nc.publish(createInbox(), "s");
}, { code: ErrorCode.BadPayload });

await nc.close();
});

test("basics - disconnect reconnects", async (t) => {
const ns = await NatsServer.start();
const nc = await connect({ port: ns.port });
Expand Down
7 changes: 3 additions & 4 deletions test/jetstream.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ const {
headers,
nuid,
StringCodec,
AckPolicy,
consumerOpts,
} = require(
"../",
);

const { delay, DataBuffer } = require("../lib/nats-base-client/internal_mod");
const { AckPolicy, consumerOpts } = require("../lib/src/mod");
const { delay } = require("../lib/nats-base-client/internal_mod");
const { NatsServer } = require("./helpers/launcher");
const { jetstreamServerConf } = require("./helpers/jsutil");
const { DataBuffer } = require("../lib/nats-base-client/databuffer");
const { setTimeout } = require("timers");

test("jetstream - jsm", async (t) => {
Expand Down
2 changes: 1 addition & 1 deletion test/tls.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const { resolve, join } = require("path");
const { readFileSync } = require("fs");
const { Lock } = require("./helpers/lock");
const { NatsServer } = require("./helpers/launcher");
const { buildAuthenticator } = require("../lib/src/mod");
const { buildAuthenticator } = require("../lib/nats-base-client/options");
const { extend } = require("../lib/nats-base-client/util");
const { Connect } = require("../lib/nats-base-client/protocol");

Expand Down

0 comments on commit a662822

Please sign in to comment.