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

[CHANGE] moved nanos() and millis() to nats-base-client as they are referenced by the base library #687

Merged
merged 3 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
deno-version: ${{ matrix.deno-version }}

- name: Set NATS Server Version
run: echo "NATS_VERSION=v2.10.12" >> $GITHUB_ENV
run: echo "NATS_VERSION=v2.10.14" >> $GITHUB_ENV

# this here because dns seems to be wedged on gha
# - name: Add hosts to /etc/hosts
Expand Down
3 changes: 2 additions & 1 deletion jetstream/consumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ import {
backoff,
deferred,
delay,
nanos,
Timeout,
timeout,
} from "../nats-base-client/util.ts";
import { ConsumerAPI, ConsumerAPIImpl } from "./jsmconsumer_api.ts";
import { nuid } from "../nats-base-client/nuid.ts";
import { isHeartbeatMsg, nanos } from "./jsutil.ts";
import { isHeartbeatMsg } from "./jsutil.ts";
import { QueuedIteratorImpl } from "../nats-base-client/queued_iterator.ts";
import {
createInbox,
Expand Down
10 changes: 2 additions & 8 deletions jetstream/internal_mod.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 The NATS Authors
* Copyright 2023-2024 The NATS Authors
* 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
Expand All @@ -12,13 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {
checkJsError,
isFlowControlMsg,
isHeartbeatMsg,
millis,
nanos,
} from "./jsutil.ts";
export { checkJsError, isFlowControlMsg, isHeartbeatMsg } from "./jsutil.ts";

export {
AdvisoryKind,
Expand Down
5 changes: 3 additions & 2 deletions jetstream/jsapi_types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 The NATS Authors
* Copyright 2023-2024 The NATS Authors
* 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
Expand All @@ -14,7 +14,8 @@
*/

import { ApiError, Nanos } from "../nats-base-client/core.ts";
import { nanos } from "./jsutil.ts";

import { nanos } from "../nats-base-client/util.ts";

export interface ApiPaged {
total: number;
Expand Down
10 changes: 7 additions & 3 deletions jetstream/jsclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import {
isHeartbeatMsg,
isTerminal409,
Js409Errors,
millis,
nanos,
newJsErrorMsg,
validateDurableName,
validateStreamName,
Expand All @@ -39,7 +37,13 @@ import {
IngestionFilterFnResult,
QueuedIteratorImpl,
} from "../nats-base-client/queued_iterator.ts";
import { delay, Timeout, timeout } from "../nats-base-client/util.ts";
import {
delay,
millis,
nanos,
Timeout,
timeout,
} from "../nats-base-client/util.ts";
import { headers } from "../nats-base-client/headers.ts";
import { Bucket } from "./kv.ts";
import { Feature } from "../nats-base-client/semver.ts";
Expand Down
4 changes: 2 additions & 2 deletions jetstream/jsmsg.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021-2023 The NATS Authors
* Copyright 2021-2024 The NATS Authors
* 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
Expand All @@ -17,10 +17,10 @@ import { JSONCodec, StringCodec } from "../nats-base-client/codec.ts";
import { MsgImpl } from "../nats-base-client/msg.ts";
import { ProtocolHandler } from "../nats-base-client/protocol.ts";
import { RequestOne } from "../nats-base-client/request.ts";
import { nanos } from "./jsutil.ts";
import { Msg, MsgHdrs, RequestOptions } from "../nats-base-client/core.ts";
import { DeliveryInfo, PullOptions } from "./jsapi_types.ts";
import { deferred } from "../nats-base-client/mod.ts";
import { nanos } from "../nats-base-client/util.ts";

export const ACK = Uint8Array.of(43, 65, 67, 75);
const NAK = Uint8Array.of(45, 78, 65, 75);
Expand Down
19 changes: 1 addition & 18 deletions jetstream/jsutil.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021-2023 The NATS Authors
* Copyright 2021-2024 The NATS Authors
* 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
Expand All @@ -19,7 +19,6 @@ import { MsgImpl } from "../nats-base-client/msg.ts";
import {
ErrorCode,
Msg,
Nanos,
NatsError,
Publisher,
} from "../nats-base-client/core.ts";
Expand Down Expand Up @@ -89,22 +88,6 @@ export function validName(name = ""): string {
return "";
}

/**
* Converts the specified millis into Nanos
* @param millis
*/
export function nanos(millis: number): Nanos {
return millis * 1000000;
}

/**
* Convert the specified Nanos into millis
* @param ns
*/
export function millis(ns: Nanos) {
return Math.floor(ns / 1000000);
}

/**
* Returns true if the message is a flow control message
* @param msg
Expand Down
3 changes: 1 addition & 2 deletions jetstream/kv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
Payload,
QueuedIterator,
} from "../nats-base-client/core.ts";
import { millis, nanos } from "./jsutil.ts";
import { QueuedIteratorImpl } from "../nats-base-client/queued_iterator.ts";
import { headers } from "../nats-base-client/headers.ts";
import {
Expand All @@ -47,7 +46,7 @@ import {
StoredMsg,
} from "./types.ts";
import { compare, Feature, parseSemVer } from "../nats-base-client/semver.ts";
import { deferred } from "../nats-base-client/util.ts";
import { deferred, millis, nanos } from "../nats-base-client/util.ts";
import { Empty } from "../nats-base-client/encoders.ts";
import {
AckPolicy,
Expand Down
4 changes: 1 addition & 3 deletions jetstream/mod.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 The NATS Authors
* Copyright 2023-2024 The NATS Authors
* 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
Expand All @@ -16,8 +16,6 @@ export {
checkJsError,
isFlowControlMsg,
isHeartbeatMsg,
millis,
nanos,
} from "./internal_mod.ts";

export {
Expand Down
8 changes: 6 additions & 2 deletions jetstream/tests/consume_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ import {
} from "https://deno.land/std@0.221.0/assert/mod.ts";
import { initStream } from "./jstest_util.ts";
import { AckPolicy, DeliverPolicy } from "../jsapi_types.ts";
import { deadline, deferred, delay } from "../../nats-base-client/util.ts";
import { nanos } from "../jsutil.ts";
import {
deadline,
deferred,
delay,
nanos,
} from "../../nats-base-client/util.ts";
import {
ConsumerEvents,
ConsumerStatus,
Expand Down
5 changes: 2 additions & 3 deletions jetstream/tests/consumers_test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022-2023 The NATS Authors
* Copyright 2022-2024 The NATS Authors
* 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
Expand All @@ -19,13 +19,12 @@ import {
assertRejects,
assertStringIncludes,
} from "https://deno.land/std@0.221.0/assert/mod.ts";
import { deferred } from "../../nats-base-client/mod.ts";
import { deferred, nanos } from "../../nats-base-client/mod.ts";
import {
AckPolicy,
Consumer,
ConsumerMessages,
DeliverPolicy,
nanos,
PullOptions,
} from "../mod.ts";
import { NatsServer } from "../../tests/helpers/launcher.ts";
Expand Down
3 changes: 1 addition & 2 deletions jetstream/tests/fetch_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ import {
} from "https://deno.land/std@0.221.0/assert/mod.ts";
import { Empty } from "../../nats-base-client/encoders.ts";
import { StringCodec } from "../../nats-base-client/codec.ts";
import { delay } from "../../nats-base-client/util.ts";
import { nanos } from "../jsutil.ts";
import { delay, nanos } from "../../nats-base-client/util.ts";
import { NatsConnectionImpl } from "../../nats-base-client/nats.ts";
import { syncIterator } from "../../nats-base-client/core.ts";
import { PullConsumerMessagesImpl } from "../consumer.ts";
Expand Down
5 changes: 3 additions & 2 deletions jetstream/tests/jetream409_test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022-2023 The NATS Authors
* Copyright 2022-2024 The NATS Authors
* 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
Expand All @@ -13,9 +13,10 @@
* limitations under the License.
*/

import { Js409Errors, nanos, setMaxWaitingToFail } from "../jsutil.ts";
import { Js409Errors, setMaxWaitingToFail } from "../jsutil.ts";
import {
deferred,
nanos,
NatsError,
StringCodec,
} from "../../nats-base-client/mod.ts";
Expand Down
4 changes: 2 additions & 2 deletions jetstream/tests/jetstream_pullconsumer_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ import {
fail,
} from "https://deno.land/std@0.221.0/assert/mod.ts";
import { Empty } from "../../nats-base-client/encoders.ts";
import { checkJsError, nanos } from "../jsutil.ts";
import { checkJsError } from "../jsutil.ts";
import { JSONCodec, StringCodec } from "../../nats-base-client/codec.ts";
import {
consumerOpts,
ConsumerOptsBuilderImpl,
JetStreamSubscriptionInfoable,
PubAck,
} from "../types.ts";
import { deferred, delay } from "../../nats-base-client/util.ts";
import { deferred, delay, nanos } from "../../nats-base-client/util.ts";
import {
DebugEvents,
ErrorCode,
Expand Down
9 changes: 2 additions & 7 deletions jetstream/tests/jetstream_pushconsumer_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,11 @@ import {
} from "../jsapi_types.ts";
import { JSONCodec, StringCodec } from "../../nats-base-client/codec.ts";
import { Empty } from "../../nats-base-client/encoders.ts";
import { deferred, delay } from "../../nats-base-client/util.ts";
import { deferred, delay, nanos } from "../../nats-base-client/util.ts";
import { nuid } from "../../nats-base-client/nuid.ts";
import { JsMsg } from "../jsmsg.ts";
import { connect } from "../../src/connect.ts";
import {
isFlowControlMsg,
isHeartbeatMsg,
Js409Errors,
nanos,
} from "../jsutil.ts";
import { isFlowControlMsg, isHeartbeatMsg, Js409Errors } from "../jsutil.ts";
import { JetStreamSubscriptionImpl } from "../jsclient.ts";

Deno.test("jetstream - ephemeral push", async () => {
Expand Down
2 changes: 1 addition & 1 deletion jetstream/tests/jetstream_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
JsHeaders,
JsMsg,
JsMsgCallback,
nanos,
PubAck,
RepublishHeaders,
RetentionPolicy,
Expand All @@ -41,6 +40,7 @@ import {
ErrorCode,
headers,
JSONCodec,
nanos,
NatsError,
nuid,
StringCodec,
Expand Down
2 changes: 1 addition & 1 deletion jetstream/tests/jsm_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
headers,
JSONCodec,
jwtAuthenticator,
nanos,
NatsConnection,
NatsError,
nkeys,
Expand All @@ -43,7 +44,6 @@ import {
ConsumerInfo,
DiscardPolicy,
Lister,
nanos,
PubAck,
RetentionPolicy,
StorageType,
Expand Down
2 changes: 1 addition & 1 deletion jetstream/tests/jsmsg_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import {
createInbox,
Empty,
Msg,
nanos,
StorageType,
StringCodec,
} from "../../src/mod.ts";
import { nanos } from "../jsutil.ts";
import { JsMsgImpl, parseInfo, toJsMsg } from "../jsmsg.ts";
import {
cleanup,
Expand Down
2 changes: 1 addition & 1 deletion jetstream/tests/kv_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
deferred,
delay,
Empty,
nanos,
NatsConnection,
NatsConnectionImpl,
nuid,
Expand All @@ -34,7 +35,6 @@ import {
KV,
KvEntry,
KvOptions,
nanos,
StorageType,
} from "../mod.ts";

Expand Down
3 changes: 1 addition & 2 deletions jetstream/tests/next_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ import {
assertEquals,
assertRejects,
} from "https://deno.land/std@0.221.0/assert/mod.ts";
import { nanos } from "../jsutil.ts";
import { NatsConnectionImpl } from "../../nats-base-client/nats.ts";
import { delay } from "../../nats-base-client/util.ts";
import { delay, nanos } from "../../nats-base-client/util.ts";

Deno.test("next - basics", async () => {
const { ns, nc } = await setup(jetstreamServerConf());
Expand Down
3 changes: 2 additions & 1 deletion jetstream/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ import {
import { JsMsg } from "./jsmsg.ts";
import { BaseApiClient } from "./jsbaseclient_api.ts";
import { ConsumerAPI } from "./jsmconsumer_api.ts";
import { nanos, validateDurableName } from "./jsutil.ts";
import { validateDurableName } from "./jsutil.ts";
import { Lister } from "./jslister.ts";
import { nanos } from "../nats-base-client/util.ts";

/**
* The response returned by the JetStream server when a message is added to a stream.
Expand Down
2 changes: 2 additions & 0 deletions nats-base-client/internal_mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export {
deferred,
delay,
extend,
millis,
nanos,
render,
timeout,
} from "./util.ts";
Expand Down
2 changes: 2 additions & 0 deletions nats-base-client/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ export {
jwtAuthenticator,
Match,
Metric,
millis,
MsgHdrsImpl,
nanos,
NatsError,
nkeyAuthenticator,
nkeys,
Expand Down
4 changes: 2 additions & 2 deletions nats-base-client/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Deferred, deferred } from "./util.ts";
import { Deferred, deferred, nanos } from "./util.ts";
import { headers } from "./headers.ts";
import { JSONCodec } from "./codec.ts";
import { nuid } from "./nuid.ts";
import { QueuedIteratorImpl } from "./queued_iterator.ts";
import { nanos, validateName } from "../jetstream/jsutil.ts";
import { validateName } from "../jetstream/jsutil.ts";
import { parseSemVer } from "./semver.ts";
import { Empty } from "./encoders.ts";
import {
Expand Down
Loading
Loading