rivetkit 2.0.5 → 2.0.7-rc.1

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.
Files changed (178) hide show
  1. package/dist/schemas/actor-persist/v1.ts +0 -6
  2. package/dist/tsup/actor-router-consts-B3Lu87yJ.d.cts +28 -0
  3. package/dist/tsup/actor-router-consts-B3Lu87yJ.d.ts +28 -0
  4. package/dist/tsup/{chunk-5YTI25C3.cjs → chunk-3MBP4WNC.cjs} +7 -7
  5. package/dist/tsup/{chunk-5YTI25C3.cjs.map → chunk-3MBP4WNC.cjs.map} +1 -1
  6. package/dist/tsup/chunk-3Y45CIF4.cjs +3726 -0
  7. package/dist/tsup/chunk-3Y45CIF4.cjs.map +1 -0
  8. package/dist/tsup/chunk-4GP7BZSR.js +102 -0
  9. package/dist/tsup/chunk-4GP7BZSR.js.map +1 -0
  10. package/dist/tsup/chunk-5ZOHIKWG.cjs +4071 -0
  11. package/dist/tsup/chunk-5ZOHIKWG.cjs.map +1 -0
  12. package/dist/tsup/{chunk-WADSS5X4.cjs → chunk-6EUWRXLT.cjs} +21 -7
  13. package/dist/tsup/chunk-6EUWRXLT.cjs.map +1 -0
  14. package/dist/tsup/{chunk-D7NWUCRK.cjs → chunk-6OVKCDSH.cjs} +6 -6
  15. package/dist/tsup/{chunk-D7NWUCRK.cjs.map → chunk-6OVKCDSH.cjs.map} +1 -1
  16. package/dist/tsup/{chunk-I5VTWPHW.js → chunk-7N56ZUC7.js} +3 -3
  17. package/dist/tsup/{chunk-LZIBTLEY.cjs → chunk-B3TLRM4Q.cjs} +13 -25
  18. package/dist/tsup/chunk-B3TLRM4Q.cjs.map +1 -0
  19. package/dist/tsup/chunk-BW5DPM6Z.js +4071 -0
  20. package/dist/tsup/chunk-BW5DPM6Z.js.map +1 -0
  21. package/dist/tsup/chunk-DFS77KAA.cjs +1046 -0
  22. package/dist/tsup/chunk-DFS77KAA.cjs.map +1 -0
  23. package/dist/tsup/{chunk-PG3K2LI7.js → chunk-E4UVJKSV.js} +2 -2
  24. package/dist/tsup/chunk-G4ABMAQY.cjs +102 -0
  25. package/dist/tsup/chunk-G4ABMAQY.cjs.map +1 -0
  26. package/dist/tsup/{chunk-CKA54YQN.js → chunk-GZVBFXBI.js} +3 -15
  27. package/dist/tsup/chunk-GZVBFXBI.js.map +1 -0
  28. package/dist/tsup/chunk-HPT3I7UU.js +3726 -0
  29. package/dist/tsup/chunk-HPT3I7UU.js.map +1 -0
  30. package/dist/tsup/chunk-JD54PXWP.js +1046 -0
  31. package/dist/tsup/chunk-JD54PXWP.js.map +1 -0
  32. package/dist/tsup/{chunk-PHSQJ6QI.cjs → chunk-K4ENQCC4.cjs} +3 -3
  33. package/dist/tsup/{chunk-PHSQJ6QI.cjs.map → chunk-K4ENQCC4.cjs.map} +1 -1
  34. package/dist/tsup/{chunk-WNGOBAA7.js → chunk-PUSQNDJG.js} +2 -2
  35. package/dist/tsup/{chunk-CFFKMUYH.js → chunk-RVP5RUSC.js} +20 -6
  36. package/dist/tsup/chunk-RVP5RUSC.js.map +1 -0
  37. package/dist/tsup/chunk-SAZCNSVY.cjs +259 -0
  38. package/dist/tsup/chunk-SAZCNSVY.cjs.map +1 -0
  39. package/dist/tsup/{chunk-YW6Y6VNE.js → chunk-SBKRVQS2.js} +9 -5
  40. package/dist/tsup/chunk-SBKRVQS2.js.map +1 -0
  41. package/dist/tsup/{chunk-FGFT4FVX.cjs → chunk-TZGUSEIJ.cjs} +14 -10
  42. package/dist/tsup/chunk-TZGUSEIJ.cjs.map +1 -0
  43. package/dist/tsup/chunk-YQ4XQYPM.js +259 -0
  44. package/dist/tsup/chunk-YQ4XQYPM.js.map +1 -0
  45. package/dist/tsup/client/mod.cjs +9 -9
  46. package/dist/tsup/client/mod.d.cts +7 -8
  47. package/dist/tsup/client/mod.d.ts +7 -8
  48. package/dist/tsup/client/mod.js +8 -8
  49. package/dist/tsup/common/log.cjs +3 -3
  50. package/dist/tsup/common/log.js +2 -2
  51. package/dist/tsup/common/websocket.cjs +4 -4
  52. package/dist/tsup/common/websocket.js +3 -3
  53. package/dist/tsup/{connection-BvE-Oq7t.d.ts → conn-DCSQgIlw.d.ts} +1605 -1353
  54. package/dist/tsup/{connection-DTzmWwU5.d.cts → conn-DdzHTm2E.d.cts} +1605 -1353
  55. package/dist/tsup/driver-helpers/mod.cjs +31 -5
  56. package/dist/tsup/driver-helpers/mod.cjs.map +1 -1
  57. package/dist/tsup/driver-helpers/mod.d.cts +7 -8
  58. package/dist/tsup/driver-helpers/mod.d.ts +7 -8
  59. package/dist/tsup/driver-helpers/mod.js +33 -7
  60. package/dist/tsup/driver-test-suite/mod.cjs +319 -216
  61. package/dist/tsup/driver-test-suite/mod.cjs.map +1 -1
  62. package/dist/tsup/driver-test-suite/mod.d.cts +7 -7
  63. package/dist/tsup/driver-test-suite/mod.d.ts +7 -7
  64. package/dist/tsup/driver-test-suite/mod.js +588 -485
  65. package/dist/tsup/driver-test-suite/mod.js.map +1 -1
  66. package/dist/tsup/inspector/mod.cjs +17 -5
  67. package/dist/tsup/inspector/mod.cjs.map +1 -1
  68. package/dist/tsup/inspector/mod.d.cts +34 -7
  69. package/dist/tsup/inspector/mod.d.ts +34 -7
  70. package/dist/tsup/inspector/mod.js +20 -8
  71. package/dist/tsup/mod.cjs +10 -17
  72. package/dist/tsup/mod.cjs.map +1 -1
  73. package/dist/tsup/mod.d.cts +56 -9
  74. package/dist/tsup/mod.d.ts +56 -9
  75. package/dist/tsup/mod.js +17 -24
  76. package/dist/tsup/test/mod.cjs +11 -9
  77. package/dist/tsup/test/mod.cjs.map +1 -1
  78. package/dist/tsup/test/mod.d.cts +6 -7
  79. package/dist/tsup/test/mod.d.ts +6 -7
  80. package/dist/tsup/test/mod.js +10 -8
  81. package/dist/tsup/utils.cjs +4 -2
  82. package/dist/tsup/utils.cjs.map +1 -1
  83. package/dist/tsup/utils.d.cts +11 -1
  84. package/dist/tsup/utils.d.ts +11 -1
  85. package/dist/tsup/utils.js +3 -1
  86. package/package.json +8 -4
  87. package/src/actor/action.ts +1 -1
  88. package/src/actor/config.ts +1 -1
  89. package/src/actor/conn-drivers.ts +205 -0
  90. package/src/actor/conn-socket.ts +6 -0
  91. package/src/actor/{connection.ts → conn.ts} +78 -84
  92. package/src/actor/context.ts +1 -1
  93. package/src/actor/driver.ts +4 -43
  94. package/src/actor/instance.ts +162 -86
  95. package/src/actor/mod.ts +6 -14
  96. package/src/actor/persisted.ts +2 -5
  97. package/src/actor/protocol/old.ts +1 -1
  98. package/src/actor/router-endpoints.ts +147 -138
  99. package/src/actor/router.ts +89 -52
  100. package/src/actor/utils.ts +5 -1
  101. package/src/client/actor-conn.ts +163 -31
  102. package/src/client/actor-handle.ts +0 -1
  103. package/src/client/client.ts +2 -2
  104. package/src/client/config.ts +7 -0
  105. package/src/client/raw-utils.ts +1 -1
  106. package/src/client/utils.ts +1 -1
  107. package/src/common/actor-router-consts.ts +59 -0
  108. package/src/common/router.ts +2 -1
  109. package/src/common/versioned-data.ts +5 -5
  110. package/src/driver-helpers/mod.ts +15 -2
  111. package/src/driver-test-suite/mod.ts +11 -2
  112. package/src/driver-test-suite/test-inline-client-driver.ts +40 -22
  113. package/src/driver-test-suite/tests/actor-conn-state.ts +66 -22
  114. package/src/driver-test-suite/tests/actor-conn.ts +65 -126
  115. package/src/driver-test-suite/tests/actor-reconnect.ts +160 -0
  116. package/src/driver-test-suite/tests/actor-sleep.ts +0 -1
  117. package/src/driver-test-suite/tests/raw-websocket.ts +0 -35
  118. package/src/driver-test-suite/utils.ts +8 -3
  119. package/src/drivers/default.ts +8 -7
  120. package/src/drivers/engine/actor-driver.ts +67 -44
  121. package/src/drivers/engine/config.ts +4 -0
  122. package/src/drivers/file-system/actor.ts +0 -6
  123. package/src/drivers/file-system/global-state.ts +3 -14
  124. package/src/drivers/file-system/manager.ts +12 -8
  125. package/src/inspector/actor.ts +4 -3
  126. package/src/inspector/config.ts +10 -1
  127. package/src/inspector/mod.ts +1 -0
  128. package/src/inspector/utils.ts +23 -4
  129. package/src/manager/driver.ts +12 -2
  130. package/src/manager/gateway.ts +407 -0
  131. package/src/manager/protocol/query.ts +1 -1
  132. package/src/manager/router.ts +269 -468
  133. package/src/manager-api/actors.ts +61 -0
  134. package/src/manager-api/common.ts +4 -0
  135. package/src/mod.ts +1 -1
  136. package/src/registry/mod.ts +126 -12
  137. package/src/registry/serve.ts +8 -3
  138. package/src/remote-manager-driver/actor-http-client.ts +30 -19
  139. package/src/remote-manager-driver/actor-websocket-client.ts +45 -18
  140. package/src/remote-manager-driver/api-endpoints.ts +19 -21
  141. package/src/remote-manager-driver/api-utils.ts +10 -1
  142. package/src/remote-manager-driver/mod.ts +53 -53
  143. package/src/remote-manager-driver/ws-proxy.ts +2 -9
  144. package/src/test/mod.ts +6 -2
  145. package/src/utils.ts +21 -2
  146. package/dist/tsup/chunk-2MD57QF4.js +0 -1794
  147. package/dist/tsup/chunk-2MD57QF4.js.map +0 -1
  148. package/dist/tsup/chunk-B2QGJGZQ.js +0 -338
  149. package/dist/tsup/chunk-B2QGJGZQ.js.map +0 -1
  150. package/dist/tsup/chunk-CFFKMUYH.js.map +0 -1
  151. package/dist/tsup/chunk-CKA54YQN.js.map +0 -1
  152. package/dist/tsup/chunk-FGFT4FVX.cjs.map +0 -1
  153. package/dist/tsup/chunk-IRMBWX36.cjs +0 -1794
  154. package/dist/tsup/chunk-IRMBWX36.cjs.map +0 -1
  155. package/dist/tsup/chunk-L7QRXNWP.js +0 -6562
  156. package/dist/tsup/chunk-L7QRXNWP.js.map +0 -1
  157. package/dist/tsup/chunk-LZIBTLEY.cjs.map +0 -1
  158. package/dist/tsup/chunk-MRZS2J4X.cjs +0 -6562
  159. package/dist/tsup/chunk-MRZS2J4X.cjs.map +0 -1
  160. package/dist/tsup/chunk-RM2SVURR.cjs +0 -338
  161. package/dist/tsup/chunk-RM2SVURR.cjs.map +0 -1
  162. package/dist/tsup/chunk-WADSS5X4.cjs.map +0 -1
  163. package/dist/tsup/chunk-YW6Y6VNE.js.map +0 -1
  164. package/dist/tsup/common-CXCe7s6i.d.cts +0 -218
  165. package/dist/tsup/common-CXCe7s6i.d.ts +0 -218
  166. package/dist/tsup/router-endpoints-CctffZNL.d.cts +0 -65
  167. package/dist/tsup/router-endpoints-DFm1BglJ.d.ts +0 -65
  168. package/src/actor/generic-conn-driver.ts +0 -246
  169. package/src/common/fake-event-source.ts +0 -267
  170. package/src/manager-api/routes/actors-create.ts +0 -16
  171. package/src/manager-api/routes/actors-delete.ts +0 -4
  172. package/src/manager-api/routes/actors-get-by-id.ts +0 -7
  173. package/src/manager-api/routes/actors-get-or-create-by-id.ts +0 -29
  174. package/src/manager-api/routes/actors-get.ts +0 -7
  175. package/src/manager-api/routes/common.ts +0 -18
  176. /package/dist/tsup/{chunk-I5VTWPHW.js.map → chunk-7N56ZUC7.js.map} +0 -0
  177. /package/dist/tsup/{chunk-PG3K2LI7.js.map → chunk-E4UVJKSV.js.map} +0 -0
  178. /package/dist/tsup/{chunk-WNGOBAA7.js.map → chunk-PUSQNDJG.js.map} +0 -0
@@ -1,12 +1,19 @@
1
1
  import * as cbor from "cbor-x";
2
+ import invariant from "invariant";
2
3
  import type * as protocol from "@/schemas/client-protocol/mod";
3
4
  import { TO_CLIENT_VERSIONED } from "@/schemas/client-protocol/versioned";
4
5
  import { bufferToArrayBuffer } from "@/utils";
6
+ import {
7
+ CONN_DRIVERS,
8
+ ConnDriverKind,
9
+ type ConnDriverState,
10
+ ConnReadyState,
11
+ getConnDriverKindFromState,
12
+ } from "./conn-drivers";
13
+ import type { ConnSocket } from "./conn-socket";
5
14
  import type { AnyDatabaseProvider } from "./database";
6
- import { type ConnDriver, ConnectionReadyState } from "./driver";
7
15
  import * as errors from "./errors";
8
16
  import type { ActorInstance } from "./instance";
9
- import { loggerWithoutContext } from "./log";
10
17
  import type { PersistedConn } from "./persisted";
11
18
  import { CachedSerializer } from "./protocol/serde";
12
19
  import { generateSecureToken } from "./utils";
@@ -19,23 +26,16 @@ export function generateConnToken(): string {
19
26
  return generateSecureToken(32);
20
27
  }
21
28
 
29
+ export function generateConnSocketId(): string {
30
+ return crypto.randomUUID();
31
+ }
32
+
22
33
  export type ConnId = string;
23
34
 
24
35
  export type AnyConn = Conn<any, any, any, any, any, any>;
25
36
 
26
- export const CONNECTION_DRIVER_WEBSOCKET = "webSocket";
27
- export const CONNECTION_DRIVER_SSE = "sse";
28
- export const CONNECTION_DRIVER_HTTP = "http";
29
-
30
- export type ConnectionDriver =
31
- | typeof CONNECTION_DRIVER_WEBSOCKET
32
- | typeof CONNECTION_DRIVER_SSE
33
- | typeof CONNECTION_DRIVER_HTTP;
34
-
35
37
  export type ConnectionStatus = "connected" | "reconnecting";
36
38
 
37
- export const CONNECTION_CHECK_LIVENESS_SYMBOL = Symbol("checkLiveness");
38
-
39
39
  /**
40
40
  * Represents a client connection to a actor.
41
41
  *
@@ -46,13 +46,9 @@ export const CONNECTION_CHECK_LIVENESS_SYMBOL = Symbol("checkLiveness");
46
46
  export class Conn<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
47
47
  subscriptions: Set<string> = new Set<string>();
48
48
 
49
- #stateEnabled: boolean;
50
-
51
49
  // TODO: Remove this cyclical reference
52
50
  #actor: ActorInstance<S, CP, CS, V, I, DB>;
53
51
 
54
- #status: ConnectionStatus = "connected";
55
-
56
52
  /**
57
53
  * The proxied state that notifies of changes automatically.
58
54
  *
@@ -60,23 +56,31 @@ export class Conn<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
60
56
  */
61
57
  __persist: PersistedConn<CP, CS>;
62
58
 
59
+ get __driverState(): ConnDriverState | undefined {
60
+ return this.__socket?.driverState;
61
+ }
62
+
63
63
  /**
64
- * Driver used to manage realtime connection communication.
64
+ * Socket connected to this connection.
65
65
  *
66
- * @protected
66
+ * If undefined, then nothing is connected to this.
67
67
  */
68
- #driver: ConnDriver;
68
+ __socket?: ConnSocket;
69
69
 
70
- public get params(): CP {
71
- return this.__persist.params;
70
+ get __status(): ConnectionStatus {
71
+ if (this.__socket) {
72
+ return "connected";
73
+ } else {
74
+ return "reconnecting";
75
+ }
72
76
  }
73
77
 
74
- public get driver(): ConnectionDriver {
75
- return this.__persist.connDriver as ConnectionDriver;
78
+ public get params(): CP {
79
+ return this.__persist.params;
76
80
  }
77
81
 
78
- public get _stateEnabled() {
79
- return this.#stateEnabled;
82
+ public get __stateEnabled() {
83
+ return this.#actor.connStateEnabled;
80
84
  }
81
85
 
82
86
  /**
@@ -118,7 +122,7 @@ export class Conn<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
118
122
  * Status of the connection.
119
123
  */
120
124
  public get status(): ConnectionStatus {
121
- return this.#status;
125
+ return this.__status;
122
126
  }
123
127
 
124
128
  /**
@@ -138,17 +142,13 @@ export class Conn<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
138
142
  public constructor(
139
143
  actor: ActorInstance<S, CP, CS, V, I, DB>,
140
144
  persist: PersistedConn<CP, CS>,
141
- driver: ConnDriver,
142
- stateEnabled: boolean,
143
145
  ) {
144
146
  this.#actor = actor;
145
147
  this.__persist = persist;
146
- this.#driver = driver;
147
- this.#stateEnabled = stateEnabled;
148
148
  }
149
149
 
150
150
  #validateStateEnabled() {
151
- if (!this.#stateEnabled) {
151
+ if (!this.__stateEnabled) {
152
152
  throw new errors.ConnStateNotEnabled();
153
153
  }
154
154
  }
@@ -161,12 +161,28 @@ export class Conn<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
161
161
  * @protected
162
162
  */
163
163
  public _sendMessage(message: CachedSerializer<protocol.ToClient>) {
164
- this.#driver.sendMessage?.(
165
- this.#actor,
166
- this,
167
- this.__persist.connDriverState,
168
- message,
169
- );
164
+ if (this.__driverState) {
165
+ const driverKind = getConnDriverKindFromState(this.__driverState);
166
+ const driver = CONN_DRIVERS[driverKind];
167
+ if (driver.sendMessage) {
168
+ driver.sendMessage(
169
+ this.#actor,
170
+ this,
171
+ (this.__driverState as any)[driverKind],
172
+ message,
173
+ );
174
+ } else {
175
+ this.#actor.rLog.debug({
176
+ msg: "conn driver does not support sending messages",
177
+ conn: this.id,
178
+ });
179
+ }
180
+ } else {
181
+ this.#actor.rLog.warn({
182
+ msg: "missing connection driver state for send message",
183
+ conn: this.id,
184
+ });
185
+ }
170
186
  }
171
187
 
172
188
  /**
@@ -205,53 +221,31 @@ export class Conn<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
205
221
  * @param reason - The reason for disconnection.
206
222
  */
207
223
  public async disconnect(reason?: string) {
208
- this.#status = "reconnecting";
209
- await this.#driver.disconnect(
210
- this.#actor,
211
- this,
212
- this.__persist.connDriverState,
213
- reason,
214
- );
215
- }
216
-
217
- /**
218
- * This method checks the connection's liveness by querying the driver for its ready state.
219
- * If the connection is not closed, it updates the last liveness timestamp and returns `true`.
220
- * Otherwise, it returns `false`.
221
- * @internal
222
- */
223
- [CONNECTION_CHECK_LIVENESS_SYMBOL]() {
224
- const readyState = this.#driver.getConnectionReadyState(this.#actor, this);
225
-
226
- const isConnectionClosed =
227
- readyState === ConnectionReadyState.CLOSED ||
228
- readyState === ConnectionReadyState.CLOSING ||
229
- readyState === undefined;
230
-
231
- const newLastSeen = Date.now();
232
- const newStatus = isConnectionClosed ? "reconnecting" : "connected";
233
-
234
- this.#actor.rLog.debug({
235
- msg: "liveness probe for connection",
236
- connId: this.id,
237
- actorId: this.#actor.id,
238
- readyState,
239
-
240
- status: this.#status,
241
- newStatus,
242
-
243
- lastSeen: this.__persist.lastSeen,
244
- currentTs: newLastSeen,
245
- });
246
-
247
- if (!isConnectionClosed) {
248
- this.__persist.lastSeen = newLastSeen;
224
+ if (this.__socket && this.__driverState) {
225
+ const driverKind = getConnDriverKindFromState(this.__driverState);
226
+ const driver = CONN_DRIVERS[driverKind];
227
+ if (driver.disconnect) {
228
+ driver.disconnect(
229
+ this.#actor,
230
+ this,
231
+ (this.__driverState as any)[driverKind],
232
+ reason,
233
+ );
234
+ } else {
235
+ this.#actor.rLog.debug({
236
+ msg: "no disconnect handler for conn driver",
237
+ conn: this.id,
238
+ });
239
+ }
240
+
241
+ this.#actor.__connDisconnected(this, true, this.__socket.socketId);
242
+ } else {
243
+ this.#actor.rLog.warn({
244
+ msg: "missing connection driver state for disconnect",
245
+ conn: this.id,
246
+ });
249
247
  }
250
248
 
251
- this.#status = newStatus;
252
- return {
253
- status: this.#status,
254
- lastSeen: this.__persist.lastSeen,
255
- };
249
+ this.__socket = undefined;
256
250
  }
257
251
  }
@@ -2,7 +2,7 @@ import type { ActorKey } from "@/actor/mod";
2
2
  import type { Client } from "@/client/client";
3
3
  import type { Logger } from "@/common/log";
4
4
  import type { Registry } from "@/registry/mod";
5
- import type { Conn, ConnId } from "./connection";
5
+ import type { Conn, ConnId } from "./conn";
6
6
  import type { AnyDatabaseProvider, InferDatabaseClient } from "./database";
7
7
  import type { ActorInstance, SaveStateOptions } from "./instance";
8
8
  import type { Schedule } from "./schedule";
@@ -1,15 +1,10 @@
1
- import type { CachedSerializer } from "@/actor/protocol/serde";
1
+ import type { Context as HonoContext } from "hono";
2
2
  import type { AnyClient } from "@/client/client";
3
3
  import type { ManagerDriver } from "@/manager/driver";
4
4
  import type { RegistryConfig } from "@/registry/config";
5
5
  import type { RunConfig } from "@/registry/run-config";
6
- import type * as protocol from "@/schemas/client-protocol/mod";
7
- import type { AnyConn, ConnectionDriver } from "./connection";
8
- import type { GenericConnGlobalState } from "./generic-conn-driver";
9
6
  import type { AnyActorInstance } from "./instance";
10
7
 
11
- export type ConnectionDriversMap = Record<ConnectionDriver, ConnDriver>;
12
-
13
8
  export type ActorDriverBuilder = (
14
9
  registryConfig: RegistryConfig,
15
10
  runConfig: RunConfig,
@@ -22,8 +17,6 @@ export interface ActorDriver {
22
17
 
23
18
  loadActor(actorId: string): Promise<AnyActorInstance>;
24
19
 
25
- getGenericConnGlobalState(actorId: string): GenericConnGlobalState;
26
-
27
20
  getContext(actorId: string): unknown;
28
21
 
29
22
  readPersistedData(actorId: string): Promise<Uint8Array | undefined>;
@@ -45,40 +38,8 @@ export interface ActorDriver {
45
38
  sleep?(actorId: string): Promise<void>;
46
39
 
47
40
  shutdown?(immediate: boolean): Promise<void>;
48
- }
49
-
50
- export enum ConnectionReadyState {
51
- UNKNOWN = -1,
52
- CONNECTING = 0,
53
- OPEN = 1,
54
- CLOSING = 2,
55
- CLOSED = 3,
56
- }
57
-
58
- export interface ConnDriver<ConnDriverState = unknown> {
59
- sendMessage?(
60
- actor: AnyActorInstance,
61
- conn: AnyConn,
62
- state: ConnDriverState,
63
- message: CachedSerializer<protocol.ToClient>,
64
- ): void;
65
41
 
66
- /**
67
- * This returns a promise since we commonly disconnect at the end of a program, and not waiting will cause the socket to not close cleanly.
68
- */
69
- disconnect(
70
- actor: AnyActorInstance,
71
- conn: AnyConn,
72
- state: ConnDriverState,
73
- reason?: string,
74
- ): Promise<void>;
75
-
76
- /**
77
- * Returns the ready state of the connection.
78
- * This is used to determine if the connection is ready to send messages, or if the connection is stale.
79
- */
80
- getConnectionReadyState(
81
- actor: AnyActorInstance,
82
- conn: AnyConn,
83
- ): ConnectionReadyState | undefined;
42
+ // Serverless
43
+ /** This handles the serverless start request. This should manage the lifecycle of the runner tied to the request lifecycle. */
44
+ serverlessHandleStart?(c: HonoContext): Promise<Response>;
84
45
  }