UNPKG

theater-client

Version:

TypeScript client library for Theater actor system TCP protocol

105 lines 3.1 kB
/** * Actor wrapper class - provides ergonomic interface around an actor ID */ import type { TheaterClient } from './TheaterClient.js'; import { TheaterConnection } from '../connection/TheaterConnection.js'; import type { TheaterId, ActorStatus, ManifestConfig, ChainEvent } from '../types/protocol.js'; import type { ChannelStream, ActorEventStream, ActorCallbacks } from '../types/client.js'; /** * Actor wrapper that provides a clean, object-oriented interface * around an actor ID, automatically filling in the ID for all operations */ export declare class Actor { readonly id: TheaterId; private readonly client; private eventConnection; private callbacks; constructor(id: TheaterId, client: TheaterClient, eventConnection?: TheaterConnection, callbacks?: ActorCallbacks); /** * Get the current status of this actor */ getStatus(): Promise<ActorStatus>; /** * Restart this actor */ restart(): Promise<void>; /** * Stop this actor */ stop(): Promise<void>; /** * Get the manifest configuration of this actor */ getManifest(): Promise<ManifestConfig>; /** * Get the current state of this actor */ getState(): Promise<Uint8Array | null>; /** * Get the event history for this actor */ getEvents(): Promise<ChainEvent[]>; /** * Get metrics for this actor */ getMetrics(): Promise<any>; /** * Send raw bytes to this actor (fire-and-forget) */ sendBytes(data: Uint8Array): Promise<void>; /** * Send raw bytes to this actor and wait for response */ requestBytes(data: Uint8Array): Promise<Uint8Array>; /** * Send a JSON object to this actor (fire-and-forget) */ sendJson(obj: any): Promise<void>; /** * Send a JSON object to this actor and wait for JSON response */ requestJson<T = any>(obj: any): Promise<T>; /** * Send a string to this actor (fire-and-forget) */ sendString(text: string): Promise<void>; /** * Send a string to this actor and wait for string response */ requestString(text: string): Promise<string>; /** * Open a communication channel with this actor */ openChannel(initialMessage?: Uint8Array): Promise<ChannelStream>; /** * Subscribe to events from this actor */ subscribe(): Promise<ActorEventStream>; /** * Check if this actor has supervision (event stream connection) */ get isSupervised(): boolean; /** * Set up event handling for supervised actors */ private setupEventHandling; /** * String representation of this actor (returns the ID) */ toString(): string; /** * Check if this actor has the same ID as another actor */ equals(other: Actor): boolean; /** * Get a JSON representation of this actor */ toJSON(): { id: TheaterId; }; /** * Check if this actor represents the same ID as a string */ hasId(id: TheaterId): boolean; } //# sourceMappingURL=Actor.d.ts.map