@camera.ui/rpc 1.0.3 → 1.0.4
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.
- package/externals/nats.js/core/src/authenticator.ts +159 -0
- package/externals/nats.js/core/src/bench.ts +426 -0
- package/externals/nats.js/core/src/codec.ts +28 -0
- package/externals/nats.js/core/src/core.ts +1219 -0
- package/externals/nats.js/core/src/databuffer.ts +129 -0
- package/externals/nats.js/core/src/denobuffer.ts +248 -0
- package/externals/nats.js/core/src/encoders.ts +53 -0
- package/externals/nats.js/core/src/errors.ts +300 -0
- package/externals/nats.js/core/src/headers.ts +315 -0
- package/externals/nats.js/core/src/heartbeats.ts +114 -0
- package/externals/nats.js/core/src/idleheartbeat_monitor.ts +140 -0
- package/externals/nats.js/core/src/internal_mod.ts +167 -0
- package/externals/nats.js/core/src/ipparser.ts +215 -0
- package/externals/nats.js/core/src/mod.ts +113 -0
- package/externals/nats.js/core/src/msg.ts +120 -0
- package/externals/nats.js/core/src/muxsubscription.ts +111 -0
- package/externals/nats.js/core/src/nats.ts +650 -0
- package/externals/nats.js/core/src/nkeys.ts +1 -0
- package/externals/nats.js/core/src/nuid.ts +16 -0
- package/externals/nats.js/core/src/options.ts +202 -0
- package/externals/nats.js/core/src/parser.ts +756 -0
- package/externals/nats.js/core/src/protocol.ts +1304 -0
- package/externals/nats.js/core/src/queued_iterator.ts +171 -0
- package/externals/nats.js/core/src/request.ts +177 -0
- package/externals/nats.js/core/src/semver.ts +165 -0
- package/externals/nats.js/core/src/servers.ts +424 -0
- package/externals/nats.js/core/src/transport.ts +117 -0
- package/externals/nats.js/core/src/types.ts +17 -0
- package/externals/nats.js/core/src/util.ts +367 -0
- package/externals/nats.js/core/src/version.ts +2 -0
- package/externals/nats.js/core/src/ws_transport.ts +391 -0
- package/package.json +2 -1
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020-2022 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 type { Deferred } from "./util.ts";
|
|
16
|
+
import { deferred } from "./util.ts";
|
|
17
|
+
import type { QueuedIterator } from "./core.ts";
|
|
18
|
+
import type { CallbackFn, Dispatcher } from "./core.ts";
|
|
19
|
+
import { InvalidOperationError } from "./errors.ts";
|
|
20
|
+
|
|
21
|
+
export class QueuedIteratorImpl<T> implements QueuedIterator<T>, Dispatcher<T> {
|
|
22
|
+
inflight: number;
|
|
23
|
+
processed: number;
|
|
24
|
+
// this is updated by the protocol
|
|
25
|
+
received: number;
|
|
26
|
+
noIterator: boolean;
|
|
27
|
+
iterClosed: Deferred<void | Error>;
|
|
28
|
+
done: boolean;
|
|
29
|
+
signal: Deferred<void>;
|
|
30
|
+
yields: (T | CallbackFn)[];
|
|
31
|
+
filtered: number;
|
|
32
|
+
pendingFiltered: number;
|
|
33
|
+
ctx?: unknown;
|
|
34
|
+
_data?: unknown; //data is for use by extenders in any way they like
|
|
35
|
+
err?: Error;
|
|
36
|
+
time: number;
|
|
37
|
+
profile: boolean;
|
|
38
|
+
yielding: boolean;
|
|
39
|
+
didBreak: boolean;
|
|
40
|
+
|
|
41
|
+
constructor() {
|
|
42
|
+
this.inflight = 0;
|
|
43
|
+
this.filtered = 0;
|
|
44
|
+
this.pendingFiltered = 0;
|
|
45
|
+
this.processed = 0;
|
|
46
|
+
this.received = 0;
|
|
47
|
+
this.noIterator = false;
|
|
48
|
+
this.done = false;
|
|
49
|
+
this.signal = deferred<void>();
|
|
50
|
+
this.yields = [];
|
|
51
|
+
this.iterClosed = deferred<void | Error>();
|
|
52
|
+
this.time = 0;
|
|
53
|
+
this.yielding = false;
|
|
54
|
+
this.didBreak = false;
|
|
55
|
+
this.profile = false;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
[Symbol.asyncIterator](): AsyncIterator<T> {
|
|
59
|
+
return this.iterate();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
push(v: T | CallbackFn): void {
|
|
63
|
+
if (this.done) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
// if they `break` from a `for await`, any signaling that is pushed via
|
|
67
|
+
// a function is not handled this can prevent closed promises from
|
|
68
|
+
// resolving downstream.
|
|
69
|
+
if (this.didBreak) {
|
|
70
|
+
if (typeof v === "function") {
|
|
71
|
+
const cb = v as CallbackFn;
|
|
72
|
+
try {
|
|
73
|
+
cb();
|
|
74
|
+
} catch (_) {
|
|
75
|
+
// ignored
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (typeof v === "function") {
|
|
81
|
+
this.pendingFiltered++;
|
|
82
|
+
}
|
|
83
|
+
this.yields.push(v);
|
|
84
|
+
this.signal.resolve();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async *iterate(): AsyncIterableIterator<T> {
|
|
88
|
+
if (this.noIterator) {
|
|
89
|
+
throw new InvalidOperationError(
|
|
90
|
+
"iterator cannot be used when a callback is registered",
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
if (this.yielding) {
|
|
94
|
+
throw new InvalidOperationError("iterator is already yielding");
|
|
95
|
+
}
|
|
96
|
+
this.yielding = true;
|
|
97
|
+
try {
|
|
98
|
+
while (true) {
|
|
99
|
+
if (this.yields.length === 0) {
|
|
100
|
+
await this.signal;
|
|
101
|
+
}
|
|
102
|
+
if (this.err) {
|
|
103
|
+
throw this.err;
|
|
104
|
+
}
|
|
105
|
+
const yields = this.yields;
|
|
106
|
+
this.inflight = yields.length;
|
|
107
|
+
this.yields = [];
|
|
108
|
+
for (let i = 0; i < yields.length; i++) {
|
|
109
|
+
if (typeof yields[i] === "function") {
|
|
110
|
+
this.pendingFiltered--;
|
|
111
|
+
const fn = yields[i] as CallbackFn;
|
|
112
|
+
try {
|
|
113
|
+
fn();
|
|
114
|
+
} catch (err) {
|
|
115
|
+
// failed on the invocation - fail the iterator
|
|
116
|
+
// so they know to fix the callback
|
|
117
|
+
throw err;
|
|
118
|
+
}
|
|
119
|
+
// fn could have also set an error
|
|
120
|
+
if (this.err) {
|
|
121
|
+
throw this.err;
|
|
122
|
+
}
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
this.processed++;
|
|
127
|
+
this.inflight--;
|
|
128
|
+
const start = this.profile ? Date.now() : 0;
|
|
129
|
+
yield yields[i] as T;
|
|
130
|
+
this.time = this.profile ? Date.now() - start : 0;
|
|
131
|
+
}
|
|
132
|
+
// yielding could have paused and microtask
|
|
133
|
+
// could have added messages. Prevent allocations
|
|
134
|
+
// if possible
|
|
135
|
+
if (this.done) {
|
|
136
|
+
break;
|
|
137
|
+
} else if (this.yields.length === 0) {
|
|
138
|
+
yields.length = 0;
|
|
139
|
+
this.yields = yields;
|
|
140
|
+
this.signal = deferred();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
} finally {
|
|
144
|
+
// the iterator used break/return
|
|
145
|
+
this.didBreak = true;
|
|
146
|
+
this.stop();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
stop(err?: Error): void {
|
|
151
|
+
if (this.done) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
this.err = err;
|
|
155
|
+
this.done = true;
|
|
156
|
+
this.signal.resolve();
|
|
157
|
+
this.iterClosed.resolve(err);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
getProcessed(): number {
|
|
161
|
+
return this.noIterator ? this.received : this.processed;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
getPending(): number {
|
|
165
|
+
return this.yields.length + this.inflight - this.pendingFiltered;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
getReceived(): number {
|
|
169
|
+
return this.received - this.filtered;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020-2023 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 type { Deferred, Timeout } from "./util.ts";
|
|
16
|
+
import { deferred, randomToken, timeout } from "./util.ts";
|
|
17
|
+
import type { MuxSubscription } from "./muxsubscription.ts";
|
|
18
|
+
import type {
|
|
19
|
+
Msg,
|
|
20
|
+
Request,
|
|
21
|
+
RequestManyOptions,
|
|
22
|
+
RequestOptions,
|
|
23
|
+
} from "./core.ts";
|
|
24
|
+
import { errors, RequestError, TimeoutError } from "./errors.ts";
|
|
25
|
+
|
|
26
|
+
export class BaseRequest {
|
|
27
|
+
token: string;
|
|
28
|
+
received: number;
|
|
29
|
+
ctx?: RequestError;
|
|
30
|
+
requestSubject: string;
|
|
31
|
+
mux: MuxSubscription;
|
|
32
|
+
|
|
33
|
+
constructor(
|
|
34
|
+
mux: MuxSubscription,
|
|
35
|
+
requestSubject: string,
|
|
36
|
+
asyncTraces = true,
|
|
37
|
+
) {
|
|
38
|
+
this.mux = mux;
|
|
39
|
+
this.requestSubject = requestSubject;
|
|
40
|
+
this.received = 0;
|
|
41
|
+
this.token = randomToken();
|
|
42
|
+
if (asyncTraces) {
|
|
43
|
+
this.ctx = new RequestError();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface RequestManyOptionsInternal extends RequestManyOptions {
|
|
49
|
+
callback: (err: Error | null, msg: Msg | null) => void;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Request expects multiple message response
|
|
54
|
+
* the request ends when the timer expires,
|
|
55
|
+
* an error arrives or an expected count of messages
|
|
56
|
+
* arrives, end is signaled by a null message
|
|
57
|
+
*/
|
|
58
|
+
export class RequestMany extends BaseRequest implements Request {
|
|
59
|
+
callback!: (err: Error | null, msg: Msg | null) => void;
|
|
60
|
+
done: Deferred<void>;
|
|
61
|
+
timer: number;
|
|
62
|
+
max: number;
|
|
63
|
+
opts: Partial<RequestManyOptionsInternal>;
|
|
64
|
+
constructor(
|
|
65
|
+
mux: MuxSubscription,
|
|
66
|
+
requestSubject: string,
|
|
67
|
+
opts: Partial<RequestManyOptions> = { maxWait: 1000 },
|
|
68
|
+
) {
|
|
69
|
+
super(mux, requestSubject);
|
|
70
|
+
this.opts = opts;
|
|
71
|
+
if (typeof this.opts.callback !== "function") {
|
|
72
|
+
throw new TypeError("callback must be a function");
|
|
73
|
+
}
|
|
74
|
+
this.callback = this.opts.callback;
|
|
75
|
+
|
|
76
|
+
this.max = typeof opts.maxMessages === "number" && opts.maxMessages > 0
|
|
77
|
+
? opts.maxMessages
|
|
78
|
+
: -1;
|
|
79
|
+
this.done = deferred();
|
|
80
|
+
this.done.then(() => {
|
|
81
|
+
this.callback(null, null);
|
|
82
|
+
});
|
|
83
|
+
// @ts-ignore: node is not a number
|
|
84
|
+
this.timer = setTimeout(() => {
|
|
85
|
+
this.cancel();
|
|
86
|
+
}, opts.maxWait);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
cancel(err?: Error): void {
|
|
90
|
+
if (err) {
|
|
91
|
+
this.callback(err, null);
|
|
92
|
+
}
|
|
93
|
+
clearTimeout(this.timer);
|
|
94
|
+
this.mux.cancel(this);
|
|
95
|
+
this.done.resolve();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
resolver(err: Error | null, msg: Msg): void {
|
|
99
|
+
if (err) {
|
|
100
|
+
if (this.ctx) {
|
|
101
|
+
err.stack += `\n\n${this.ctx.stack}`;
|
|
102
|
+
}
|
|
103
|
+
this.cancel(err as Error);
|
|
104
|
+
} else {
|
|
105
|
+
this.callback(null, msg);
|
|
106
|
+
if (this.opts.strategy === "count") {
|
|
107
|
+
this.max--;
|
|
108
|
+
if (this.max === 0) {
|
|
109
|
+
this.cancel();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (this.opts.strategy === "stall") {
|
|
114
|
+
clearTimeout(this.timer);
|
|
115
|
+
// @ts-ignore: node is not a number
|
|
116
|
+
this.timer = setTimeout(() => {
|
|
117
|
+
this.cancel();
|
|
118
|
+
}, this.opts.stall || 300);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (this.opts.strategy === "sentinel") {
|
|
122
|
+
if (msg && msg.data.length === 0) {
|
|
123
|
+
this.cancel();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export class RequestOne extends BaseRequest implements Request {
|
|
131
|
+
deferred: Deferred<Msg>;
|
|
132
|
+
timer: Timeout<Msg>;
|
|
133
|
+
|
|
134
|
+
constructor(
|
|
135
|
+
mux: MuxSubscription,
|
|
136
|
+
requestSubject: string,
|
|
137
|
+
opts: RequestOptions = { timeout: 1000 },
|
|
138
|
+
asyncTraces = true,
|
|
139
|
+
) {
|
|
140
|
+
super(mux, requestSubject, asyncTraces);
|
|
141
|
+
// extend(this, opts);
|
|
142
|
+
this.deferred = deferred();
|
|
143
|
+
this.timer = timeout<Msg>(opts.timeout, asyncTraces);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
resolver(err: Error | null, msg: Msg): void {
|
|
147
|
+
if (this.timer) {
|
|
148
|
+
this.timer.cancel();
|
|
149
|
+
}
|
|
150
|
+
if (err) {
|
|
151
|
+
// we have proper stack on timeout
|
|
152
|
+
if (!(err instanceof TimeoutError)) {
|
|
153
|
+
if (this.ctx) {
|
|
154
|
+
this.ctx.message = err.message;
|
|
155
|
+
this.ctx.cause = err;
|
|
156
|
+
err = this.ctx;
|
|
157
|
+
} else {
|
|
158
|
+
err = new errors.RequestError(err.message, { cause: err });
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
this.deferred.reject(err);
|
|
162
|
+
} else {
|
|
163
|
+
this.deferred.resolve(msg);
|
|
164
|
+
}
|
|
165
|
+
this.cancel();
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
cancel(err?: Error): void {
|
|
169
|
+
if (this.timer) {
|
|
170
|
+
this.timer.cancel();
|
|
171
|
+
}
|
|
172
|
+
this.mux.cancel(this);
|
|
173
|
+
this.deferred.reject(
|
|
174
|
+
err ? err : new RequestError("cancelled"),
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2022-2023 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
|
+
|
|
16
|
+
export type SemVer = { major: number; minor: number; micro: number };
|
|
17
|
+
export function parseSemVer(
|
|
18
|
+
s = "",
|
|
19
|
+
): SemVer {
|
|
20
|
+
const m = s.match(/(\d+).(\d+).(\d+)/);
|
|
21
|
+
if (m) {
|
|
22
|
+
return {
|
|
23
|
+
major: parseInt(m[1]),
|
|
24
|
+
minor: parseInt(m[2]),
|
|
25
|
+
micro: parseInt(m[3]),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
throw new Error(`'${s}' is not a semver value`);
|
|
29
|
+
}
|
|
30
|
+
export function compare(a: SemVer, b: SemVer): number {
|
|
31
|
+
if (a.major < b.major) return -1;
|
|
32
|
+
if (a.major > b.major) return 1;
|
|
33
|
+
if (a.minor < b.minor) return -1;
|
|
34
|
+
if (a.minor > b.minor) return 1;
|
|
35
|
+
if (a.micro < b.micro) return -1;
|
|
36
|
+
if (a.micro > b.micro) return 1;
|
|
37
|
+
return 0;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const Feature = {
|
|
41
|
+
JS_KV: "js_kv",
|
|
42
|
+
JS_OBJECTSTORE: "js_objectstore",
|
|
43
|
+
JS_PULL_MAX_BYTES: "js_pull_max_bytes",
|
|
44
|
+
JS_NEW_CONSUMER_CREATE_API: "js_new_consumer_create",
|
|
45
|
+
JS_ALLOW_DIRECT: "js_allow_direct",
|
|
46
|
+
JS_MULTIPLE_CONSUMER_FILTER: "js_multiple_consumer_filter",
|
|
47
|
+
JS_SIMPLIFICATION: "js_simplification",
|
|
48
|
+
JS_STREAM_CONSUMER_METADATA: "js_stream_consumer_metadata",
|
|
49
|
+
JS_CONSUMER_FILTER_SUBJECTS: "js_consumer_filter_subjects",
|
|
50
|
+
JS_STREAM_FIRST_SEQ: "js_stream_first_seq",
|
|
51
|
+
JS_STREAM_SUBJECT_TRANSFORM: "js_stream_subject_transform",
|
|
52
|
+
JS_STREAM_SOURCE_SUBJECT_TRANSFORM: "js_stream_source_subject_transform",
|
|
53
|
+
JS_STREAM_COMPRESSION: "js_stream_compression",
|
|
54
|
+
JS_DEFAULT_CONSUMER_LIMITS: "js_default_consumer_limits",
|
|
55
|
+
JS_BATCH_DIRECT_GET: "js_batch_direct_get",
|
|
56
|
+
JS_PRIORITY_GROUPS: "js_priority_groups",
|
|
57
|
+
JS_CONSUMER_RESET: "js_consumer_reset",
|
|
58
|
+
} as const;
|
|
59
|
+
|
|
60
|
+
export type Feature = typeof Feature[keyof typeof Feature];
|
|
61
|
+
|
|
62
|
+
type FeatureVersion = {
|
|
63
|
+
ok: boolean;
|
|
64
|
+
min: string;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export class Features {
|
|
68
|
+
server!: SemVer;
|
|
69
|
+
features: Map<string, FeatureVersion>;
|
|
70
|
+
disabled: string[];
|
|
71
|
+
constructor(v: SemVer) {
|
|
72
|
+
this.features = new Map<Feature, FeatureVersion>();
|
|
73
|
+
this.disabled = [];
|
|
74
|
+
this.update(v);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Removes all disabled entries
|
|
79
|
+
*/
|
|
80
|
+
resetDisabled(): void {
|
|
81
|
+
this.disabled.length = 0;
|
|
82
|
+
this.update(this.server);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Disables a particular feature.
|
|
87
|
+
* @param f
|
|
88
|
+
*/
|
|
89
|
+
disable(f: Feature): void {
|
|
90
|
+
this.disabled.push(f);
|
|
91
|
+
this.update(this.server);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
isDisabled(f: Feature): boolean {
|
|
95
|
+
return this.disabled.indexOf(f) !== -1;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
update(v: SemVer | string): void {
|
|
99
|
+
if (typeof v === "string") {
|
|
100
|
+
v = parseSemVer(v);
|
|
101
|
+
}
|
|
102
|
+
this.server = v;
|
|
103
|
+
this.set(Feature.JS_KV, "2.6.2");
|
|
104
|
+
this.set(Feature.JS_OBJECTSTORE, "2.6.3");
|
|
105
|
+
this.set(Feature.JS_PULL_MAX_BYTES, "2.8.3");
|
|
106
|
+
this.set(Feature.JS_NEW_CONSUMER_CREATE_API, "2.9.0");
|
|
107
|
+
this.set(Feature.JS_ALLOW_DIRECT, "2.9.0");
|
|
108
|
+
this.set(Feature.JS_MULTIPLE_CONSUMER_FILTER, "2.10.0");
|
|
109
|
+
this.set(Feature.JS_SIMPLIFICATION, "2.9.4");
|
|
110
|
+
this.set(Feature.JS_STREAM_CONSUMER_METADATA, "2.10.0");
|
|
111
|
+
this.set(Feature.JS_CONSUMER_FILTER_SUBJECTS, "2.10.0");
|
|
112
|
+
this.set(Feature.JS_STREAM_FIRST_SEQ, "2.10.0");
|
|
113
|
+
this.set(Feature.JS_STREAM_SUBJECT_TRANSFORM, "2.10.0");
|
|
114
|
+
this.set(Feature.JS_STREAM_SOURCE_SUBJECT_TRANSFORM, "2.10.0");
|
|
115
|
+
this.set(Feature.JS_STREAM_COMPRESSION, "2.10.0");
|
|
116
|
+
this.set(Feature.JS_DEFAULT_CONSUMER_LIMITS, "2.10.0");
|
|
117
|
+
this.set(Feature.JS_BATCH_DIRECT_GET, "2.11.0");
|
|
118
|
+
this.set(Feature.JS_PRIORITY_GROUPS, "2.11.0");
|
|
119
|
+
this.set(Feature.JS_CONSUMER_RESET, "2.14.0");
|
|
120
|
+
|
|
121
|
+
this.disabled.forEach((f) => {
|
|
122
|
+
this.features.delete(f);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Register a feature that requires a particular server version.
|
|
128
|
+
* @param f
|
|
129
|
+
* @param requires
|
|
130
|
+
*/
|
|
131
|
+
set(f: Feature, requires: string): void {
|
|
132
|
+
this.features.set(f, {
|
|
133
|
+
min: requires,
|
|
134
|
+
ok: compare(this.server, parseSemVer(requires)) >= 0,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Returns whether the feature is available and the min server
|
|
140
|
+
* version that supports it.
|
|
141
|
+
* @param f
|
|
142
|
+
*/
|
|
143
|
+
get(f: Feature): FeatureVersion {
|
|
144
|
+
return this.features.get(f) || { min: "unknown", ok: false };
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Returns true if the feature is supported
|
|
149
|
+
* @param f
|
|
150
|
+
*/
|
|
151
|
+
supports(f: Feature): boolean {
|
|
152
|
+
return this.get(f)?.ok || false;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Returns true if the server is at least the specified version
|
|
157
|
+
* @param v
|
|
158
|
+
*/
|
|
159
|
+
require(v: SemVer | string): boolean {
|
|
160
|
+
if (typeof v === "string") {
|
|
161
|
+
v = parseSemVer(v);
|
|
162
|
+
}
|
|
163
|
+
return compare(this.server, v) >= 0;
|
|
164
|
+
}
|
|
165
|
+
}
|