Skip to content

Commit 1f5d184

Browse files
committed
refactor: rename ActorHandle to ActorConn for clarity
1 parent 99342ff commit 1f5d184

File tree

7 files changed

+110
-201
lines changed

7 files changed

+110
-201
lines changed

packages/actor-core/src/client/handle.ts renamed to packages/actor-core/src/client/actor_conn.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import * as cbor from "cbor-x";
88
import * as errors from "./errors";
99
import { logger } from "./log";
1010
import { type WebSocketMessage as ConnMessage, messageLength } from "./utils";
11-
import { ACTOR_HANDLES_SYMBOL, ClientRaw, DynamicImports } from "./client";
11+
import { ACTOR_CONNS_SYMBOL, ClientRaw, DynamicImports } from "./client";
1212
import { ActorDefinition, AnyActorDefinition } from "@/actor/definition";
1313
import pRetry, { AbortError } from "p-retry";
1414

@@ -39,11 +39,11 @@ export type ConnTransport = { websocket: WebSocket } | { sse: EventSource };
3939
export const CONNECT_SYMBOL = Symbol("connect");
4040

4141
/**
42-
* Provides underlying functions for {@link ActorHandle}. See {@link ActorHandle} for using type-safe remote procedure calls.
42+
* Provides underlying functions for {@link ActorConn}. See {@link ActorConn} for using type-safe remote procedure calls.
4343
*
44-
* @see {@link ActorHandle}
44+
* @see {@link ActorConn}
4545
*/
46-
export class ActorHandleRaw {
46+
export class ActorConnRaw {
4747
#disposed = false;
4848

4949
/* Will be aborted on dispose. */
@@ -81,7 +81,7 @@ export class ActorHandleRaw {
8181
/**
8282
* Do not call this directly.
8383
*
84-
* Creates an instance of ActorHandleRaw.
84+
* Creates an instance of ActorConnRaw.
8585
*
8686
* @param {string} endpoint - The endpoint to connect to.
8787
*
@@ -100,9 +100,9 @@ export class ActorHandleRaw {
100100
}
101101

102102
/**
103-
* Call a raw RPC handle. See {@link ActorHandle} for type-safe RPC calls.
103+
* Call a raw RPC connection. See {@link ActorConn} for type-safe RPC calls.
104104
*
105-
* @see {@link ActorHandle}
105+
* @see {@link ActorConn}
106106
* @template Args - The type of arguments to pass to the RPC function.
107107
* @template Response - The type of the response returned by the RPC function.
108108
* @param {string} name - The name of the RPC function to call.
@@ -712,10 +712,10 @@ enc
712712
* @returns {Promise<void>} A promise that resolves when the socket is gracefully closed.
713713
*/
714714
async dispose(): Promise<void> {
715-
// Internally, this "disposes" the handle
715+
// Internally, this "disposes" the connection
716716

717717
if (this.#disposed) {
718-
logger().warn("handle already disconnected");
718+
logger().warn("connection already disconnected");
719719
return;
720720
}
721721
this.#disposed = true;
@@ -729,7 +729,7 @@ enc
729729
this.#abortController.abort();
730730

731731
// Remove from registry
732-
this.client[ACTOR_HANDLES_SYMBOL].delete(this);
732+
this.client[ACTOR_CONNS_SYMBOL].delete(this);
733733

734734
// Disconnect transport cleanly
735735
if (!this.#transport) {
@@ -776,29 +776,29 @@ type ActorDefinitionRpcs<AD extends AnyActorDefinition> = {
776776
};
777777

778778
/**
779-
* Connection to an actor. Allows calling actor's remote procedure calls with inferred types. See {@link ActorHandleRaw} for underlying methods.
779+
* Connection to an actor. Allows calling actor's remote procedure calls with inferred types. See {@link ActorConnRaw} for underlying methods.
780780
*
781781
* @example
782782
* ```
783-
* const room = await client.get<ChatRoom>(...etc...);
783+
* const room = await client.connect<ChatRoom>(...etc...);
784784
* // This calls the rpc named `sendMessage` on the `ChatRoom` actor.
785785
* await room.sendMessage('Hello, world!');
786786
* ```
787787
*
788788
* Private methods (e.g. those starting with `_`) are automatically excluded.
789789
*
790-
* @template AD The actor class that this handle is connected to.
791-
* @see {@link ActorHandleRaw}
790+
* @template AD The actor class that this connection is for.
791+
* @see {@link ActorConnRaw}
792792
*/
793793

794-
export type ActorHandle<AD extends AnyActorDefinition> = ActorHandleRaw &
794+
export type ActorConn<AD extends AnyActorDefinition> = ActorConnRaw &
795795
ActorDefinitionRpcs<AD>;
796796

797797
//{
798798
// [K in keyof A as K extends string ? K extends `_${string}` ? never : K : K]: A[K] extends (...args: infer Args) => infer Return ? ActorRPCFunction<Args, Return> : never;
799799
//};
800800
/**
801-
* RPC function returned by `ActorHandle`. This will call `ActorHandle.rpc` when triggered.
801+
* RPC function returned by `ActorConn`. This will call `ActorConn.rpc` when triggered.
802802
*
803803
* @typedef {Function} ActorRPCFunction
804804
* @template Args

0 commit comments

Comments
 (0)