@spine-event-engine/delivery-server 2.0.0-snapshot.32 → 2.0.0-snapshot.33
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/README.md +63 -26
- package/REFERENCE.md +112 -53
- package/dist/admin/admin-service.d.ts +0 -7
- package/dist/admin/admin-service.d.ts.map +1 -1
- package/dist/admin/admin-service.js +231 -82
- package/dist/admin/admin-service.js.map +1 -1
- package/dist/core/in-memory-delivery-core.d.ts +19 -18
- package/dist/core/in-memory-delivery-core.d.ts.map +1 -1
- package/dist/core/in-memory-delivery-core.js +14 -14
- package/dist/core/in-memory-delivery-core.js.map +1 -1
- package/dist/core/in-memory-delivery-state.d.ts +61 -12
- package/dist/core/in-memory-delivery-state.d.ts.map +1 -1
- package/dist/core/in-memory-delivery-state.js +186 -100
- package/dist/core/in-memory-delivery-state.js.map +1 -1
- package/dist/core/inbox-service.d.ts +66 -3
- package/dist/core/inbox-service.d.ts.map +1 -1
- package/dist/core/inbox-service.js +84 -143
- package/dist/core/inbox-service.js.map +1 -1
- package/dist/core/mutation-admission.d.ts +3 -1
- package/dist/core/mutation-admission.d.ts.map +1 -1
- package/dist/core/mutation-admission.js +14 -3
- package/dist/core/mutation-admission.js.map +1 -1
- package/dist/core/shard-observing-service.d.ts +37 -0
- package/dist/core/shard-observing-service.d.ts.map +1 -0
- package/dist/core/shard-observing-service.js +267 -0
- package/dist/core/shard-observing-service.js.map +1 -0
- package/dist/core/shard-service.d.ts +29 -11
- package/dist/core/shard-service.d.ts.map +1 -1
- package/dist/core/shard-service.js +239 -154
- package/dist/core/shard-service.js.map +1 -1
- package/dist/core/wire-values.d.ts +10 -0
- package/dist/core/wire-values.d.ts.map +1 -1
- package/dist/core/wire-values.js +10 -0
- package/dist/core/wire-values.js.map +1 -1
- package/dist/health/health-service.d.ts.map +1 -1
- package/dist/health/health-service.js +1 -0
- package/dist/health/health-service.js.map +1 -1
- package/dist/server/assembly.d.ts +35 -2
- package/dist/server/assembly.d.ts.map +1 -1
- package/dist/server/assembly.js +62 -20
- package/dist/server/assembly.js.map +1 -1
- package/dist/server/config.d.ts +10 -3
- package/dist/server/config.d.ts.map +1 -1
- package/dist/server/config.js +22 -8
- package/dist/server/config.js.map +1 -1
- package/dist/server/delivery-child-pool.d.ts +83 -0
- package/dist/server/delivery-child-pool.d.ts.map +1 -0
- package/dist/server/delivery-child-pool.js +344 -0
- package/dist/server/delivery-child-pool.js.map +1 -0
- package/dist/server/delivery-parent-proxy.d.ts +45 -0
- package/dist/server/delivery-parent-proxy.d.ts.map +1 -0
- package/dist/server/delivery-parent-proxy.js +309 -0
- package/dist/server/delivery-parent-proxy.js.map +1 -0
- package/dist/server/delivery-server.d.ts +20 -20
- package/dist/server/delivery-server.d.ts.map +1 -1
- package/dist/server/delivery-server.js +59 -16
- package/dist/server/delivery-server.js.map +1 -1
- package/dist/server/delivery-stream-fan-in.d.ts +37 -0
- package/dist/server/delivery-stream-fan-in.d.ts.map +1 -0
- package/dist/server/delivery-stream-fan-in.js +334 -0
- package/dist/server/delivery-stream-fan-in.js.map +1 -0
- package/dist/server/private-delivery-child-process.d.ts +2 -0
- package/dist/server/private-delivery-child-process.d.ts.map +1 -0
- package/dist/server/private-delivery-child-process.js +71 -0
- package/dist/server/private-delivery-child-process.js.map +1 -0
- package/dist/server/private-delivery-child.d.ts +46 -0
- package/dist/server/private-delivery-child.d.ts.map +1 -0
- package/dist/server/private-delivery-child.js +145 -0
- package/dist/server/private-delivery-child.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -3
- package/dist/core/limits.d.ts +0 -64
- package/dist/core/limits.d.ts.map +0 -1
- package/dist/core/limits.js +0 -73
- package/dist/core/limits.js.map +0 -1
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026, CodeMatters. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
|
5
|
+
* in compliance with the License. You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
|
10
|
+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
|
11
|
+
* or implied. See the License for the specific language governing permissions and limitations under
|
|
12
|
+
* the License.
|
|
13
|
+
*/
|
|
14
|
+
import { create } from "@bufbuild/protobuf";
|
|
15
|
+
import { ShardObservingService, ShardedWorkAvailableSchema, } from "@spine-event-engine/proto/delivery-server";
|
|
16
|
+
import { DeliveryShards } from "./wire-values.js";
|
|
17
|
+
/**
|
|
18
|
+
* Creates a publisher around the shared in-memory delivery state.
|
|
19
|
+
*/
|
|
20
|
+
export const ShardObserving = Object.freeze({
|
|
21
|
+
/**
|
|
22
|
+
* Creates the observing service.
|
|
23
|
+
*
|
|
24
|
+
* @param state Supplies the shared Inbox and session state.
|
|
25
|
+
* @param reminderMs Sets the interval between unclaimed-work reminders.
|
|
26
|
+
* @returns The service and its mutation and lifecycle hooks.
|
|
27
|
+
*/
|
|
28
|
+
create(state, reminderMs) {
|
|
29
|
+
if (!Number.isSafeInteger(reminderMs) || reminderMs <= 0)
|
|
30
|
+
throw new RangeError("Work reminder interval must be a positive number of whole milliseconds.");
|
|
31
|
+
return new WorkPublisher(state, reminderMs);
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
/**
|
|
35
|
+
* Coordinates subscriptions and reminder timers for one delivery state.
|
|
36
|
+
*/
|
|
37
|
+
class WorkPublisher {
|
|
38
|
+
state;
|
|
39
|
+
reminderMs;
|
|
40
|
+
#subscribers = new Map();
|
|
41
|
+
#reminders = new Map();
|
|
42
|
+
#closed = false;
|
|
43
|
+
/**
|
|
44
|
+
* Creates the publisher and its Connect service.
|
|
45
|
+
*
|
|
46
|
+
* @param state Supplies the shared delivery state.
|
|
47
|
+
* @param reminderMs Sets the repeat interval in milliseconds.
|
|
48
|
+
*/
|
|
49
|
+
constructor(state, reminderMs) {
|
|
50
|
+
this.state = state;
|
|
51
|
+
this.reminderMs = reminderMs;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Serves one independent observation stream.
|
|
55
|
+
*/
|
|
56
|
+
service = {
|
|
57
|
+
observeAll: async function* (_request, context) {
|
|
58
|
+
if (this.#closed || context.signal.aborted)
|
|
59
|
+
return;
|
|
60
|
+
const subscriber = new WorkSubscriber();
|
|
61
|
+
const detach = () => {
|
|
62
|
+
context.signal.removeEventListener("abort", detach);
|
|
63
|
+
this.#subscribers.delete(subscriber);
|
|
64
|
+
subscriber.close();
|
|
65
|
+
if (this.#subscribers.size === 0) {
|
|
66
|
+
for (const timer of this.#reminders.values())
|
|
67
|
+
timer.cancel();
|
|
68
|
+
this.#reminders.clear();
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
context.signal.addEventListener("abort", detach, { once: true });
|
|
72
|
+
this.#subscribers.set(subscriber, detach);
|
|
73
|
+
try {
|
|
74
|
+
for (const shard of this.state.pendingShards()) {
|
|
75
|
+
if (this.#available(shard)) {
|
|
76
|
+
subscriber.push(this.#notice(shard));
|
|
77
|
+
if (!this.#reminders.has(DeliveryShards.key(shard)))
|
|
78
|
+
this.#schedule(shard);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
for await (const notice of subscriber)
|
|
82
|
+
if (notice.shard !== undefined && this.#available(notice.shard))
|
|
83
|
+
yield notice;
|
|
84
|
+
}
|
|
85
|
+
finally {
|
|
86
|
+
detach();
|
|
87
|
+
}
|
|
88
|
+
}.bind(this),
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Checks availability after a committed state transition.
|
|
92
|
+
*
|
|
93
|
+
* @param shard Identifies the changed shard.
|
|
94
|
+
*/
|
|
95
|
+
changed(shard) {
|
|
96
|
+
if (this.#closed)
|
|
97
|
+
return;
|
|
98
|
+
const key = DeliveryShards.key(shard);
|
|
99
|
+
if (!this.#available(shard)) {
|
|
100
|
+
this.#reminders.get(key)?.cancel();
|
|
101
|
+
this.#reminders.delete(key);
|
|
102
|
+
for (const subscriber of this.#subscribers.keys())
|
|
103
|
+
subscriber.invalidate(key);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
this.#publish(shard);
|
|
107
|
+
if (this.#subscribers.size > 0 && !this.#reminders.has(key))
|
|
108
|
+
this.#schedule(shard);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Clears streams and cancels all reminders.
|
|
112
|
+
*/
|
|
113
|
+
close() {
|
|
114
|
+
if (this.#closed)
|
|
115
|
+
return;
|
|
116
|
+
this.#closed = true;
|
|
117
|
+
for (const timer of this.#reminders.values())
|
|
118
|
+
timer.cancel();
|
|
119
|
+
this.#reminders.clear();
|
|
120
|
+
for (const detach of this.#subscribers.values())
|
|
121
|
+
detach();
|
|
122
|
+
this.#subscribers.clear();
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Checks whether pending work can be picked up.
|
|
126
|
+
*
|
|
127
|
+
* @param shard Identifies the shard.
|
|
128
|
+
* @returns Whether the shard is free with pending work.
|
|
129
|
+
*/
|
|
130
|
+
#available(shard) {
|
|
131
|
+
return this.state.hasPending(shard) && this.state.session(shard) === undefined;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Creates one detached work notice.
|
|
135
|
+
*
|
|
136
|
+
* @param shard Identifies the shard.
|
|
137
|
+
* @returns The wire notice.
|
|
138
|
+
*/
|
|
139
|
+
#notice(shard) {
|
|
140
|
+
return create(ShardedWorkAvailableSchema, { shard: DeliveryShards.copy(shard) });
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Sends a notice to every current subscriber.
|
|
144
|
+
*
|
|
145
|
+
* @param shard Identifies the shard.
|
|
146
|
+
*/
|
|
147
|
+
#publish(shard) {
|
|
148
|
+
const notice = this.#notice(shard);
|
|
149
|
+
for (const subscriber of this.#subscribers.keys())
|
|
150
|
+
subscriber.push(notice);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Sets the next reminder for an available shard.
|
|
154
|
+
*
|
|
155
|
+
* @param shard Identifies the shard.
|
|
156
|
+
*/
|
|
157
|
+
#schedule(shard) {
|
|
158
|
+
const key = DeliveryShards.key(shard);
|
|
159
|
+
this.#reminders.set(key, new LongReminder(this.reminderMs, () => {
|
|
160
|
+
this.#reminders.delete(key);
|
|
161
|
+
if (this.#closed || this.#subscribers.size === 0 || !this.#available(shard))
|
|
162
|
+
return;
|
|
163
|
+
this.#publish(shard);
|
|
164
|
+
this.#schedule(shard);
|
|
165
|
+
}));
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Waits through multiple Node timer slots for a long configured interval.
|
|
170
|
+
*/
|
|
171
|
+
class LongReminder {
|
|
172
|
+
onFire;
|
|
173
|
+
#remaining;
|
|
174
|
+
#timer;
|
|
175
|
+
/**
|
|
176
|
+
* Starts the reminder countdown.
|
|
177
|
+
*
|
|
178
|
+
* @param milliseconds Sets the complete delay.
|
|
179
|
+
* @param onFire Runs when the complete delay elapses.
|
|
180
|
+
*/
|
|
181
|
+
constructor(milliseconds, onFire) {
|
|
182
|
+
this.onFire = onFire;
|
|
183
|
+
this.#remaining = milliseconds;
|
|
184
|
+
this.#arm();
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Clears the current timer slot.
|
|
188
|
+
*/
|
|
189
|
+
cancel() {
|
|
190
|
+
if (this.#timer !== undefined)
|
|
191
|
+
clearTimeout(this.#timer);
|
|
192
|
+
this.#timer = undefined;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Sets the next timer slot without truncating the configured interval.
|
|
196
|
+
*/
|
|
197
|
+
#arm() {
|
|
198
|
+
const slot = Math.min(this.#remaining, 2_147_483_647);
|
|
199
|
+
this.#remaining -= slot;
|
|
200
|
+
this.#timer = setTimeout(() => {
|
|
201
|
+
if (this.#remaining > 0)
|
|
202
|
+
this.#arm();
|
|
203
|
+
else
|
|
204
|
+
this.onFire();
|
|
205
|
+
}, slot);
|
|
206
|
+
this.#timer.unref();
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Buffers notices for one stream until its reader accepts them.
|
|
211
|
+
*/
|
|
212
|
+
class WorkSubscriber {
|
|
213
|
+
#pending = new Map();
|
|
214
|
+
#wake;
|
|
215
|
+
#closed = false;
|
|
216
|
+
/**
|
|
217
|
+
* Adds a shard notice, coalescing unread notices for the same shard.
|
|
218
|
+
*
|
|
219
|
+
* @param notice Supplies the work notice.
|
|
220
|
+
*/
|
|
221
|
+
push(notice) {
|
|
222
|
+
if (this.#closed || notice.shard === undefined)
|
|
223
|
+
return;
|
|
224
|
+
this.#pending.set(DeliveryShards.key(notice.shard), notice);
|
|
225
|
+
this.#wake?.();
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Removes a queued shard after it becomes unavailable.
|
|
229
|
+
*
|
|
230
|
+
* @param key Identifies the unavailable shard.
|
|
231
|
+
*/
|
|
232
|
+
invalidate(key) {
|
|
233
|
+
this.#pending.delete(key);
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Clears the stream and wakes its reader.
|
|
237
|
+
*/
|
|
238
|
+
close() {
|
|
239
|
+
this.#closed = true;
|
|
240
|
+
this.#pending.clear();
|
|
241
|
+
this.#wake?.();
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Reads notices until cancellation or service closure.
|
|
245
|
+
*
|
|
246
|
+
* @returns The pending notices.
|
|
247
|
+
*/
|
|
248
|
+
async *[Symbol.asyncIterator]() {
|
|
249
|
+
for (;;) {
|
|
250
|
+
const next = this.#pending.entries().next().value;
|
|
251
|
+
if (next !== undefined) {
|
|
252
|
+
this.#pending.delete(next[0]);
|
|
253
|
+
yield next[1];
|
|
254
|
+
}
|
|
255
|
+
else if (this.#closed) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
await new Promise((resolve) => {
|
|
260
|
+
this.#wake = resolve;
|
|
261
|
+
});
|
|
262
|
+
this.#wake = undefined;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
//# sourceMappingURL=shard-observing-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shard-observing-service.js","sourceRoot":"","sources":["../../src/core/shard-observing-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EACL,qBAAqB,EACrB,0BAA0B,GAE3B,MAAM,2CAA2C,CAAC;AAInD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAwBlD;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAStB,MAAM,CAAC,MAAM,CAAC;IACjB;;;;;;OAMG;IACH,MAAM,CAAC,KAA4B,EAAE,UAAkB;QACrD,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,IAAI,UAAU,IAAI,CAAC;YACtD,MAAM,IAAI,UAAU,CAClB,yEAAyE,CAC1E,CAAC;QACJ,OAAO,IAAI,aAAa,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IAC9C,CAAC;CACF,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,aAAa;IAcE;IACA;IAdV,YAAY,GAAG,IAAI,GAAG,EAA8B,CAAC;IAErD,UAAU,GAAG,IAAI,GAAG,EAAwB,CAAC;IAEtD,OAAO,GAAG,KAAK,CAAC;IAEhB;;;;;OAKG;IACH,YACmB,KAA4B,EAC5B,UAAkB;QADlB,UAAK,GAAL,KAAK,CAAuB;QAC5B,eAAU,GAAV,UAAU,CAAQ;IAClC,CAAC;IAEJ;;OAEG;IACM,OAAO,GAA8C;QAC5D,UAA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GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC;QAC5D,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC;IACjB,CAAC;IAED;;;;OAIG;IACH,UAAU,CAAC,GAAW;QACpB,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACtB,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC;IACjB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC;QAC3B,SAAS,CAAC;YACR,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC;YAClD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;gBACvB,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC9B,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC;YAChB,CAAC;iBAAM,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;gBACxB,OAAO;YACT,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;oBAClC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC;gBACvB,CAAC,CAAC,CAAC;gBACH,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;YACzB,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,22 +1,40 @@
|
|
|
1
|
+
import { type Timestamp } from "@bufbuild/protobuf/wkt";
|
|
1
2
|
import { type ServiceImpl } from "@connectrpc/connect";
|
|
2
3
|
import { ShardService } from "@spine-event-engine/proto/delivery-server";
|
|
3
|
-
import type { ShardIndex } from "@spine-event-engine/proto/delivery";
|
|
4
|
+
import type { ShardIndex, WorkerId } from "@spine-event-engine/proto/delivery";
|
|
4
5
|
import { InMemoryDeliveryState } from "./in-memory-delivery-state.js";
|
|
5
6
|
import { MutationAdmission } from "./mutation-admission.js";
|
|
6
7
|
/**
|
|
7
|
-
*
|
|
8
|
+
* Serves the JVM-compatible shard pickup and release operations.
|
|
8
9
|
*/
|
|
9
|
-
export declare
|
|
10
|
+
export declare class ShardSessionRuntime {
|
|
11
|
+
#private;
|
|
10
12
|
/**
|
|
11
|
-
*
|
|
13
|
+
* The ShardService handlers.
|
|
14
|
+
*/
|
|
15
|
+
readonly service: ServiceImpl<typeof ShardService>;
|
|
16
|
+
/**
|
|
17
|
+
* Creates the shard service over one in-memory record store.
|
|
12
18
|
*
|
|
13
|
-
* @param state Stores the
|
|
14
|
-
* @param admission
|
|
15
|
-
* @param now Supplies the
|
|
16
|
-
* @param
|
|
17
|
-
* @param onTransition
|
|
18
|
-
|
|
19
|
+
* @param state Stores the current shard records.
|
|
20
|
+
* @param admission Serializes mutations of that store.
|
|
21
|
+
* @param now Supplies the full-precision wall clock.
|
|
22
|
+
* @param timeoutMs Makes another worker's session stale after this duration.
|
|
23
|
+
* @param onTransition Reports a pickup or release to observers.
|
|
24
|
+
*/
|
|
25
|
+
constructor(state: InMemoryDeliveryState, admission: MutationAdmission, now: () => Timestamp, timeoutMs: number, onTransition?: (shard: ShardIndex) => void);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Validates received shard and worker identities.
|
|
29
|
+
*/
|
|
30
|
+
export declare const DeliverySessionInputs: Readonly<{
|
|
31
|
+
/**
|
|
32
|
+
* Validates a complete shard identity.
|
|
33
|
+
*/
|
|
34
|
+
requireShard: (shard: ShardIndex | undefined) => ShardIndex;
|
|
35
|
+
/**
|
|
36
|
+
* Validates a complete worker identity.
|
|
19
37
|
*/
|
|
20
|
-
|
|
38
|
+
requireWorker: (worker: WorkerId | undefined) => WorkerId;
|
|
21
39
|
}>;
|
|
22
40
|
//# sourceMappingURL=shard-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shard-service.d.ts","sourceRoot":"","sources":["../../src/core/shard-service.ts"],"names":[],"mappings":"AAeA,OAAO,EAAsB,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,
|
|
1
|
+
{"version":3,"file":"shard-service.d.ts","sourceRoot":"","sources":["../../src/core/shard-service.ts"],"names":[],"mappings":"AAeA,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAsB,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAIL,YAAY,EAGb,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAE/E,OAAO,EAAE,qBAAqB,EAAoB,MAAM,+BAA+B,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAG5D;;GAEG;AACH,qBAAa,mBAAmB;;IAW9B;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,OAAO,YAAY,CAAC,CAAC;IAEnD;;;;;;;;OAQG;gBAED,KAAK,EAAE,qBAAqB,EAC5B,SAAS,EAAE,iBAAiB,EAC5B,GAAG,EAAE,MAAM,SAAS,EACpB,SAAS,EAAE,MAAM,EACjB,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI;CA2J7C;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC;IAC3C;;OAEG;IACH,YAAY,EAAE,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,KAAK,UAAU,CAAC;IAE5D;;OAEG;IACH,aAAa,EAAE,CAAC,MAAM,EAAE,QAAQ,GAAG,SAAS,KAAK,QAAQ,CAAC;CAC3D,CAGC,CAAC"}
|