@nats-io/services 3.0.0-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,106 @@
1
+ /*
2
+ * Copyright 2022-2024 The NATS Authors
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+ import {
16
+ Empty,
17
+ JSONCodec,
18
+ QueuedIteratorImpl,
19
+ RequestStrategy,
20
+ } from "@nats-io/nats-core/internal";
21
+
22
+ import type {
23
+ NatsConnection,
24
+ QueuedIterator,
25
+ RequestManyOptions,
26
+ } from "@nats-io/nats-core/internal";
27
+
28
+ import { ServiceImpl } from "./service";
29
+ import { ServiceVerb } from "./types";
30
+
31
+ import type {
32
+ ServiceClient,
33
+ ServiceIdentity,
34
+ ServiceInfo,
35
+ ServiceStats,
36
+ } from "./types";
37
+
38
+ export class ServiceClientImpl implements ServiceClient {
39
+ nc: NatsConnection;
40
+ prefix: string | undefined;
41
+ opts: RequestManyOptions;
42
+ constructor(
43
+ nc: NatsConnection,
44
+ opts: RequestManyOptions = {
45
+ strategy: RequestStrategy.JitterTimer,
46
+ maxWait: 2000,
47
+ },
48
+ prefix?: string,
49
+ ) {
50
+ this.nc = nc;
51
+ this.prefix = prefix;
52
+ this.opts = opts;
53
+ }
54
+
55
+ ping(
56
+ name = "",
57
+ id = "",
58
+ ): Promise<QueuedIterator<ServiceIdentity>> {
59
+ return this.q<ServiceIdentity>(ServiceVerb.PING, name, id);
60
+ }
61
+
62
+ stats(
63
+ name = "",
64
+ id = "",
65
+ ): Promise<QueuedIterator<ServiceStats>> {
66
+ return this.q<ServiceStats>(ServiceVerb.STATS, name, id);
67
+ }
68
+
69
+ info(
70
+ name = "",
71
+ id = "",
72
+ ): Promise<QueuedIterator<ServiceInfo>> {
73
+ return this.q<ServiceInfo>(ServiceVerb.INFO, name, id);
74
+ }
75
+
76
+ async q<T>(
77
+ v: ServiceVerb,
78
+ name = "",
79
+ id = "",
80
+ ): Promise<QueuedIterator<T>> {
81
+ const iter = new QueuedIteratorImpl<T>();
82
+ const jc = JSONCodec<T>();
83
+ const subj = ServiceImpl.controlSubject(v, name, id, this.prefix);
84
+ const responses = await this.nc.requestMany(subj, Empty, this.opts);
85
+ (async () => {
86
+ for await (const m of responses) {
87
+ try {
88
+ const s = jc.decode(m.data);
89
+ iter.push(s);
90
+ } catch (err) {
91
+ // @ts-ignore: pushing fn
92
+ iter.push(() => {
93
+ iter.stop(err);
94
+ });
95
+ }
96
+ }
97
+ //@ts-ignore: push a fn
98
+ iter.push(() => {
99
+ iter.stop();
100
+ });
101
+ })().catch((err) => {
102
+ iter.stop(err);
103
+ });
104
+ return iter;
105
+ }
106
+ }
@@ -0,0 +1,300 @@
1
+ import type {
2
+ Msg,
3
+ Nanos,
4
+ NatsError,
5
+ PublishOptions,
6
+ QueuedIterator,
7
+ } from "@nats-io/nats-core";
8
+
9
+ export interface ServiceMsg extends Msg {
10
+ respondError(
11
+ code: number,
12
+ description: string,
13
+ data?: Uint8Array,
14
+ opts?: PublishOptions,
15
+ ): boolean;
16
+ }
17
+
18
+ export type ServiceHandler = (err: NatsError | null, msg: ServiceMsg) => void;
19
+ /**
20
+ * A service Endpoint
21
+ */
22
+ export type Endpoint = {
23
+ /**
24
+ * Subject where the endpoint listens
25
+ */
26
+ subject: string;
27
+ /**
28
+ * An optional handler - if not set the service is an iterator
29
+ * @param err
30
+ * @param msg
31
+ */
32
+ handler?: ServiceHandler;
33
+ /**
34
+ * Optional metadata about the endpoint
35
+ */
36
+ metadata?: Record<string, string>;
37
+ /**
38
+ * Optional queue group to run this particular endpoint in. The service's configuration
39
+ * queue configuration will be used. See {@link ServiceConfig}.
40
+ */
41
+ queue?: string;
42
+ };
43
+ export type EndpointOptions = Partial<Endpoint>;
44
+ export type EndpointInfo = {
45
+ name: string;
46
+ subject: string;
47
+ metadata?: Record<string, string>;
48
+ queue_group?: string;
49
+ };
50
+
51
+ export interface ServiceGroup {
52
+ /**
53
+ * The name of the endpoint must be a simple subject token with no wildcards
54
+ * @param name
55
+ * @param opts is either a handler or a more complex options which allows a
56
+ * subject, handler, and/or schema
57
+ */
58
+ addEndpoint(
59
+ name: string,
60
+ opts?: ServiceHandler | EndpointOptions,
61
+ ): QueuedIterator<ServiceMsg>;
62
+
63
+ /**
64
+ * A group is a subject prefix from which endpoints can be added.
65
+ * Can be empty to allow for prefixes or tokens that are set at runtime
66
+ * without requiring editing of the service.
67
+ * Note that an optional queue can be specified, all endpoints added to
68
+ * the group, will use the specified queue unless the endpoint overrides it.
69
+ * see {@link EndpointOptions} and {@link ServiceConfig}.
70
+ * @param subject
71
+ * @param queue
72
+ */
73
+ addGroup(subject?: string, queue?: string): ServiceGroup;
74
+ }
75
+
76
+ export type ServiceMetadata = {
77
+ metadata?: Record<string, string>;
78
+ };
79
+
80
+ export enum ServiceResponseType {
81
+ STATS = "io.nats.micro.v1.stats_response",
82
+ INFO = "io.nats.micro.v1.info_response",
83
+ PING = "io.nats.micro.v1.ping_response",
84
+ }
85
+
86
+ export interface ServiceResponse {
87
+ /**
88
+ * Response type schema
89
+ */
90
+ type: ServiceResponseType;
91
+ }
92
+
93
+ export type ServiceIdentity = ServiceResponse & ServiceMetadata & {
94
+ /**
95
+ * The kind of the service reporting the stats
96
+ */
97
+ name: string;
98
+ /**
99
+ * The unique ID of the service reporting the stats
100
+ */
101
+ id: string;
102
+ /**
103
+ * A version for the service
104
+ */
105
+ version: string;
106
+ };
107
+ export type NamedEndpointStats = {
108
+ /**
109
+ * The name of the endpoint
110
+ */
111
+ name: string;
112
+ /**
113
+ * The subject the endpoint is listening on
114
+ */
115
+ subject: string;
116
+ /**
117
+ * The number of requests received by the endpoint
118
+ */
119
+ num_requests: number;
120
+ /**
121
+ * Number of errors that the endpoint has raised
122
+ */
123
+ num_errors: number;
124
+ /**
125
+ * If set, the last error triggered by the endpoint
126
+ */
127
+ last_error?: string;
128
+ /**
129
+ * A field that can be customized with any data as returned by stats handler see {@link ServiceConfig}
130
+ */
131
+ data?: unknown;
132
+ /**
133
+ * Total processing_time for the service
134
+ */
135
+ processing_time: Nanos;
136
+ /**
137
+ * Average processing_time is the total processing_time divided by the num_requests
138
+ */
139
+ average_processing_time: Nanos;
140
+ /**
141
+ * The queue group the endpoint is listening on
142
+ */
143
+ queue_group?: string;
144
+ };
145
+ /**
146
+ * Statistics for an endpoint
147
+ */
148
+ export type EndpointStats = ServiceIdentity & {
149
+ endpoints?: NamedEndpointStats[];
150
+ /**
151
+ * ISO Date string when the service started
152
+ */
153
+ started: string;
154
+ };
155
+ export type ServiceInfo = ServiceIdentity & {
156
+ /**
157
+ * Description for the service
158
+ */
159
+ description: string;
160
+ /**
161
+ * Service metadata
162
+ */
163
+ metadata?: Record<string, string>;
164
+ /**
165
+ * Information about the Endpoints
166
+ */
167
+ endpoints: EndpointInfo[];
168
+ };
169
+ export type ServiceConfig = {
170
+ /**
171
+ * A type for a service
172
+ */
173
+ name: string;
174
+ /**
175
+ * A version identifier for the service
176
+ */
177
+ version: string;
178
+ /**
179
+ * Description for the service
180
+ */
181
+ description?: string;
182
+ /**
183
+ * A customized handler for the stats of an endpoint. The
184
+ * data returned by the endpoint will be serialized as is
185
+ * @param endpoint
186
+ */
187
+ statsHandler?: (
188
+ endpoint: Endpoint,
189
+ ) => Promise<unknown | null>;
190
+
191
+ /**
192
+ * Optional metadata about the service
193
+ */
194
+ metadata?: Record<string, string>;
195
+ /**
196
+ * Optional queue group to run the service in. By default,
197
+ * then queue name is "q". Note that this configuration will
198
+ * be the default for all endpoints and groups.
199
+ */
200
+ queue?: string;
201
+ };
202
+ /**
203
+ * The stats of a service
204
+ */
205
+ export type ServiceStats = ServiceIdentity & EndpointStats;
206
+
207
+ export interface Service extends ServiceGroup {
208
+ /**
209
+ * A promise that gets resolved to null or Error once the service ends.
210
+ * If an error, then service exited because of an error.
211
+ */
212
+ stopped: Promise<null | Error>;
213
+ /**
214
+ * True if the service is stopped
215
+ */
216
+ // FIXME: this would be better as stop - but the queued iterator may be an issue perhaps call it `isStopped`
217
+ isStopped: boolean;
218
+
219
+ /**
220
+ * Returns the stats for the service.
221
+ */
222
+ stats(): Promise<ServiceStats>;
223
+
224
+ /**
225
+ * Returns a service info for the service
226
+ */
227
+ info(): ServiceInfo;
228
+
229
+ /**
230
+ * Returns the identity used by this service
231
+ */
232
+ ping(): ServiceIdentity;
233
+
234
+ /**
235
+ * Resets all the stats
236
+ */
237
+ reset(): void;
238
+
239
+ /**
240
+ * Stop the service returning a promise once the service completes.
241
+ * If the service was stopped due to an error, that promise resolves to
242
+ * the specified error
243
+ */
244
+ stop(err?: Error): Promise<null | Error>;
245
+ }
246
+
247
+ export const ServiceErrorHeader = "Nats-Service-Error";
248
+ export const ServiceErrorCodeHeader = "Nats-Service-Error-Code";
249
+
250
+ export class ServiceError extends Error {
251
+ code: number;
252
+
253
+ constructor(code: number, message: string) {
254
+ super(message);
255
+ this.code = code;
256
+ }
257
+
258
+ static isServiceError(msg: Msg): boolean {
259
+ return ServiceError.toServiceError(msg) !== null;
260
+ }
261
+
262
+ static toServiceError(msg: Msg): ServiceError | null {
263
+ const scode = msg?.headers?.get(ServiceErrorCodeHeader) || "";
264
+ if (scode !== "") {
265
+ const code = parseInt(scode) || 400;
266
+ const description = msg?.headers?.get(ServiceErrorHeader) || "";
267
+ return new ServiceError(code, description.length ? description : scode);
268
+ }
269
+ return null;
270
+ }
271
+ }
272
+
273
+ export enum ServiceVerb {
274
+ PING = "PING",
275
+ STATS = "STATS",
276
+ INFO = "INFO",
277
+ }
278
+
279
+ export interface ServiceClient {
280
+ /**
281
+ * Pings services
282
+ * @param name - optional
283
+ * @param id - optional
284
+ */
285
+ ping(name?: string, id?: string): Promise<QueuedIterator<ServiceIdentity>>;
286
+
287
+ /**
288
+ * Requests all the stats from services
289
+ * @param name
290
+ * @param id
291
+ */
292
+ stats(name?: string, id?: string): Promise<QueuedIterator<ServiceStats>>;
293
+
294
+ /**
295
+ * Requests info from services
296
+ * @param name
297
+ * @param id
298
+ */
299
+ info(name?: string, id?: string): Promise<QueuedIterator<ServiceInfo>>;
300
+ }
@@ -0,0 +1,10 @@
1
+ import type { NatsConnection, RequestManyOptions } from "@nats-io/nats-core";
2
+ import type { Service, ServiceClient, ServiceConfig } from "./types";
3
+ export type { Endpoint, EndpointInfo, EndpointOptions, EndpointStats, NamedEndpointStats, Service, ServiceClient, ServiceConfig, ServiceGroup, ServiceHandler, ServiceIdentity, ServiceInfo, ServiceMetadata, ServiceMsg, ServiceResponse, ServiceStats, } from "./types";
4
+ export { ServiceError, ServiceErrorCodeHeader, ServiceErrorHeader, ServiceResponseType, ServiceVerb, } from "./types";
5
+ export declare class Svc {
6
+ nc: NatsConnection;
7
+ constructor(nc: NatsConnection);
8
+ add(config: ServiceConfig): Promise<Service>;
9
+ client(opts?: RequestManyOptions, prefix?: string): ServiceClient;
10
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Svc = exports.ServiceVerb = exports.ServiceResponseType = exports.ServiceErrorHeader = exports.ServiceErrorCodeHeader = exports.ServiceError = void 0;
4
+ const service_1 = require("./service");
5
+ const serviceclient_1 = require("./serviceclient");
6
+ var types_1 = require("./types");
7
+ Object.defineProperty(exports, "ServiceError", { enumerable: true, get: function () { return types_1.ServiceError; } });
8
+ Object.defineProperty(exports, "ServiceErrorCodeHeader", { enumerable: true, get: function () { return types_1.ServiceErrorCodeHeader; } });
9
+ Object.defineProperty(exports, "ServiceErrorHeader", { enumerable: true, get: function () { return types_1.ServiceErrorHeader; } });
10
+ Object.defineProperty(exports, "ServiceResponseType", { enumerable: true, get: function () { return types_1.ServiceResponseType; } });
11
+ Object.defineProperty(exports, "ServiceVerb", { enumerable: true, get: function () { return types_1.ServiceVerb; } });
12
+ class Svc {
13
+ nc;
14
+ constructor(nc) {
15
+ this.nc = nc;
16
+ }
17
+ add(config) {
18
+ try {
19
+ const s = new service_1.ServiceImpl(this.nc, config);
20
+ return s.start();
21
+ }
22
+ catch (err) {
23
+ return Promise.reject(err);
24
+ }
25
+ }
26
+ client(opts, prefix) {
27
+ return new serviceclient_1.ServiceClientImpl(this.nc, opts, prefix);
28
+ }
29
+ }
30
+ exports.Svc = Svc;
31
+ //# sourceMappingURL=internal_mod.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal_mod.js","sourceRoot":"","sources":["../build/src/internal_mod.ts"],"names":[],"mappings":";;;AACA,uCAAwC;AACxC,mDAAoD;AAsBpD,iCAMiB;AALf,qGAAA,YAAY,OAAA;AACZ,+GAAA,sBAAsB,OAAA;AACtB,2GAAA,kBAAkB,OAAA;AAClB,4GAAA,mBAAmB,OAAA;AACnB,oGAAA,WAAW,OAAA;AAGb,MAAa,GAAG;IACd,EAAE,CAAiB;IAEnB,YAAY,EAAkB;QAC5B,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;IAED,GAAG,CAAC,MAAqB;QACvB,IAAI,CAAC;YACH,MAAM,CAAC,GAAG,IAAI,qBAAW,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;YAC3C,OAAO,CAAC,CAAC,KAAK,EAAE,CAAC;QACnB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,MAAM,CAAC,IAAyB,EAAE,MAAe;QAC/C,OAAO,IAAI,iCAAiB,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IACtD,CAAC;CACF;AAnBD,kBAmBC"}
package/lib/mod.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export type { Endpoint, EndpointInfo, EndpointOptions, EndpointStats, NamedEndpointStats, Service, ServiceClient, ServiceConfig, ServiceGroup, ServiceHandler, ServiceIdentity, ServiceInfo, ServiceMetadata, ServiceMsg, ServiceResponse, ServiceStats, } from "./internal_mod";
2
+ export { ServiceError, ServiceErrorCodeHeader, ServiceErrorHeader, ServiceResponseType, ServiceVerb, Svc, } from "./internal_mod";
package/lib/mod.js ADDED
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Svc = exports.ServiceVerb = exports.ServiceResponseType = exports.ServiceErrorHeader = exports.ServiceErrorCodeHeader = exports.ServiceError = void 0;
4
+ var internal_mod_1 = require("./internal_mod");
5
+ Object.defineProperty(exports, "ServiceError", { enumerable: true, get: function () { return internal_mod_1.ServiceError; } });
6
+ Object.defineProperty(exports, "ServiceErrorCodeHeader", { enumerable: true, get: function () { return internal_mod_1.ServiceErrorCodeHeader; } });
7
+ Object.defineProperty(exports, "ServiceErrorHeader", { enumerable: true, get: function () { return internal_mod_1.ServiceErrorHeader; } });
8
+ Object.defineProperty(exports, "ServiceResponseType", { enumerable: true, get: function () { return internal_mod_1.ServiceResponseType; } });
9
+ Object.defineProperty(exports, "ServiceVerb", { enumerable: true, get: function () { return internal_mod_1.ServiceVerb; } });
10
+ Object.defineProperty(exports, "Svc", { enumerable: true, get: function () { return internal_mod_1.Svc; } });
11
+ //# sourceMappingURL=mod.js.map
package/lib/mod.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.js","sourceRoot":"","sources":["../build/src/mod.ts"],"names":[],"mappings":";;;AAmBA,+CAOwB;AANtB,4GAAA,YAAY,OAAA;AACZ,sHAAA,sBAAsB,OAAA;AACtB,kHAAA,kBAAkB,OAAA;AAClB,mHAAA,mBAAmB,OAAA;AACnB,2GAAA,WAAW,OAAA;AACX,mGAAA,GAAG,OAAA"}
@@ -0,0 +1,105 @@
1
+ import type { Deferred, Msg, MsgHdrs, Nanos, NatsConnection, NatsError, Payload, PublishOptions, QueuedIterator, ReviverFn, Sub } from "@nats-io/nats-core/internal";
2
+ import { ServiceVerb } from "./types";
3
+ import type { Endpoint, EndpointInfo, EndpointOptions, NamedEndpointStats, Service, ServiceConfig, ServiceGroup, ServiceHandler, ServiceIdentity, ServiceInfo, ServiceMsg, ServiceStats } from "./types";
4
+ /**
5
+ * Services have common backplane subject pattern:
6
+ *
7
+ * `$SRV.PING|STATS|INFO` - pings or retrieves status for all services
8
+ * `$SRV.PING|STATS|INFO.<name>` - pings or retrieves status for all services having the specified name
9
+ * `$SRV.PING|STATS|INFO.<name>.<id>` - pings or retrieves status of a particular service
10
+ *
11
+ * Note that <name> and <id> are upper-cased.
12
+ */
13
+ export declare const ServiceApiPrefix = "$SRV";
14
+ export declare class ServiceMsgImpl implements ServiceMsg {
15
+ msg: Msg;
16
+ constructor(msg: Msg);
17
+ get data(): Uint8Array;
18
+ get sid(): number;
19
+ get subject(): string;
20
+ get reply(): string;
21
+ get headers(): MsgHdrs | undefined;
22
+ respond(data?: Payload, opts?: PublishOptions): boolean;
23
+ respondError(code: number, description: string, data?: Uint8Array, opts?: PublishOptions): boolean;
24
+ json<T = unknown>(reviver?: ReviverFn): T;
25
+ string(): string;
26
+ }
27
+ export declare class ServiceGroupImpl implements ServiceGroup {
28
+ subject: string;
29
+ queue: string;
30
+ srv: ServiceImpl;
31
+ constructor(parent: ServiceGroup, name?: string, queue?: string);
32
+ calcSubject(root: string, name?: string): string;
33
+ addEndpoint(name?: string, opts?: ServiceHandler | EndpointOptions): QueuedIterator<ServiceMsg>;
34
+ addGroup(name?: string, queue?: string): ServiceGroup;
35
+ }
36
+ type NamedEndpoint = {
37
+ name: string;
38
+ } & Endpoint;
39
+ type ServiceSubscription<T = unknown> = NamedEndpoint & {
40
+ internal: boolean;
41
+ sub: Sub<T>;
42
+ qi?: QueuedIterator<T>;
43
+ stats: NamedEndpointStatsImpl;
44
+ metadata?: Record<string, string>;
45
+ };
46
+ export declare class ServiceImpl implements Service {
47
+ nc: NatsConnection;
48
+ _id: string;
49
+ config: ServiceConfig;
50
+ handlers: ServiceSubscription[];
51
+ internal: ServiceSubscription[];
52
+ _stopped: boolean;
53
+ _done: Deferred<Error | null>;
54
+ started: string;
55
+ /**
56
+ * @param verb
57
+ * @param name
58
+ * @param id
59
+ * @param prefix - this is only supplied by tooling when building control subject that crosses an account
60
+ */
61
+ static controlSubject(verb: ServiceVerb, name?: string, id?: string, prefix?: string): string;
62
+ constructor(nc: NatsConnection, config?: ServiceConfig);
63
+ get subjects(): string[];
64
+ get id(): string;
65
+ get name(): string;
66
+ get description(): string;
67
+ get version(): string;
68
+ get metadata(): Record<string, string> | undefined;
69
+ errorToHeader(err: Error): MsgHdrs;
70
+ setupHandler(h: NamedEndpoint, internal?: boolean): ServiceSubscription;
71
+ info(): ServiceInfo;
72
+ endpoints(): EndpointInfo[];
73
+ stats(): Promise<ServiceStats>;
74
+ addInternalHandler(verb: ServiceVerb, handler: (err: NatsError | null, msg: Msg) => Promise<void>): void;
75
+ _doAddInternalHandler(name: string, verb: ServiceVerb, handler: (err: NatsError | null, msg: Msg) => Promise<void>, kind?: string, id?: string): void;
76
+ start(): Promise<Service>;
77
+ close(err?: Error): Promise<null | Error>;
78
+ get stopped(): Promise<null | Error>;
79
+ get isStopped(): boolean;
80
+ stop(err?: Error): Promise<null | Error>;
81
+ ping(): ServiceIdentity;
82
+ reset(): void;
83
+ addGroup(name: string, queue?: string): ServiceGroup;
84
+ addEndpoint(name: string, handler?: ServiceHandler | EndpointOptions): QueuedIterator<ServiceMsg>;
85
+ _addEndpoint(e: NamedEndpoint): QueuedIterator<ServiceMsg>;
86
+ }
87
+ declare class NamedEndpointStatsImpl implements NamedEndpointStats {
88
+ name: string;
89
+ subject: string;
90
+ average_processing_time: Nanos;
91
+ num_requests: number;
92
+ processing_time: Nanos;
93
+ num_errors: number;
94
+ last_error?: string;
95
+ data?: unknown;
96
+ metadata?: Record<string, string>;
97
+ queue: string;
98
+ constructor(name: string, subject: string, queue?: string);
99
+ reset(qi?: QueuedIterator<unknown>): void;
100
+ countLatency(start: number): void;
101
+ countError(err: Error): void;
102
+ _stats(): NamedEndpointStats;
103
+ stats(qi?: QueuedIterator<unknown>): NamedEndpointStats;
104
+ }
105
+ export {};