@kylewillett/troupe 0.1.0 → 0.2.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/CHANGELOG.md +21 -2
- package/README.md +132 -2
- package/dist/ask.d.ts +5 -1
- package/dist/ask.js +16 -0
- package/dist/backstage/index.d.ts +2 -1
- package/dist/backstage/index.js +1 -0
- package/dist/backstage/source.d.ts +1 -1
- package/dist/backstage/source.js +65 -2
- package/dist/backstage/types.d.ts +65 -4
- package/dist/backstage/types.js +2 -1
- package/dist/backstage-ui/assets/index-CG896RLZ.css +1 -0
- package/dist/backstage-ui/assets/index-DF_Xnc1u.js +9 -0
- package/dist/backstage-ui/index.html +2 -2
- package/dist/cell.d.ts +16 -14
- package/dist/cell.js +38 -13
- package/dist/checks.d.ts +10 -0
- package/dist/checks.js +34 -2
- package/dist/cluster/index.d.ts +6 -0
- package/dist/cluster/index.js +4 -0
- package/dist/cluster/leases.d.ts +37 -0
- package/dist/cluster/leases.js +132 -0
- package/dist/cluster/membership.d.ts +100 -0
- package/dist/cluster/membership.js +559 -0
- package/dist/cluster/memory.d.ts +31 -0
- package/dist/cluster/memory.js +187 -0
- package/dist/cluster/placement.d.ts +10 -0
- package/dist/cluster/placement.js +30 -0
- package/dist/cluster/postgres/index.d.ts +1 -0
- package/dist/cluster/postgres/index.js +3 -0
- package/dist/cluster/postgres/schema.d.ts +7 -0
- package/dist/cluster/postgres/schema.js +33 -0
- package/dist/cluster/postgres/schema.sql +18 -0
- package/dist/cluster/postgres/store.d.ts +28 -0
- package/dist/cluster/postgres/store.js +124 -0
- package/dist/cluster/region.d.ts +103 -0
- package/dist/cluster/region.js +843 -0
- package/dist/cluster/remoting.d.ts +79 -0
- package/dist/cluster/remoting.js +755 -0
- package/dist/cluster/shard-memory.d.ts +14 -0
- package/dist/cluster/shard-memory.js +92 -0
- package/dist/cluster/shard-store.d.ts +62 -0
- package/dist/cluster/shard-store.js +36 -0
- package/dist/cluster/shard.d.ts +54 -0
- package/dist/cluster/shard.js +278 -0
- package/dist/cluster/sharding.d.ts +109 -0
- package/dist/cluster/sharding.js +278 -0
- package/dist/cluster/table.d.ts +29 -0
- package/dist/cluster/table.js +74 -0
- package/dist/cluster/transport.d.ts +29 -0
- package/dist/cluster/transport.js +4 -0
- package/dist/cluster/wire.d.ts +90 -0
- package/dist/cluster/wire.js +177 -0
- package/dist/hash.d.ts +7 -0
- package/dist/hash.js +25 -0
- package/dist/internal.d.ts +134 -2
- package/dist/internal.js +12 -1
- package/dist/json.d.ts +44 -0
- package/dist/json.js +143 -0
- package/dist/node/cluster/frames.d.ts +31 -0
- package/dist/node/cluster/frames.js +73 -0
- package/dist/node/cluster/index.d.ts +1 -0
- package/dist/node/cluster/index.js +3 -0
- package/dist/node/cluster/tcp.d.ts +101 -0
- package/dist/node/cluster/tcp.js +416 -0
- package/dist/persistence/actor.js +1 -1
- package/dist/persistence/backend.d.ts +1 -10
- package/dist/persistence/backend.js +4 -34
- package/dist/persistence/postgres/index.d.ts +2 -1
- package/dist/persistence/postgres/index.js +1 -1
- package/dist/persistence/postgres/pool.d.ts +44 -0
- package/dist/persistence/postgres/pool.js +65 -0
- package/dist/persistence/postgres/postgres.d.ts +1 -33
- package/dist/persistence/postgres/postgres.js +4 -63
- package/dist/system.d.ts +1 -1
- package/dist/system.js +190 -24
- package/dist/types.d.ts +86 -3
- package/package.json +25 -4
- package/dist/backstage-ui/assets/index-Bg0MCiqs.css +0 -1
- package/dist/backstage-ui/assets/index-CeefBsDh.js +0 -9
- package/dist/persistence/json.d.ts +0 -7
- package/dist/persistence/json.js +0 -75
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { ActorSystem, AnyRef } from '../types.js';
|
|
2
|
+
import type { Transport } from './transport.js';
|
|
3
|
+
import { type Codec, type EntityRefs, type NodeId } from './wire.js';
|
|
4
|
+
/** The remoting protocol's version, in every hello. A peer on another version is refused. */
|
|
5
|
+
export declare const PROTOCOL = 1;
|
|
6
|
+
/** Options for {@link startRemoting}. */
|
|
7
|
+
export interface RemotingOptions {
|
|
8
|
+
/** The cluster's name, which every node shares: lower-case letters, digits and `-`. */
|
|
9
|
+
cluster: string;
|
|
10
|
+
/** How this node reaches the others. Its `address` is this node's. */
|
|
11
|
+
transport: Transport;
|
|
12
|
+
/** How many messages wait for a peer that has no connection. Default 10,000. */
|
|
13
|
+
bufferSize?: number;
|
|
14
|
+
/** The largest frame remoting sends, in UTF-8 bytes. Default 1 MiB. */
|
|
15
|
+
maxFrameBytes?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Whether remoting closes by itself once the system has terminated. Default true. The cluster
|
|
18
|
+
* turns it off, so it can say goodbye first and close remoting itself (decision 0028).
|
|
19
|
+
*/
|
|
20
|
+
closeWithSystem?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** A peer's incarnation, as its hello named it. */
|
|
23
|
+
export interface PeerId {
|
|
24
|
+
readonly address: string;
|
|
25
|
+
readonly uid: number;
|
|
26
|
+
}
|
|
27
|
+
/** What a control frame's handler gets: who sent it, and the frame, parsed. */
|
|
28
|
+
export type ControlHandler = (from: PeerId, frame: Readonly<Record<string, unknown>>) => void;
|
|
29
|
+
/** Remoting for one node. */
|
|
30
|
+
export interface Remoting {
|
|
31
|
+
/** This node: the cluster, its address, and its uid, drawn from the system's `random`. */
|
|
32
|
+
readonly self: NodeId;
|
|
33
|
+
/** The codec for messages to and from this node (decision 0025). */
|
|
34
|
+
readonly codec: Codec;
|
|
35
|
+
/** Resolves once the transport is listening. */
|
|
36
|
+
readonly whenListening: Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* The ref a ref URI decodes to on this node: a local actor, a dead ref, or a remote ref.
|
|
39
|
+
* @throws TypeError if `uri` isn't a ref URI in this cluster.
|
|
40
|
+
*/
|
|
41
|
+
ref(uri: string): AnyRef;
|
|
42
|
+
/**
|
|
43
|
+
* The node at `address` is down, from membership (decision 0028). Its buffered messages become
|
|
44
|
+
* `unreachable` dead letters, as does everything sent to it later, every watch on it signals
|
|
45
|
+
* `terminated`, and its incarnation can't connect again. A new uid at the address can. With
|
|
46
|
+
* `uid`, only that incarnation goes: if remoting already knows a newer one at the address, only
|
|
47
|
+
* the old one's watches end. When the downed incarnation dials again, it's sent a `downed`
|
|
48
|
+
* frame before it's refused, so it can learn that it's down.
|
|
49
|
+
*/
|
|
50
|
+
nodeDown(address: string, uid?: number): void;
|
|
51
|
+
/**
|
|
52
|
+
* Sends a control frame to `address` if a connection is open, and returns true. Otherwise it
|
|
53
|
+
* starts a dial, drops the frame and returns false: membership's frames are sent again on its
|
|
54
|
+
* next tick, so waiting for a connection would only deliver stale ones.
|
|
55
|
+
*/
|
|
56
|
+
signal(address: string, frame: Readonly<Record<string, unknown>>): boolean;
|
|
57
|
+
/** Handles frames whose type remoting doesn't know, such as membership's. One handler. */
|
|
58
|
+
onControl(handler: ControlHandler): void;
|
|
59
|
+
/** Called with each peer incarnation once a connection to it is established. One handler. */
|
|
60
|
+
onPeer(handler: (peer: PeerId) => void): void;
|
|
61
|
+
/** Gives the codec sharding's entity refs (decision 0030). Once. */
|
|
62
|
+
setEntities(refs: EntityRefs): void;
|
|
63
|
+
/**
|
|
64
|
+
* Closes the transport. Everything sent afterwards is a `terminated` dead letter. Runs by
|
|
65
|
+
* itself once the system has terminated.
|
|
66
|
+
*/
|
|
67
|
+
close(): Promise<void>;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Starts remoting on `system`: listens on the transport, and makes refs to other nodes' actors
|
|
71
|
+
* work as local ones do.
|
|
72
|
+
* @throws TypeError for options that can't be used.
|
|
73
|
+
* @throws Error if the system already has remoting.
|
|
74
|
+
*/
|
|
75
|
+
export declare function startRemoting(system: ActorSystem, opts: RemotingOptions): Remoting;
|
|
76
|
+
/** Whether `value` has a transport's shape. */
|
|
77
|
+
export declare function isTransport(value: unknown): value is Transport;
|
|
78
|
+
/** The UTF-8 length of `text`, without allocating. Lone surrogates count as the 3 bytes of U+FFFD. */
|
|
79
|
+
export declare function utf8Bytes(text: string): number;
|