Skip to content

Commit

Permalink
Merge pull request #537 from nats-io/doc-types
Browse files Browse the repository at this point in the history
moved reviver from jetstream to core
  • Loading branch information
aricart committed Jun 15, 2023
2 parents aa66750 + 298d467 commit 606a977
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 17 deletions.
2 changes: 1 addition & 1 deletion jetstream/jsm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {
DirectStreamAPI,
JetStreamClient,
JetStreamManager,
ReviverFn,
StoredMsg,
StreamAPI,
} from "./types.ts";
Expand All @@ -34,6 +33,7 @@ import {
Msg,
MsgHdrs,
NatsConnection,
ReviverFn,
} from "../nats-base-client/core.ts";
import {
AccountInfoResponse,
Expand Down
7 changes: 5 additions & 2 deletions jetstream/jsmstream_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@ import {
kvPrefix,
KvStatus,
ObjectStoreStatus,
ReviverFn,
StoredMsg,
Stream,
StreamAPI,
Streams,
} from "./types.ts";
import { JetStreamOptions, NatsConnection } from "../nats-base-client/core.ts";
import {
JetStreamOptions,
NatsConnection,
ReviverFn,
} from "../nats-base-client/core.ts";
import {
ApiPagedRequest,
ExternalStream,
Expand Down
7 changes: 1 addition & 6 deletions jetstream/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
NatsError,
Payload,
QueuedIterator,
ReviverFn,
Sub,
} from "../nats-base-client/core.ts";
import { TypedSubscriptionOptions } from "../nats-base-client/typedsub.ts";
Expand Down Expand Up @@ -758,12 +759,6 @@ export interface DirectStreamAPI {
getMessage(stream: string, query: DirectMsgRequest): Promise<StoredMsg>;
}

/**
* A reviver function
*/
//deno-lint-ignore no-explicit-any
export type ReviverFn = (key: string, value: any) => any;

/**
* An interface representing a message that retrieved directly from JetStream.
*/
Expand Down
12 changes: 7 additions & 5 deletions nats-base-client/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
* limitations under the License.
*/

import {
JetStreamClient,
JetStreamManager,
ReviverFn,
} from "../jetstream/types.ts";
import { JetStreamClient, JetStreamManager } from "../jetstream/types.ts";
import { nuid } from "./nuid.ts";

/**
Expand Down Expand Up @@ -649,6 +645,12 @@ export interface NatsConnection {
services: ServicesAPI;
}

/**
* A reviver function
*/
//deno-lint-ignore no-explicit-any
export type ReviverFn = (key: string, value: any) => any;

/**
* Represents a message delivered by NATS. This interface is used by
* Subscribers.
Expand Down
1 change: 1 addition & 0 deletions nats-base-client/internal_mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export type {
PublishOptions,
RequestManyOptions,
RequestOptions,
ReviverFn,
Server,
ServerInfo,
ServersChanged,
Expand Down
1 change: 1 addition & 0 deletions nats-base-client/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export type {
QueuedIterator,
RequestManyOptions,
RequestOptions,
ReviverFn,
ServerInfo,
ServersChanged,
Service,
Expand Down
10 changes: 8 additions & 2 deletions nats-base-client/msg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@ import { MsgHdrsImpl } from "./headers.ts";
import type { MsgArg } from "./parser.ts";
import { Empty, TD } from "./encoders.ts";
import { Codec, JSONCodec } from "./codec.ts";
import { ErrorCode, Msg, MsgHdrs, NatsError, Publisher } from "./core.ts";
import { ReviverFn } from "../jetstream/types.ts";
import {
ErrorCode,
Msg,
MsgHdrs,
NatsError,
Publisher,
ReviverFn,
} from "./core.ts";

export function isRequestError(msg: Msg): NatsError | null {
// NATS core only considers errors 503s on messages that have no payload
Expand Down
2 changes: 1 addition & 1 deletion nats-base-client/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
Payload,
PublishOptions,
QueuedIterator,
ReviverFn,
Service,
ServiceConfig,
ServiceError,
Expand All @@ -48,7 +49,6 @@ import {
ServiceVerb,
Sub,
} from "./core.ts";
import { ReviverFn } from "../jetstream/types.ts";

/**
* Services have common backplane subject pattern:
Expand Down

0 comments on commit 606a977

Please sign in to comment.