@graftland/plugin-remote 0.3.0 → 0.3.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.
- package/dist/Auth.d.ts +2 -2
- package/dist/Auth.d.ts.map +1 -1
- package/dist/Auth.js.map +1 -1
- package/dist/{Bootstrap-MCwivGN1.js → Bootstrap-H9gDsgsC.js} +2 -2
- package/dist/{Contract-CcpSIJm4.js → Contract-DsJtisvL.js} +8 -46
- package/dist/Contract.d.ts +50 -53
- package/dist/Contract.d.ts.map +1 -1
- package/dist/Contract.js +1 -1
- package/dist/Contract.js.map +1 -1
- package/dist/{Errors-oPsTLY7l.js → Errors-DYhsGZcZ.js} +14 -1
- package/dist/Errors.d.ts +19 -0
- package/dist/Errors.d.ts.map +1 -1
- package/dist/Errors.js +14 -1
- package/dist/Errors.js.map +1 -1
- package/dist/{FailureGroup-BcH0XOBi.js → FailureGroup-BgT73AaR.js} +14 -4
- package/dist/{Framing-zaYdOJnT.js → Framing-G9eSaeLb.js} +1 -1
- package/dist/{Graft-BsYq3F-J.js → Graft-B71CPA2Y.js} +46 -35
- package/dist/{Packages-B1TPk8pa.js → Packages-AgoCGotL.js} +23 -26
- package/dist/{Peer-IJgFK6mD.js → Peer-DXeVrGBh.js} +5 -5
- package/dist/{ProcessObservation-DEGrEMfP.js → ProcessObservation-gLgGirYv.js} +1 -1
- package/dist/{ServeLifecycle-CJM0gG5B.js → ServeLifecycle-Bd1FPJ6e.js} +1 -1
- package/dist/Testing.d.ts +4 -4
- package/dist/Testing.d.ts.map +1 -1
- package/dist/Testing.js +10 -4
- package/dist/Testing.js.map +1 -1
- package/dist/Transport.d.ts +2 -2
- package/dist/Transport.d.ts.map +1 -1
- package/dist/Transport.js.map +1 -1
- package/dist/bin.js +48 -47
- package/dist/bin.js.map +1 -1
- package/dist/{childRuntime-DSqtFN9o.js → childRuntime-Bm3iSg_N.js} +30 -26
- package/dist/connectionEnded-BwcxQ7W8.js +54 -0
- package/dist/{entry-SYsx9VNb.js → entry-psOpX3Bj.js} +76 -48
- package/dist/host/auth/bearer.d.ts +1 -2
- package/dist/host/auth/bearer.d.ts.map +1 -1
- package/dist/host/auth/bearer.js +1 -1
- package/dist/host/auth/bearer.js.map +1 -1
- package/dist/host/auth/jwt.d.ts +1 -2
- package/dist/host/auth/jwt.d.ts.map +1 -1
- package/dist/host/auth/jwt.js +1 -1
- package/dist/host/auth/jwt.js.map +1 -1
- package/dist/host/auth/mtls.js +2 -2
- package/dist/host/auth/none.js +1 -1
- package/dist/host/command.d.ts +1 -1
- package/dist/host/command.d.ts.map +1 -1
- package/dist/host/command.js +4 -4
- package/dist/host/command.js.map +1 -1
- package/dist/host/local.d.ts +1 -2
- package/dist/host/local.d.ts.map +1 -1
- package/dist/host/local.js +3 -3
- package/dist/host/local.js.map +1 -1
- package/dist/host/unix.d.ts +1 -1
- package/dist/host/unix.d.ts.map +1 -1
- package/dist/host/unix.js +3 -3
- package/dist/host/unix.js.map +1 -1
- package/dist/host/websocket.d.ts +1 -1
- package/dist/host/websocket.d.ts.map +1 -1
- package/dist/host/websocket.js +3 -3
- package/dist/host/websocket.js.map +1 -1
- package/dist/host/worker.d.ts +1 -2
- package/dist/host/worker.d.ts.map +1 -1
- package/dist/host/worker.js +4 -5
- package/dist/host/worker.js.map +1 -1
- package/dist/{importer-D7zSgqxq.js → importer-Cvf88eAY.js} +5 -8
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -10
- package/dist/index.js.map +1 -1
- package/dist/internal/Certificates.js +4 -4
- package/dist/internal/Certificates.js.map +1 -1
- package/dist/internal/FailureGroup.js +3 -2
- package/dist/internal/FailureGroup.js.map +1 -1
- package/dist/internal/assembly.js +9 -2
- package/dist/internal/assembly.js.map +1 -1
- package/dist/internal/auth/mtls.js +1 -1
- package/dist/internal/auth/mtls.js.map +1 -1
- package/dist/internal/auth/tokenCredentials.d.ts +0 -1
- package/dist/internal/auth/tokenCredentials.d.ts.map +1 -1
- package/dist/internal/auth/tokenCredentials.js.map +1 -1
- package/dist/internal/child.js +20 -17
- package/dist/internal/child.js.map +1 -1
- package/dist/internal/childRuntime.js +6 -4
- package/dist/internal/childRuntime.js.map +1 -1
- package/dist/internal/contract.js +26 -0
- package/dist/internal/contract.js.map +1 -0
- package/dist/internal/credentials.d.ts +6 -6
- package/dist/internal/credentials.d.ts.map +1 -1
- package/dist/internal/credentials.js.map +1 -1
- package/dist/internal/directTransport.d.ts +1 -1
- package/dist/internal/entry.d.ts +1 -2
- package/dist/internal/entry.d.ts.map +1 -1
- package/dist/internal/entry.js +4 -14
- package/dist/internal/entry.js.map +1 -1
- package/dist/internal/execution.js +44 -7
- package/dist/internal/execution.js.map +1 -1
- package/dist/internal/host/runner.js +7 -6
- package/dist/internal/host/runner.js.map +1 -1
- package/dist/internal/host.js +5 -5
- package/dist/internal/host.js.map +1 -1
- package/dist/internal/port.d.ts +2 -10
- package/dist/internal/port.js +5 -5
- package/dist/internal/port.js.map +1 -1
- package/dist/internal/release.js +1 -1
- package/dist/internal/release.js.map +1 -1
- package/dist/internal/runner/Connection.d.ts +1 -1
- package/dist/internal/runner/Connection.js +4 -4
- package/dist/internal/runner/Connection.js.map +1 -1
- package/dist/internal/runner/Execution.js +3 -3
- package/dist/internal/runner/Execution.js.map +1 -1
- package/dist/internal/runner/Framing.d.ts +1 -11
- package/dist/internal/runner/Framing.js +1 -1
- package/dist/internal/runner/Framing.js.map +1 -1
- package/dist/internal/runner/Local.js +1 -1
- package/dist/internal/runner/Local.js.map +1 -1
- package/dist/internal/runner/Lock.js +1 -1
- package/dist/internal/runner/Lock.js.map +1 -1
- package/dist/internal/runner/Packages.d.ts +1 -1
- package/dist/internal/runner/Packages.js +22 -25
- package/dist/internal/runner/Packages.js.map +1 -1
- package/dist/internal/runner/Processes.js +7 -9
- package/dist/internal/runner/Processes.js.map +1 -1
- package/dist/internal/runner/Store.js +3 -3
- package/dist/internal/runner/Store.js.map +1 -1
- package/dist/internal/runner/Supervisor.js +46 -47
- package/dist/internal/runner/Supervisor.js.map +1 -1
- package/dist/internal/runner/accept.js +3 -3
- package/dist/internal/runner/accept.js.map +1 -1
- package/dist/internal/runner/model.js +1 -1
- package/dist/internal/runner/model.js.map +1 -1
- package/dist/internal/serve.js +1 -1
- package/dist/internal/serve.js.map +1 -1
- package/dist/internal/services.d.ts +2 -12
- package/dist/internal/services.d.ts.map +1 -1
- package/dist/internal/services.js.map +1 -1
- package/dist/internal/supervisorPlugin.js +1 -1
- package/dist/internal/watchdogMain.js +5 -5
- package/dist/internal/watchdogMain.js.map +1 -1
- package/dist/internal/websocketServer.js +3 -1
- package/dist/internal/websocketServer.js.map +1 -1
- package/dist/internal/workerMain.js +3 -3
- package/dist/{port-Blbh8tms.js → port--3x2zJ4D.js} +8 -8
- package/dist/{release-BY4Mlluy.js → release-DfZPuIcK.js} +1 -1
- package/dist/runner/auth/bearer.js +2 -2
- package/dist/runner/auth/jwt.js +4 -4
- package/dist/runner/auth/jwt.js.map +1 -1
- package/dist/runner/auth/mtls.js +3 -3
- package/dist/runner/auth/none.js +1 -1
- package/dist/runner/index.js +5 -5
- package/dist/runner/stdio.js +3 -3
- package/dist/runner/unix.js +3 -3
- package/dist/runner/websocket.js +4 -4
- package/dist/{socketChannel-KmtzF-9G.js → socketChannel-CJvL2DiB.js} +2 -2
- package/dist/{supervisorPlugin-Inb1S5IV.js → supervisorPlugin-t6Z6PrhD.js} +72 -76
- package/dist/{token-v5ne2I0-.js → token-CYBNNlhS.js} +1 -1
- package/dist/{tokenCredentials-WUJm2AKm.js → tokenCredentials-CbCuk-Rt.js} +3 -3
- package/dist/{websocketServer-MXcCJx0v.js → websocketServer-NQhODlEt.js} +5 -3
- package/dist/{workerChannel-P82YdNjh.js → workerChannel-C8hhBJzA.js} +1 -1
- package/package.json +3 -3
- package/src/Auth.ts +9 -2
- package/src/Contract.ts +67 -51
- package/src/Errors.ts +23 -0
- package/src/Testing.ts +16 -2
- package/src/Transport.ts +6 -2
- package/src/bin.ts +28 -30
- package/src/host/auth/bearer.ts +1 -6
- package/src/host/auth/jwt.ts +1 -6
- package/src/host/command.ts +2 -0
- package/src/host/local.ts +5 -9
- package/src/host/unix.ts +2 -0
- package/src/host/websocket.ts +2 -0
- package/src/host/worker.ts +4 -6
- package/src/index.ts +8 -4
- package/src/internal/Certificates.ts +10 -13
- package/src/internal/FailureGroup.ts +128 -121
- package/src/internal/assembly.ts +19 -10
- package/src/internal/auth/mtls.ts +19 -20
- package/src/internal/auth/tokenCredentials.ts +1 -7
- package/src/internal/child.ts +249 -240
- package/src/internal/childRuntime.ts +84 -81
- package/src/internal/contract.ts +47 -0
- package/src/internal/credentials.ts +12 -9
- package/src/internal/entry.ts +11 -25
- package/src/internal/execution.ts +73 -14
- package/src/internal/host/runner.ts +153 -153
- package/src/internal/host.ts +123 -130
- package/src/internal/port.ts +100 -103
- package/src/internal/release.ts +3 -2
- package/src/internal/runner/Connection.ts +52 -60
- package/src/internal/runner/Execution.ts +163 -164
- package/src/internal/runner/Framing.ts +9 -10
- package/src/internal/runner/Local.ts +26 -27
- package/src/internal/runner/Lock.ts +23 -25
- package/src/internal/runner/Packages.ts +67 -70
- package/src/internal/runner/Processes.ts +89 -92
- package/src/internal/runner/Store.ts +110 -114
- package/src/internal/runner/Supervisor.ts +392 -405
- package/src/internal/runner/accept.ts +76 -84
- package/src/internal/runner/model.ts +20 -21
- package/src/internal/serve.ts +15 -13
- package/src/internal/services.ts +1 -19
- package/src/internal/watchdogMain.ts +16 -11
- package/src/internal/websocketServer.ts +18 -3
- package/src/runner/auth/jwt.ts +10 -6
- package/dist/cleanup-BPWr-5U9.js +0 -13
- package/dist/connectionEnded-DUgcobEd.js +0 -9
- package/dist/internal/childErrors.d.ts +0 -33
- package/dist/internal/childErrors.d.ts.map +0 -1
- package/dist/internal/port.d.ts.map +0 -1
- package/dist/internal/runner/Framing.d.ts.map +0 -1
package/src/internal/port.ts
CHANGED
|
@@ -167,64 +167,66 @@ interface State {
|
|
|
167
167
|
readonly servers: HashMap.HashMap<string, ServerEndpoint>
|
|
168
168
|
readonly clients: HashMap.HashMap<string, ClientEndpoint>
|
|
169
169
|
}
|
|
170
|
-
const initialize = (
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
170
|
+
const initialize = Effect.fnUntraced(function* (
|
|
171
|
+
bytes: Channel,
|
|
172
|
+
options: Options,
|
|
173
|
+
): Effect.fn.Return<State, never, Scope.Scope> {
|
|
174
|
+
const limits = { ...defaults, ...options.limits }
|
|
175
|
+
const workers = yield* FailureGroup.make<TransportError>()
|
|
176
|
+
const incoming = yield* TxRef.make(
|
|
177
|
+
HashMap.empty<RequestKey, RequestState<RpcMessage.FromClientEncoded>>(),
|
|
178
|
+
)
|
|
179
|
+
const outgoing = yield* TxRef.make(
|
|
180
|
+
HashMap.empty<RequestKey, RequestState<RpcMessage.FromServerEncoded>>(),
|
|
181
|
+
)
|
|
182
|
+
const queues = {
|
|
183
|
+
control: yield* TxQueue.unbounded<Pending, Cause.Done>(),
|
|
184
|
+
data: yield* TxQueue.unbounded<Pending, Cause.Done>(),
|
|
185
|
+
log: yield* TxQueue.unbounded<Pending, Cause.Done>(),
|
|
186
|
+
}
|
|
187
|
+
const servers = yield* Effect.forEach(
|
|
188
|
+
Record.toEntries(options.serve),
|
|
189
|
+
Effect.fnUntraced(function* ([name, group]) {
|
|
190
|
+
return [
|
|
191
|
+
name,
|
|
192
|
+
{
|
|
193
|
+
group,
|
|
194
|
+
ready:
|
|
195
|
+
yield* Deferred.make<
|
|
196
|
+
Parameters<RpcServer.Protocol["Service"]["run"]>[0]
|
|
197
|
+
>(),
|
|
198
|
+
disconnects: yield* Queue.dropping<number>(1),
|
|
199
|
+
},
|
|
200
|
+
] satisfies readonly [string, unknown]
|
|
201
|
+
}),
|
|
202
|
+
).pipe(Effect.map(HashMap.fromIterable))
|
|
203
|
+
const clients = yield* Effect.forEach(
|
|
204
|
+
Record.toEntries(options.call),
|
|
205
|
+
Effect.fnUntraced(function* ([name, group]) {
|
|
206
|
+
return [
|
|
207
|
+
name,
|
|
208
|
+
{
|
|
209
|
+
group,
|
|
210
|
+
ready:
|
|
211
|
+
yield* Deferred.make<
|
|
212
|
+
Parameters<RpcClient.Protocol["Service"]["run"]>[1]
|
|
213
|
+
>(),
|
|
214
|
+
},
|
|
215
|
+
] satisfies readonly [string, unknown]
|
|
216
|
+
}),
|
|
217
|
+
).pipe(Effect.map(HashMap.fromIterable))
|
|
218
|
+
return {
|
|
219
|
+
bytes,
|
|
220
|
+
options,
|
|
221
|
+
limits,
|
|
222
|
+
workers,
|
|
223
|
+
incoming,
|
|
224
|
+
outgoing,
|
|
225
|
+
queues,
|
|
226
|
+
servers,
|
|
227
|
+
clients,
|
|
228
|
+
}
|
|
229
|
+
})
|
|
228
230
|
|
|
229
231
|
const admit = Effect.fnUntraced(function* <A>(
|
|
230
232
|
state: State,
|
|
@@ -447,41 +449,38 @@ const serverProtocol = (
|
|
|
447
449
|
),
|
|
448
450
|
})
|
|
449
451
|
}
|
|
450
|
-
const next = (state: State)
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
sent: true,
|
|
471
|
-
}),
|
|
472
|
-
)
|
|
473
|
-
}
|
|
474
|
-
return Option.some(frame)
|
|
475
|
-
}
|
|
476
|
-
if (
|
|
477
|
-
(yield* TxQueue.isDone(state.queues.control)) &&
|
|
478
|
-
(yield* TxQueue.isDone(state.queues.data)) &&
|
|
479
|
-
(yield* TxQueue.isDone(state.queues.log))
|
|
452
|
+
const next = Effect.fnUntraced(function* (state: State) {
|
|
453
|
+
yield* state.workers.check
|
|
454
|
+
for (const p of [
|
|
455
|
+
"control",
|
|
456
|
+
"data",
|
|
457
|
+
"log",
|
|
458
|
+
] satisfies ReadonlyArray<Priority>) {
|
|
459
|
+
const pending = yield* TxQueue.poll(state.queues[p])
|
|
460
|
+
if (Option.isNone(pending)) continue
|
|
461
|
+
const { frame, request } = pending.value
|
|
462
|
+
if (Option.isSome(request)) {
|
|
463
|
+
const table = yield* TxRef.get(state.outgoing)
|
|
464
|
+
const requestState = HashMap.get(table, request.value)
|
|
465
|
+
if (Option.isNone(requestState)) return Option.none<Frame>()
|
|
466
|
+
yield* TxRef.set(
|
|
467
|
+
state.outgoing,
|
|
468
|
+
HashMap.set(table, request.value, {
|
|
469
|
+
...requestState.value,
|
|
470
|
+
sent: true,
|
|
471
|
+
}),
|
|
480
472
|
)
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
473
|
+
}
|
|
474
|
+
return Option.some(frame)
|
|
475
|
+
}
|
|
476
|
+
if (
|
|
477
|
+
(yield* TxQueue.isDone(state.queues.control)) &&
|
|
478
|
+
(yield* TxQueue.isDone(state.queues.data)) &&
|
|
479
|
+
(yield* TxQueue.isDone(state.queues.log))
|
|
484
480
|
)
|
|
481
|
+
return yield* Cause.done()
|
|
482
|
+
return yield* Effect.txRetry
|
|
483
|
+
}, Effect.tx)
|
|
485
484
|
const writer = (state: State) =>
|
|
486
485
|
Stream.fromEffectRepeat(next(state)).pipe(
|
|
487
486
|
Stream.filterMap(Result.fromOption(() => undefined)),
|
|
@@ -592,18 +591,16 @@ export const make = Effect.fnUntraced(function* (
|
|
|
592
591
|
// The same failure remains observable through Port.await and client requests.
|
|
593
592
|
// This observer only publishes disconnects, even while the owner closes its scope.
|
|
594
593
|
yield* state.workers.await.pipe(
|
|
595
|
-
Effect.catchCause(
|
|
596
|
-
Effect.
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
TxRef.set(state.
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
}),
|
|
606
|
-
),
|
|
594
|
+
Effect.catchCause(
|
|
595
|
+
Effect.fnUntraced(function* () {
|
|
596
|
+
for (const server of HashMap.values(state.servers))
|
|
597
|
+
yield* Queue.offer(server.disconnects, 0)
|
|
598
|
+
yield* Effect.tx(
|
|
599
|
+
TxRef.set(state.incoming, HashMap.empty()).pipe(
|
|
600
|
+
Effect.andThen(TxRef.set(state.outgoing, HashMap.empty())),
|
|
601
|
+
),
|
|
602
|
+
)
|
|
603
|
+
}, Effect.uninterruptible),
|
|
607
604
|
),
|
|
608
605
|
Effect.forkScoped,
|
|
609
606
|
)
|
package/src/internal/release.ts
CHANGED
|
@@ -19,8 +19,9 @@ export const close = (
|
|
|
19
19
|
) =>
|
|
20
20
|
Effect.uninterruptible(
|
|
21
21
|
Scope.close(scope, exit).pipe(
|
|
22
|
-
Effect.catchCauseIf(
|
|
23
|
-
|
|
22
|
+
Effect.catchCauseIf(
|
|
23
|
+
Cause.hasInterruptsOnly,
|
|
24
|
+
Effect.fnUntraced(function* (cause) {
|
|
24
25
|
// Re-entering interruptibility observes pending external cancellation without producing a self-interrupt.
|
|
25
26
|
// Read it after release so cancellation arriving during a finalizer is included too.
|
|
26
27
|
const pending = yield* Effect.exit(Effect.interruptible(Effect.void))
|
|
@@ -112,73 +112,65 @@ const finish = (causes: ReadonlyArray<Cause.Cause<unknown>>) => {
|
|
|
112
112
|
/** Close partially acquired resources too; the normal release observes exit before stopping readers. */
|
|
113
113
|
const scopes = Effect.acquireRelease(
|
|
114
114
|
Effect.all({ resources: Scope.make(), process: Scope.make() }),
|
|
115
|
-
(scopes, exit)
|
|
116
|
-
Effect.
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
)
|
|
121
|
-
yield* finish([reason(process), reason(resources)])
|
|
122
|
-
}),
|
|
115
|
+
Effect.fnUntraced(function* (scopes, exit) {
|
|
116
|
+
const process = yield* Effect.exit(Release.close(scopes.process, exit))
|
|
117
|
+
const resources = yield* Effect.exit(Release.close(scopes.resources, exit))
|
|
118
|
+
yield* finish([reason(process), reason(resources)])
|
|
119
|
+
}),
|
|
123
120
|
)
|
|
124
121
|
|
|
125
122
|
/** Setup supplies a concrete control lifecycle; release never reads a later-installed effect. */
|
|
126
|
-
export const acquire = <A, E, R, D, DR>(
|
|
123
|
+
export const acquire = Effect.fnUntraced(function* <A, E, R, D, DR>(
|
|
127
124
|
target: Target,
|
|
128
125
|
contractModule: string,
|
|
129
126
|
options: Port.Options,
|
|
130
127
|
setup: Effect.Effect<A, E, R | Connection>,
|
|
131
128
|
dispose: (value: A) => Effect.Effect<Cause.Cause<unknown>, D, DR>,
|
|
132
129
|
timeout: Duration.Input,
|
|
133
|
-
)
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
owned.process,
|
|
152
|
-
)
|
|
153
|
-
}).pipe(Effect.interruptible),
|
|
154
|
-
(connection, exit) =>
|
|
155
|
-
Effect.gen(function* () {
|
|
156
|
-
const process = yield* Effect.exit(Release.close(owned.process, exit))
|
|
157
|
-
// Wait for exit while readers are alive; collect their final cause after resources close.
|
|
158
|
-
yield* connection.diagnostics
|
|
159
|
-
const resources = yield* Effect.exit(
|
|
160
|
-
Release.close(owned.resources, exit),
|
|
161
|
-
)
|
|
162
|
-
const diagnostics = yield* connection.diagnostics
|
|
163
|
-
yield* finish([reason(process), reason(resources), diagnostics])
|
|
164
|
-
}),
|
|
165
|
-
)
|
|
166
|
-
return yield* Effect.acquireRelease(
|
|
167
|
-
setup.pipe(Effect.provideService(Connection, connection)),
|
|
168
|
-
(value) =>
|
|
169
|
-
Effect.gen(function* () {
|
|
170
|
-
const graceful = yield* dispose(value).pipe(
|
|
171
|
-
Effect.interruptible,
|
|
172
|
-
Effect.timeout(timeout),
|
|
173
|
-
Effect.exit,
|
|
174
|
-
)
|
|
175
|
-
const terminated = yield* Effect.exit(
|
|
176
|
-
connection.terminate(Exit.isSuccess(graceful)),
|
|
130
|
+
) {
|
|
131
|
+
const owned = yield* scopes
|
|
132
|
+
const connection = yield* Effect.acquireRelease(
|
|
133
|
+
Effect.gen(function* () {
|
|
134
|
+
return target._tag === "Local" || target._tag === "Worker"
|
|
135
|
+
? yield* Local(
|
|
136
|
+
target,
|
|
137
|
+
contractModule,
|
|
138
|
+
options,
|
|
139
|
+
owned.resources,
|
|
140
|
+
owned.process,
|
|
141
|
+
).pipe(Effect.map(connected))
|
|
142
|
+
: yield* RunnerConnection.connect(
|
|
143
|
+
target,
|
|
144
|
+
contractModule,
|
|
145
|
+
options,
|
|
146
|
+
owned.resources,
|
|
147
|
+
owned.process,
|
|
177
148
|
)
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
149
|
+
}).pipe(Effect.interruptible),
|
|
150
|
+
Effect.fnUntraced(function* (connection, exit) {
|
|
151
|
+
const process = yield* Effect.exit(Release.close(owned.process, exit))
|
|
152
|
+
// Wait for exit while readers are alive; collect their final cause after resources close.
|
|
153
|
+
yield* connection.diagnostics
|
|
154
|
+
const resources = yield* Effect.exit(Release.close(owned.resources, exit))
|
|
155
|
+
const diagnostics = yield* connection.diagnostics
|
|
156
|
+
yield* finish([reason(process), reason(resources), diagnostics])
|
|
157
|
+
}),
|
|
158
|
+
)
|
|
159
|
+
return yield* Effect.acquireRelease(
|
|
160
|
+
setup.pipe(Effect.provideService(Connection, connection)),
|
|
161
|
+
Effect.fnUntraced(function* (value) {
|
|
162
|
+
const graceful = yield* dispose(value).pipe(
|
|
163
|
+
Effect.interruptible,
|
|
164
|
+
Effect.timeout(timeout),
|
|
165
|
+
Effect.exit,
|
|
166
|
+
)
|
|
167
|
+
const terminated = yield* Effect.exit(
|
|
168
|
+
connection.terminate(Exit.isSuccess(graceful)),
|
|
169
|
+
)
|
|
170
|
+
yield* finish([
|
|
171
|
+
Exit.isSuccess(graceful) ? graceful.value : graceful.cause,
|
|
172
|
+
reason(terminated),
|
|
173
|
+
])
|
|
174
|
+
}),
|
|
175
|
+
)
|
|
176
|
+
})
|