UNPKG

@temporalio/worker

Version:
68 lines (67 loc) 2.63 kB
import { Client, Worker } from '@temporalio/core-bridge'; import { NativeConnectionOptions } from './connection-options'; /** * A Native Connection object that delegates calls to the Rust Core binary extension. * * A Worker must use this class to connect to the server. * * Do not confuse this connection class with `@temporalio/client`'s Connection. */ export declare class NativeConnection { private nativeClient; /** * referenceHolders is used internally by the framework, it can be accessed with `extractReferenceHolders` (below) */ private readonly referenceHolders; /** * nativeClient is intentionally left private, framework code can access it with `extractNativeClient` (below) */ protected constructor(nativeClient: Client); /** * @deprecated use `connect` instead */ static create(options?: NativeConnectionOptions): Promise<NativeConnection>; /** * Eagerly connect to the Temporal server and return a NativeConnection instance */ static connect(options?: NativeConnectionOptions): Promise<NativeConnection>; /** * Close this connection. * * Make sure any Workers using this connection are stopped before calling * this method or it will throw an {@link IllegalStateError} */ close(): Promise<void>; /** * Mapping of gRPC metadata (HTTP headers) to send with each request to the server. * * Use {@link NativeConnectionOptions.metadata} to set the initial metadata for client creation. */ setMetadata(metadata: Record<string, string>): Promise<void>; /** * Update the API key for this client. This is only set if `metadata` doesn't already have an * "authorization" key. * * Use {@link NativeConnectionOptions.apiKey} to set the initial metadata for client creation. */ setApiKey(apiKey: string): Promise<void>; } /** * Extract the private native client instance from a `NativeConnection` instance. * * Only meant to be used by the framework. */ export declare function extractNativeClient(conn: NativeConnection): Client; /** * Extract the private referenceHolders set from a `NativeConnection` instance. * * Only meant to be used by the framework. */ export declare function extractReferenceHolders(conn: NativeConnection): Set<Worker>; /** * Internal class used when a Worker directly instantiates a connection with no external references. * * This class is only used as a "marker" during Worker shutdown to decide whether to close the connection. */ export declare class InternalNativeConnection extends NativeConnection { }