@graftland/plugin-remote 0.3.2 → 0.4.0
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 +18 -54
- package/README.zh-CN.md +17 -51
- package/README.zh-TW.md +17 -51
- package/dist/Auth.d.ts.map +1 -1
- package/dist/Auth.js.map +1 -1
- package/dist/Config.d.ts +1151 -0
- package/dist/Config.d.ts.map +1 -0
- package/dist/Config.js +183 -0
- package/dist/Config.js.map +1 -0
- package/dist/Contract.d.ts +1 -1
- package/dist/Contract.d.ts.map +1 -1
- package/dist/Contract.js +32 -1
- package/dist/Contract.js.map +1 -1
- package/dist/Instance.d.ts.map +1 -1
- package/dist/Instance.js.map +1 -1
- package/dist/Testing.d.ts +1 -1
- package/dist/Testing.d.ts.map +1 -1
- package/dist/Testing.js.map +1 -1
- package/dist/Transport.d.ts +1 -1
- package/dist/Transport.d.ts.map +1 -1
- package/dist/Transport.js.map +1 -1
- package/dist/cli.d.ts +4 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +25 -0
- package/dist/cli.js.map +1 -0
- package/dist/host/auth/bearer.d.ts +9 -1
- package/dist/host/auth/bearer.d.ts.map +1 -1
- package/dist/host/auth/bearer.js +4 -2
- package/dist/host/auth/bearer.js.map +1 -1
- package/dist/host/auth/jwt.d.ts +9 -1
- package/dist/host/auth/jwt.d.ts.map +1 -1
- package/dist/host/auth/jwt.js +4 -2
- package/dist/host/auth/jwt.js.map +1 -1
- package/dist/host/auth/mtls.d.ts +10 -7
- package/dist/host/auth/mtls.d.ts.map +1 -1
- package/dist/host/auth/mtls.js +13 -14
- package/dist/host/auth/mtls.js.map +1 -1
- package/dist/host/auth/none.d.ts +3 -1
- package/dist/host/auth/none.js +7 -5
- package/dist/host/auth/none.js.map +1 -1
- package/dist/host/command.d.ts +14 -1
- package/dist/host/command.d.ts.map +1 -1
- package/dist/host/command.js +11 -9
- package/dist/host/command.js.map +1 -1
- package/dist/host/local.d.ts +2 -1
- package/dist/host/local.d.ts.map +1 -1
- package/dist/host/local.js +9 -30
- package/dist/host/local.js.map +1 -1
- package/dist/host/unix.d.ts +6 -1
- package/dist/host/unix.d.ts.map +1 -1
- package/dist/host/unix.js +13 -9
- package/dist/host/unix.js.map +1 -1
- package/dist/host/websocket.d.ts +10 -1
- package/dist/host/websocket.d.ts.map +1 -1
- package/dist/host/websocket.js +11 -8
- package/dist/host/websocket.js.map +1 -1
- package/dist/host/worker.d.ts +3 -1
- package/dist/host/worker.d.ts.map +1 -1
- package/dist/host/worker.js +13 -9
- package/dist/host/worker.js.map +1 -1
- package/dist/index.d.ts +6 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +30 -64
- package/dist/index.js.map +1 -1
- package/dist/internal/Certificates.js.map +1 -1
- package/dist/internal/FailureGroup.js +6 -6
- package/dist/internal/FailureGroup.js.map +1 -1
- package/dist/internal/Peer.js.map +1 -1
- package/dist/internal/{ServeLifecycle.js → RunnerLifecycle.js} +6 -6
- package/dist/internal/RunnerLifecycle.js.map +1 -0
- package/dist/internal/Supervisor.js.map +1 -1
- package/dist/internal/assembly.d.ts +3 -2
- package/dist/internal/assembly.js +8 -8
- package/dist/internal/assembly.js.map +1 -1
- package/dist/internal/auth/config.d.ts +27 -0
- package/dist/internal/auth/config.d.ts.map +1 -0
- package/dist/internal/auth/config.js +29 -0
- package/dist/internal/auth/config.js.map +1 -0
- package/dist/internal/auth/mtls.js.map +1 -1
- package/dist/internal/auth/token.js.map +1 -1
- package/dist/internal/auth/tokenCredentials.d.ts +2 -1
- package/dist/internal/auth/tokenCredentials.d.ts.map +1 -1
- package/dist/internal/auth/tokenCredentials.js +1 -1
- package/dist/internal/auth/tokenCredentials.js.map +1 -1
- package/dist/internal/child.js +3 -3
- package/dist/internal/child.js.map +1 -1
- package/dist/internal/childMain.js +47 -0
- package/dist/internal/childMain.js.map +1 -0
- package/dist/internal/childRuntime.js +8 -8
- package/dist/internal/childRuntime.js.map +1 -1
- package/dist/internal/cleanup.js +3 -3
- package/dist/internal/cleanup.js.map +1 -1
- package/dist/internal/contract.js.map +1 -1
- package/dist/internal/credentials.d.ts +3 -2
- package/dist/internal/credentials.d.ts.map +1 -1
- package/dist/internal/credentials.js +1 -1
- package/dist/internal/credentials.js.map +1 -1
- package/dist/internal/directTransport.js.map +1 -1
- package/dist/internal/entry.d.ts +493 -3
- package/dist/internal/entry.d.ts.map +1 -1
- package/dist/internal/entry.js +22 -9
- package/dist/internal/entry.js.map +1 -1
- package/dist/internal/entryConfig.d.ts +2 -202
- package/dist/internal/entryConfig.js +2 -136
- package/dist/internal/entryConfig.js.map +1 -1
- package/dist/internal/execution.d.ts +4 -4
- package/dist/internal/execution.js +11 -11
- package/dist/internal/execution.js.map +1 -1
- package/dist/internal/follow.js +1 -1
- package/dist/internal/follow.js.map +1 -1
- package/dist/internal/forkTree.js.map +1 -1
- package/dist/internal/host/local.js.map +1 -1
- package/dist/internal/host/runner.js +4 -4
- package/dist/internal/host/runner.js.map +1 -1
- package/dist/internal/host.js +2 -2
- package/dist/internal/host.js.map +1 -1
- package/dist/internal/importer.js +1 -1
- package/dist/internal/importer.js.map +1 -1
- package/dist/internal/listenerStartup.js +1 -1
- package/dist/internal/listenerStartup.js.map +1 -1
- package/dist/internal/loadModule.js.map +1 -1
- package/dist/internal/platform.js +1 -9
- package/dist/internal/port.d.ts +1 -1
- package/dist/internal/port.js +2 -2
- package/dist/internal/port.js.map +1 -1
- package/dist/internal/runner/Bootstrap.js.map +1 -1
- package/dist/internal/runner/Connection.d.ts +3 -2
- package/dist/internal/runner/Connection.js +6 -6
- package/dist/internal/runner/Connection.js.map +1 -1
- package/dist/internal/runner/Execution.js +6 -6
- package/dist/internal/runner/Execution.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.map +1 -1
- package/dist/internal/runner/Multiplex.js.map +1 -1
- package/dist/internal/runner/Packages.js.map +1 -1
- package/dist/internal/runner/ProcessObservation.js.map +1 -1
- package/dist/internal/runner/Processes.js.map +1 -1
- package/dist/internal/runner/Retention.js.map +1 -1
- package/dist/internal/runner/Store.js.map +1 -1
- package/dist/internal/runner/Supervisor.js +5 -5
- package/dist/internal/runner/Supervisor.js.map +1 -1
- package/dist/internal/runner/Watchdog.js.map +1 -1
- package/dist/internal/runner/Wire.d.ts +1 -1
- package/dist/internal/runner/Wire.js.map +1 -1
- package/dist/internal/runner/accept.js +2 -2
- package/dist/internal/runner/accept.js.map +1 -1
- package/dist/internal/runner/command.js +1 -1
- package/dist/internal/runner/command.js.map +1 -1
- package/dist/internal/runner/connectionEnded.js +1 -1
- package/dist/internal/runner/connectionEnded.js.map +1 -1
- package/dist/internal/runner/model.d.ts.map +1 -1
- package/dist/internal/runner/model.js.map +1 -1
- package/dist/internal/services.d.ts.map +1 -1
- package/dist/internal/services.js +1 -1
- package/dist/internal/services.js.map +1 -1
- package/dist/internal/socketChannel.js.map +1 -1
- package/dist/internal/stdioChannel.js.map +1 -1
- package/dist/internal/supervisorPlugin.js +48 -1
- package/dist/internal/supervisorPlugin.js.map +1 -1
- package/dist/internal/transportOptions.d.ts.map +1 -1
- package/dist/internal/watchdogMain.js +5 -3
- package/dist/internal/watchdogMain.js.map +1 -1
- package/dist/internal/websocket.js.map +1 -1
- package/dist/internal/websocketServer.js +1 -1
- package/dist/internal/websocketServer.js.map +1 -1
- package/dist/internal/workerChannel.js.map +1 -1
- package/dist/internal/workerMain.js +13 -6
- package/dist/internal/workerMain.js.map +1 -1
- package/dist/runner/auth/bearer.d.ts +8 -5
- package/dist/runner/auth/bearer.d.ts.map +1 -1
- package/dist/runner/auth/bearer.js +13 -11
- package/dist/runner/auth/bearer.js.map +1 -1
- package/dist/runner/auth/jwt.d.ts +30 -17
- package/dist/runner/auth/jwt.d.ts.map +1 -1
- package/dist/runner/auth/jwt.js +16 -28
- package/dist/runner/auth/jwt.js.map +1 -1
- package/dist/runner/auth/mtls.d.ts +8 -6
- package/dist/runner/auth/mtls.d.ts.map +1 -1
- package/dist/runner/auth/mtls.js +13 -29
- package/dist/runner/auth/mtls.js.map +1 -1
- package/dist/runner/auth/none.d.ts +7 -1
- package/dist/runner/auth/none.js +7 -5
- package/dist/runner/auth/none.js.map +1 -1
- package/dist/runner/index.d.ts +5 -1
- package/dist/runner/index.d.ts.map +1 -1
- package/dist/runner/index.js +62 -30
- package/dist/runner/index.js.map +1 -1
- package/dist/runner/stdio.d.ts +6 -1
- package/dist/runner/stdio.d.ts.map +1 -1
- package/dist/runner/stdio.js +11 -9
- package/dist/runner/stdio.js.map +1 -1
- package/dist/runner/unix.d.ts +6 -1
- package/dist/runner/unix.d.ts.map +1 -1
- package/dist/runner/unix.js +10 -8
- package/dist/runner/unix.js.map +1 -1
- package/dist/runner/websocket.d.ts +24 -1
- package/dist/runner/websocket.d.ts.map +1 -1
- package/dist/runner/websocket.js +12 -10
- package/dist/runner/websocket.js.map +1 -1
- package/package.json +14 -12
- package/schema.json +2269 -0
- package/src/Auth.ts +8 -2
- package/src/Config.ts +196 -0
- package/src/Contract.ts +12 -3
- package/src/Instance.ts +1 -0
- package/src/Testing.ts +6 -4
- package/src/Transport.ts +12 -3
- package/src/cli.ts +60 -0
- package/src/host/auth/bearer.ts +1 -0
- package/src/host/auth/jwt.ts +1 -0
- package/src/host/auth/mtls.ts +7 -12
- package/src/host/auth/none.ts +3 -1
- package/src/host/command.ts +8 -5
- package/src/host/local.ts +4 -2
- package/src/host/unix.ts +11 -7
- package/src/host/websocket.ts +10 -7
- package/src/host/worker.ts +8 -5
- package/src/index.ts +36 -23
- package/src/internal/Certificates.ts +1 -0
- package/src/internal/FailureGroup.ts +5 -3
- package/src/internal/Peer.ts +1 -0
- package/src/internal/{ServeLifecycle.ts → RunnerLifecycle.ts} +7 -5
- package/src/internal/Supervisor.ts +5 -4
- package/src/internal/assembly.ts +11 -9
- package/src/internal/auth/config.ts +44 -0
- package/src/internal/auth/mtls.ts +1 -0
- package/src/internal/auth/token.ts +1 -0
- package/src/internal/auth/tokenCredentials.ts +4 -2
- package/src/internal/child.ts +8 -6
- package/src/{bin.ts → internal/childMain.ts} +16 -61
- package/src/internal/childRuntime.ts +12 -10
- package/src/internal/cleanup.ts +3 -2
- package/src/internal/contract.ts +1 -0
- package/src/internal/credentials.ts +3 -1
- package/src/internal/directTransport.ts +9 -2
- package/src/internal/entry.ts +53 -16
- package/src/internal/entryConfig.ts +10 -132
- package/src/internal/execution.ts +17 -15
- package/src/internal/follow.ts +2 -1
- package/src/internal/forkTree.ts +2 -1
- package/src/internal/host/local.ts +1 -0
- package/src/internal/host/runner.ts +7 -5
- package/src/internal/host.ts +9 -8
- package/src/internal/importer.ts +3 -2
- package/src/internal/listenerStartup.ts +4 -2
- package/src/internal/loadModule.ts +1 -0
- package/src/internal/platform.ts +1 -12
- package/src/internal/port.ts +11 -6
- package/src/internal/runner/Bootstrap.ts +1 -0
- package/src/internal/runner/Connection.ts +13 -11
- package/src/internal/runner/Execution.ts +14 -13
- package/src/internal/runner/Local.ts +3 -2
- package/src/internal/runner/Lock.ts +1 -0
- package/src/internal/runner/Multiplex.ts +2 -1
- package/src/internal/runner/Packages.ts +7 -5
- package/src/internal/runner/ProcessObservation.ts +2 -1
- package/src/internal/runner/Processes.ts +3 -1
- package/src/internal/runner/Retention.ts +1 -0
- package/src/internal/runner/Store.ts +3 -2
- package/src/internal/runner/Supervisor.ts +22 -20
- package/src/internal/runner/Watchdog.ts +3 -1
- package/src/internal/runner/Wire.ts +13 -12
- package/src/internal/runner/accept.ts +6 -5
- package/src/internal/runner/command.ts +3 -2
- package/src/internal/runner/connectionEnded.ts +2 -1
- package/src/internal/runner/model.ts +5 -3
- package/src/internal/services.ts +9 -2
- package/src/internal/socketChannel.ts +2 -1
- package/src/internal/stdioChannel.ts +4 -2
- package/src/internal/supervisorPlugin.ts +10 -8
- package/src/internal/transportOptions.ts +1 -0
- package/src/internal/watchdogMain.ts +5 -3
- package/src/internal/websocket.ts +5 -2
- package/src/internal/websocketServer.ts +6 -4
- package/src/internal/workerChannel.ts +1 -0
- package/src/internal/workerMain.ts +21 -5
- package/src/runner/auth/bearer.ts +10 -6
- package/src/runner/auth/jwt.ts +10 -41
- package/src/runner/auth/mtls.ts +6 -3
- package/src/runner/auth/none.ts +3 -1
- package/src/runner/index.ts +102 -11
- package/src/runner/stdio.ts +15 -10
- package/src/runner/unix.ts +7 -4
- package/src/runner/websocket.ts +9 -7
- package/dist/Auth-BElTC9_X.js +0 -6
- package/dist/Bootstrap-H9gDsgsC.js +0 -9
- package/dist/ConfigDirectory-BCC6q2R4.js +0 -5
- package/dist/Contract-DsJtisvL.js +0 -83
- package/dist/Errors-DYhsGZcZ.js +0 -58
- package/dist/FailureGroup-BgT73AaR.js +0 -63
- package/dist/Framing-G9eSaeLb.js +0 -61
- package/dist/Graft-B71CPA2Y.js +0 -996
- package/dist/Packages-AgoCGotL.js +0 -108
- package/dist/Peer-DXeVrGBh.js +0 -342
- package/dist/ProcessObservation-gLgGirYv.js +0 -38
- package/dist/ServeLifecycle-Bd1FPJ6e.js +0 -24
- package/dist/Transport-DULzpsgR.js +0 -6
- package/dist/WatchdogProtocol-BZmVxrBP.js +0 -17
- package/dist/bin.js +0 -28276
- package/dist/bin.js.map +0 -1
- package/dist/childRuntime-Bm3iSg_N.js +0 -192
- package/dist/command-9zrHdbwT.js +0 -7
- package/dist/connectionEnded-BwcxQ7W8.js +0 -54
- package/dist/directTransport-DrexuPSm.js +0 -5
- package/dist/entry-psOpX3Bj.js +0 -736
- package/dist/importer-Cvf88eAY.js +0 -344
- package/dist/internal/ServeLifecycle.js.map +0 -1
- package/dist/internal/entryConfig.d.ts.map +0 -1
- package/dist/internal/platform.js.map +0 -1
- package/dist/internal/release.js +0 -25
- package/dist/internal/release.js.map +0 -1
- package/dist/internal/serve.js +0 -60
- package/dist/internal/serve.js.map +0 -1
- package/dist/port--3x2zJ4D.js +0 -285
- package/dist/release-DfZPuIcK.js +0 -23
- package/dist/rolldown-runtime-DYf_mQCB.js +0 -34
- package/dist/socketChannel-CJvL2DiB.js +0 -3658
- package/dist/supervisorPlugin-t6Z6PrhD.js +0 -733
- package/dist/token-CYBNNlhS.js +0 -17
- package/dist/tokenCredentials-CbCuk-Rt.js +0 -31
- package/dist/websocketServer-NQhODlEt.js +0 -60
- package/dist/workerChannel-C8hhBJzA.js +0 -27
- package/src/internal/release.ts +0 -72
- package/src/internal/serve.ts +0 -119
- /package/dist/{bin.d.ts → internal/childMain.d.ts} +0 -0
package/dist/port--3x2zJ4D.js
DELETED
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
import { t as EndOfStream } from "./Framing-G9eSaeLb.js";
|
|
2
|
-
import { t as make$1 } from "./FailureGroup-BgT73AaR.js";
|
|
3
|
-
import { u as TransportError } from "./Errors-DYhsGZcZ.js";
|
|
4
|
-
import { Array, Cause, Context, Data, Deferred, Effect, Fiber, HashMap, Option, Queue, Record, Result, Schema, Stream, TxQueue, TxRef } from "effect";
|
|
5
|
-
import { RpcClient, RpcClientError, RpcSerialization, RpcServer } from "effect/rpc";
|
|
6
|
-
// packages/remote/src/internal/Limits.ts
|
|
7
|
-
const PositiveInt = Schema.Int.check(Schema.isGreaterThan(0));
|
|
8
|
-
const PositiveFinite = Schema.Finite.check(Schema.isGreaterThan(0));
|
|
9
|
-
const Limits = Schema.Struct({
|
|
10
|
-
control: PositiveInt,
|
|
11
|
-
data: PositiveInt,
|
|
12
|
-
log: PositiveInt
|
|
13
|
-
});
|
|
14
|
-
const defaults = {
|
|
15
|
-
control: 8,
|
|
16
|
-
data: 16,
|
|
17
|
-
log: 2
|
|
18
|
-
};
|
|
19
|
-
// packages/remote/src/internal/port.ts
|
|
20
|
-
const Priority = Context.Reference("@graftland/plugin-remote/internal/port/Priority", { defaultValue: () => "data" });
|
|
21
|
-
var RequestKey = class extends Data.Class {};
|
|
22
|
-
const Frame = Schema.Struct({
|
|
23
|
-
session: Schema.String,
|
|
24
|
-
endpoint: Schema.String,
|
|
25
|
-
direction: Schema.Literals(["request", "response"]),
|
|
26
|
-
priority: Schema.Literals([
|
|
27
|
-
"control",
|
|
28
|
-
"data",
|
|
29
|
-
"log"
|
|
30
|
-
]),
|
|
31
|
-
message: Schema.Unknown
|
|
32
|
-
});
|
|
33
|
-
const Id = Schema.Union([Schema.String, Schema.Finite]);
|
|
34
|
-
const isRequest = Schema.is(Schema.Union([
|
|
35
|
-
Schema.TaggedStruct("Request", {
|
|
36
|
-
id: Id,
|
|
37
|
-
tag: Schema.String
|
|
38
|
-
}),
|
|
39
|
-
Schema.TaggedStruct("Ack", { requestId: Id }),
|
|
40
|
-
Schema.TaggedStruct("Interrupt", { requestId: Id }),
|
|
41
|
-
Schema.TaggedStruct("Eof", {})
|
|
42
|
-
]));
|
|
43
|
-
const isResponse = Schema.is(Schema.Union([
|
|
44
|
-
Schema.TaggedStruct("Exit", { requestId: Id }),
|
|
45
|
-
Schema.TaggedStruct("Chunk", { requestId: Id }),
|
|
46
|
-
Schema.TaggedStruct("Defect", { defect: Schema.Unknown })
|
|
47
|
-
]));
|
|
48
|
-
const Request = Schema.declare((input) => isRequest(input));
|
|
49
|
-
const Response = Schema.declare((input) => isResponse(input));
|
|
50
|
-
const error = (message) => TransportError.make({ cause: Cause.die(new Error(message)) });
|
|
51
|
-
const rpcError = (cause) => RpcClientError.RpcClientError.make({ reason: RpcClientError.RpcClientDefect.make({
|
|
52
|
-
message: "Remote connection failed",
|
|
53
|
-
cause
|
|
54
|
-
}) });
|
|
55
|
-
const priority = (group, tag) => {
|
|
56
|
-
const rpc = group.requests.get(tag);
|
|
57
|
-
return rpc === void 0 ? "data" : Context.get(rpc.annotations, Priority);
|
|
58
|
-
};
|
|
59
|
-
const mailbox = (priority) => Queue.dropping(2).pipe(Effect.map((queue) => ({
|
|
60
|
-
queue,
|
|
61
|
-
priority,
|
|
62
|
-
sent: false
|
|
63
|
-
})));
|
|
64
|
-
const deliver = Effect.fnUntraced(function* (requestState, message) {
|
|
65
|
-
if (!(yield* Queue.offer(requestState.queue, message))) return yield* error("RPC request mailbox overflow");
|
|
66
|
-
});
|
|
67
|
-
const initialize = Effect.fnUntraced(function* (bytes, options) {
|
|
68
|
-
return {
|
|
69
|
-
bytes,
|
|
70
|
-
options,
|
|
71
|
-
limits: {
|
|
72
|
-
...defaults,
|
|
73
|
-
...options.limits
|
|
74
|
-
},
|
|
75
|
-
workers: yield* make$1(),
|
|
76
|
-
incoming: yield* TxRef.make(HashMap.empty()),
|
|
77
|
-
outgoing: yield* TxRef.make(HashMap.empty()),
|
|
78
|
-
queues: {
|
|
79
|
-
control: yield* TxQueue.unbounded(),
|
|
80
|
-
data: yield* TxQueue.unbounded(),
|
|
81
|
-
log: yield* TxQueue.unbounded()
|
|
82
|
-
},
|
|
83
|
-
servers: yield* Effect.forEach(Record.toEntries(options.serve), Effect.fnUntraced(function* ([name, group]) {
|
|
84
|
-
return [name, {
|
|
85
|
-
group,
|
|
86
|
-
ready: yield* Deferred.make(),
|
|
87
|
-
disconnects: yield* Queue.dropping(1)
|
|
88
|
-
}];
|
|
89
|
-
})).pipe(Effect.map(HashMap.fromIterable)),
|
|
90
|
-
clients: yield* Effect.forEach(Record.toEntries(options.call), Effect.fnUntraced(function* ([name, group]) {
|
|
91
|
-
return [name, {
|
|
92
|
-
group,
|
|
93
|
-
ready: yield* Deferred.make()
|
|
94
|
-
}];
|
|
95
|
-
})).pipe(Effect.map(HashMap.fromIterable))
|
|
96
|
-
};
|
|
97
|
-
});
|
|
98
|
-
const admit = Effect.fnUntraced(function* (state, table, key, requestState, direction) {
|
|
99
|
-
yield* Effect.tx(Effect.gen(function* () {
|
|
100
|
-
yield* state.workers.check;
|
|
101
|
-
const current = yield* TxRef.get(table);
|
|
102
|
-
if (Array.filter(Array.fromIterable(HashMap.values(current)), (entry) => entry.priority === requestState.priority).length >= state.limits[requestState.priority]) {
|
|
103
|
-
if (direction === "outgoing") return yield* Effect.txRetry;
|
|
104
|
-
return yield* error(`RPC admission limit exceeded for ${requestState.priority}`);
|
|
105
|
-
}
|
|
106
|
-
yield* TxRef.set(table, HashMap.set(current, key, requestState));
|
|
107
|
-
}));
|
|
108
|
-
});
|
|
109
|
-
const remove = Effect.fnUntraced(function* (table, key, requestState) {
|
|
110
|
-
yield* TxRef.update(table, HashMap.remove(key));
|
|
111
|
-
yield* Queue.end(requestState.queue);
|
|
112
|
-
});
|
|
113
|
-
const enqueue = (state, frame, request = Option.none()) => Effect.tx(state.workers.check.pipe(Effect.andThen(TxQueue.offer(state.queues[frame.priority], {
|
|
114
|
-
frame,
|
|
115
|
-
request
|
|
116
|
-
}).pipe(Effect.flatMap((accepted) => accepted ? Effect.void : error("Remote output has ended")))), Effect.asVoid));
|
|
117
|
-
const frame = (state, endpoint, direction, p, message) => ({
|
|
118
|
-
session: state.options.session,
|
|
119
|
-
endpoint,
|
|
120
|
-
direction,
|
|
121
|
-
priority: p,
|
|
122
|
-
message
|
|
123
|
-
});
|
|
124
|
-
const send = Effect.fnUntraced(function* (state, effect) {
|
|
125
|
-
const fiber = yield* state.workers.run(state.workers.check.pipe(Effect.andThen(effect)));
|
|
126
|
-
const result = yield* Fiber.await(fiber).pipe(Effect.onInterrupt(() => Fiber.interrupt(fiber)));
|
|
127
|
-
yield* state.workers.check;
|
|
128
|
-
yield* result;
|
|
129
|
-
});
|
|
130
|
-
const cancel = Effect.fnUntraced(function* (state, key) {
|
|
131
|
-
const canceled = yield* Effect.tx(Effect.gen(function* () {
|
|
132
|
-
const table = yield* TxRef.get(state.outgoing);
|
|
133
|
-
const requestState = HashMap.get(table, key);
|
|
134
|
-
if (Option.isNone(requestState)) return Option.none();
|
|
135
|
-
if (requestState.value.sent) {
|
|
136
|
-
yield* enqueue(state, frame(state, key.endpoint, "request", "control", {
|
|
137
|
-
_tag: "Interrupt",
|
|
138
|
-
requestId: key.id
|
|
139
|
-
}));
|
|
140
|
-
return Option.none();
|
|
141
|
-
}
|
|
142
|
-
yield* TxRef.set(state.outgoing, HashMap.remove(table, key));
|
|
143
|
-
return requestState;
|
|
144
|
-
}));
|
|
145
|
-
if (Option.isSome(canceled)) yield* Queue.end(canceled.value.queue);
|
|
146
|
-
});
|
|
147
|
-
const clientProtocol = (state, endpoint) => {
|
|
148
|
-
const client = Option.getOrThrow(HashMap.get(state.clients, endpoint));
|
|
149
|
-
return RpcClient.Protocol.of({
|
|
150
|
-
codecFor: RpcSerialization.json.codecFor,
|
|
151
|
-
supportsAck: true,
|
|
152
|
-
supportsTransferables: false,
|
|
153
|
-
run: (_id, receive) => Deferred.succeed(client.ready, receive).pipe(Effect.andThen(state.workers.await), Effect.catchCause((cause) => receive({
|
|
154
|
-
_tag: "ClientProtocolError",
|
|
155
|
-
error: rpcError(cause)
|
|
156
|
-
})), Effect.andThen(Effect.never)),
|
|
157
|
-
send: (_id, message) => send(state, Effect.gen(function* () {
|
|
158
|
-
if (message._tag === "Request") {
|
|
159
|
-
if (message.discard === true || message.isNotification === true) return yield* error("Discard and notification requests are not supported");
|
|
160
|
-
const key = new RequestKey({
|
|
161
|
-
endpoint,
|
|
162
|
-
id: message.id
|
|
163
|
-
});
|
|
164
|
-
const requestState = yield* mailbox(priority(client.group, message.tag));
|
|
165
|
-
yield* admit(state, state.outgoing, key, requestState, "outgoing");
|
|
166
|
-
yield* state.workers.run(Stream.fromQueue(requestState.queue).pipe(Stream.runForEach(Effect.fnUntraced(function* (response) {
|
|
167
|
-
const receive = yield* Deferred.await(client.ready);
|
|
168
|
-
if (response._tag === "Exit") yield* remove(state.outgoing, key, requestState);
|
|
169
|
-
yield* receive(response);
|
|
170
|
-
}))));
|
|
171
|
-
yield* enqueue(state, frame(state, endpoint, "request", requestState.priority, message), Option.some(key));
|
|
172
|
-
} else if (message._tag === "Interrupt") yield* cancel(state, new RequestKey({
|
|
173
|
-
endpoint,
|
|
174
|
-
id: message.requestId
|
|
175
|
-
}));
|
|
176
|
-
else if (message._tag === "Ack") yield* enqueue(state, frame(state, endpoint, "request", "control", message));
|
|
177
|
-
})).pipe(Effect.mapError((failure) => rpcError(Cause.fail(failure))))
|
|
178
|
-
});
|
|
179
|
-
};
|
|
180
|
-
const serverProtocol = (state, endpoint) => {
|
|
181
|
-
const server = Option.getOrThrow(HashMap.get(state.servers, endpoint));
|
|
182
|
-
return RpcServer.Protocol.of({
|
|
183
|
-
codecFor: RpcSerialization.json.codecFor,
|
|
184
|
-
supportsAck: true,
|
|
185
|
-
supportsTransferables: false,
|
|
186
|
-
supportsSpanPropagation: false,
|
|
187
|
-
supportsNotifications: false,
|
|
188
|
-
clientIds: Effect.succeed(/* @__PURE__ */ new Set([0])),
|
|
189
|
-
initialMessage: Effect.succeedNone,
|
|
190
|
-
disconnects: server.disconnects,
|
|
191
|
-
end: () => Effect.void,
|
|
192
|
-
run: (receive) => Deferred.succeed(server.ready, receive).pipe(Effect.andThen(Effect.never)),
|
|
193
|
-
send: (_id, message) => send(state, Effect.gen(function* () {
|
|
194
|
-
if (message._tag === "Chunk" || message._tag === "Exit") {
|
|
195
|
-
const key = new RequestKey({
|
|
196
|
-
endpoint,
|
|
197
|
-
id: message.requestId
|
|
198
|
-
});
|
|
199
|
-
const requestState = yield* TxRef.get(state.incoming).pipe(Effect.map(HashMap.get(key)));
|
|
200
|
-
if (Option.isNone(requestState)) return;
|
|
201
|
-
yield* enqueue(state, frame(state, endpoint, "response", message._tag === "Exit" ? "control" : requestState.value.priority, message));
|
|
202
|
-
if (message._tag === "Exit") yield* remove(state.incoming, key, requestState.value);
|
|
203
|
-
} else yield* enqueue(state, frame(state, endpoint, "response", "control", message));
|
|
204
|
-
})).pipe(Effect.catchTag("TransportError", () => Effect.void))
|
|
205
|
-
});
|
|
206
|
-
};
|
|
207
|
-
const next = Effect.fnUntraced(function* (state) {
|
|
208
|
-
yield* state.workers.check;
|
|
209
|
-
for (const p of [
|
|
210
|
-
"control",
|
|
211
|
-
"data",
|
|
212
|
-
"log"
|
|
213
|
-
]) {
|
|
214
|
-
const pending = yield* TxQueue.poll(state.queues[p]);
|
|
215
|
-
if (Option.isNone(pending)) continue;
|
|
216
|
-
const { frame, request } = pending.value;
|
|
217
|
-
if (Option.isSome(request)) {
|
|
218
|
-
const table = yield* TxRef.get(state.outgoing);
|
|
219
|
-
const requestState = HashMap.get(table, request.value);
|
|
220
|
-
if (Option.isNone(requestState)) return Option.none();
|
|
221
|
-
yield* TxRef.set(state.outgoing, HashMap.set(table, request.value, {
|
|
222
|
-
...requestState.value,
|
|
223
|
-
sent: true
|
|
224
|
-
}));
|
|
225
|
-
}
|
|
226
|
-
return Option.some(frame);
|
|
227
|
-
}
|
|
228
|
-
if ((yield* TxQueue.isDone(state.queues.control)) && (yield* TxQueue.isDone(state.queues.data)) && (yield* TxQueue.isDone(state.queues.log))) return yield* Cause.done();
|
|
229
|
-
return yield* Effect.txRetry;
|
|
230
|
-
}, Effect.tx);
|
|
231
|
-
const writer = (state) => Stream.fromEffectRepeat(next(state)).pipe(Stream.filterMap(Result.fromOption(() => void 0)), Stream.mapEffect((frame) => Schema.encodeEffect(Schema.fromJsonString(Frame))(frame).pipe(Effect.mapError((cause) => TransportError.make({ cause: Cause.fail(cause) })))), Stream.map((json) => new TextEncoder().encode(json + "\n")), Stream.run(state.bytes.output));
|
|
232
|
-
const read = Effect.fnUntraced(function* (state, raw) {
|
|
233
|
-
const current = yield* Schema.decodeUnknownEffect(Frame)(raw).pipe(Effect.mapError((cause) => TransportError.make({ cause: Cause.fail(cause) })));
|
|
234
|
-
if (current.session !== state.options.session) return;
|
|
235
|
-
if (current.direction === "request") {
|
|
236
|
-
const server = HashMap.get(state.servers, current.endpoint);
|
|
237
|
-
if (Option.isNone(server)) return yield* error(`Unknown RPC server endpoint: ${current.endpoint}`);
|
|
238
|
-
const message = yield* Schema.decodeUnknownEffect(Request)(current.message).pipe(Effect.mapError((cause) => TransportError.make({ cause: Cause.fail(cause) })));
|
|
239
|
-
if (message._tag === "Eof") return yield* TransportError.make({ cause: Cause.fail(EndOfStream.make({})) });
|
|
240
|
-
const key = new RequestKey({
|
|
241
|
-
endpoint: current.endpoint,
|
|
242
|
-
id: message._tag === "Request" ? message.id : message.requestId
|
|
243
|
-
});
|
|
244
|
-
if (message._tag === "Request") {
|
|
245
|
-
const p = priority(server.value.group, message.tag);
|
|
246
|
-
const requestState = yield* mailbox(p);
|
|
247
|
-
yield* admit(state, state.incoming, key, requestState, "incoming");
|
|
248
|
-
yield* state.workers.run(Stream.fromQueue(requestState.queue).pipe(Stream.runForEach(Effect.fnUntraced(function* (request) {
|
|
249
|
-
yield* (yield* Deferred.await(server.value.ready))(0, request);
|
|
250
|
-
}))));
|
|
251
|
-
yield* deliver(requestState, message);
|
|
252
|
-
} else {
|
|
253
|
-
const requestState = yield* TxRef.get(state.incoming).pipe(Effect.map(HashMap.get(key)));
|
|
254
|
-
if (Option.isSome(requestState)) yield* deliver(requestState.value, message);
|
|
255
|
-
}
|
|
256
|
-
} else {
|
|
257
|
-
const message = yield* Schema.decodeUnknownEffect(Response)(current.message).pipe(Effect.mapError((cause) => TransportError.make({ cause: Cause.fail(cause) })));
|
|
258
|
-
if (message._tag === "Defect") return yield* TransportError.make({ cause: Cause.die(message.defect) });
|
|
259
|
-
const key = new RequestKey({
|
|
260
|
-
endpoint: current.endpoint,
|
|
261
|
-
id: message.requestId
|
|
262
|
-
});
|
|
263
|
-
const requestState = yield* TxRef.get(state.outgoing).pipe(Effect.map(HashMap.get(key)));
|
|
264
|
-
if (Option.isSome(requestState)) yield* deliver(requestState.value, message);
|
|
265
|
-
}
|
|
266
|
-
});
|
|
267
|
-
const reader = (state) => state.bytes.input.pipe(Stream.decodeText(), Stream.splitLines, Stream.filter((line) => line.length > 0), Stream.mapEffect((line) => Schema.decodeEffect(Schema.fromJsonString(Schema.Unknown))(line).pipe(Effect.mapError((cause) => TransportError.make({ cause: Cause.fail(cause) })))), Stream.runForEach((raw) => read(state, raw)), Effect.andThen(Effect.fail(TransportError.make({ cause: Cause.fail(EndOfStream.make({})) }))));
|
|
268
|
-
/** One RPC client/server per declared endpoint; servers may start after the port. */
|
|
269
|
-
const make = Effect.fnUntraced(function* (bytes, options) {
|
|
270
|
-
const state = yield* initialize(bytes, options);
|
|
271
|
-
yield* state.workers.await.pipe(Effect.catchCause(Effect.fnUntraced(function* () {
|
|
272
|
-
for (const server of HashMap.values(state.servers)) yield* Queue.offer(server.disconnects, 0);
|
|
273
|
-
yield* Effect.tx(TxRef.set(state.incoming, HashMap.empty()).pipe(Effect.andThen(TxRef.set(state.outgoing, HashMap.empty()))));
|
|
274
|
-
}, Effect.uninterruptible)), Effect.forkScoped);
|
|
275
|
-
const writing = yield* state.workers.run(writer(state));
|
|
276
|
-
yield* state.workers.run(reader(state));
|
|
277
|
-
return {
|
|
278
|
-
clientProtocol: (endpoint) => clientProtocol(state, endpoint),
|
|
279
|
-
serverProtocol: (endpoint) => serverProtocol(state, endpoint),
|
|
280
|
-
await: state.workers.await,
|
|
281
|
-
fail: state.workers.fail,
|
|
282
|
-
end: Effect.tx(Effect.forEach(Record.values(state.queues), TxQueue.end, { discard: true })).pipe(Effect.andThen(Fiber.join(writing)))
|
|
283
|
-
};
|
|
284
|
-
});
|
|
285
|
-
export { PositiveInt as a, PositiveFinite as i, make as n, defaults as o, Limits as r, Priority as t };
|
package/dist/release-DfZPuIcK.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Array, Cause, Effect, Exit, Result, Schema, Scope } from "effect";
|
|
2
|
-
// packages/remote/src/internal/release.ts
|
|
3
|
-
/** Resource release was interrupted, rather than successfully cancelled. */
|
|
4
|
-
var ReleaseInterrupted = class extends Schema.TaggedError()("ReleaseInterrupted", { cause: Schema.Cause(Schema.Never, Schema.Unknown) }) {
|
|
5
|
-
get message() {
|
|
6
|
-
return "Resource release was interrupted";
|
|
7
|
-
}
|
|
8
|
-
};
|
|
9
|
-
/** Keep a known release failure distinguishable from cancellation through enclosing scopes. */
|
|
10
|
-
const close = (scope, exit) => Effect.uninterruptible(Scope.close(scope, exit).pipe(Effect.catchCauseIf(Cause.hasInterruptsOnly, Effect.fnUntraced(function* (cause) {
|
|
11
|
-
const pending = yield* Effect.exit(Effect.interruptible(Effect.void));
|
|
12
|
-
const [cancelled, interrupted] = Array.partition(cause.reasons, (reason) => Exit.isFailure(pending) && Array.some(pending.cause.reasons, (external) => reason._tag === "Interrupt" && external._tag === "Interrupt" && reason.fiberId === external.fiberId) ? Result.succeed(reason) : Result.fail(reason));
|
|
13
|
-
if (interrupted.length === 0) return yield* Effect.failCause(cause);
|
|
14
|
-
return yield* Effect.failCause(Cause.combine(Cause.fromReasons(cancelled), Cause.die(ReleaseInterrupted.make({ cause: Cause.fromReasons(interrupted) }))));
|
|
15
|
-
}))));
|
|
16
|
-
const scoped = (effect) => Effect.uninterruptibleMask((restore) => Effect.gen(function* () {
|
|
17
|
-
const scope = yield* Scope.make();
|
|
18
|
-
const body = yield* Effect.exit(restore(Scope.provide(scope)(effect)));
|
|
19
|
-
const closed = yield* Effect.exit(close(scope, body));
|
|
20
|
-
if (Exit.isFailure(closed)) return yield* Effect.failCause(Exit.isFailure(body) ? Cause.combine(body.cause, closed.cause) : closed.cause);
|
|
21
|
-
return yield* body;
|
|
22
|
-
}));
|
|
23
|
-
export { close as n, scoped as r, ReleaseInterrupted as t };
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
// \0rolldown/runtime.js
|
|
3
|
-
var __create = Object.create;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod, mod.exports), cb = null), mod.exports);
|
|
10
|
-
var __exportAll = (all, no_symbols) => {
|
|
11
|
-
let target = {};
|
|
12
|
-
for (var name in all) __defProp(target, name, {
|
|
13
|
-
get: all[name],
|
|
14
|
-
enumerable: true
|
|
15
|
-
});
|
|
16
|
-
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
17
|
-
return target;
|
|
18
|
-
};
|
|
19
|
-
var __copyProps = (to, from, except, desc) => {
|
|
20
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
21
|
-
key = keys[i];
|
|
22
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
23
|
-
get: ((k) => from[k]).bind(null, key),
|
|
24
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
return to;
|
|
28
|
-
};
|
|
29
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
30
|
-
value: mod,
|
|
31
|
-
enumerable: true
|
|
32
|
-
}) : target, mod));
|
|
33
|
-
var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
|
|
34
|
-
export { __toESM as i, __exportAll as n, __require as r, __commonJSMin as t };
|