UNPKG

inngest

Version:

Official SDK for Inngest.com. Inngest is the reliability layer for modern applications. Inngest combines durable execution, events, and queues into a zero-infra platform with built-in observability.

119 lines (118 loc) 4.38 kB
import { InngestFunction } from "../InngestFunction.js"; import { RegisterOptions } from "../../types.js"; import { Inngest } from "../Inngest.js"; //#region src/components/connect/types.d.ts declare const DEFAULT_SHUTDOWN_SIGNALS: string[]; interface ConnectApp { client: Inngest.Any; functions?: Array<InngestFunction.Like>; } interface ConnectHandlerOptions extends RegisterOptions { apps: ConnectApp[]; /** * InstanceId represents a stable identifier to be used for identifying connected SDKs. * This can be a hostname or other identifier that remains stable across restarts. * * If nil, this defaults to the current machine's hostname. */ instanceId?: string; /** * MaxWorkerConcurrency represents the maximum number of worker concurrency to use. * * If left undefined, there will be no limit on the number of concurrent requests on the worker. */ maxWorkerConcurrency?: number; /** * By default, connections will be gracefully shut down when the current * process receives a SIGINT or SIGTERM signal. Set this to an empty array to disable this behavior. */ handleShutdownSignals?: string[]; /** * Override the gateway WebSocket endpoint. When set, this URL is used * instead of the endpoint returned by the Inngest API. * * Useful when there is a proxy between the worker and the gateway * that requires a different hostname (e.g. `ws://localhost:8100`). * * Can also be set via the `INNGEST_CONNECT_GATEWAY_URL` environment variable. * This option takes precedence over the env var. */ gatewayUrl?: string; /** * Enable running the WebSocket connection, heartbeater, and lease extender * in a separate worker thread. This prevents thread-blocking user code from * interfering with connection health. * * Only works in environments that support worker_threads. * * Can also be disabled via the INNGEST_CONNECT_ISOLATE_EXECUTION=false environment variable. * * @default true */ isolateExecution?: boolean; } interface WorkerConnection { connectionId: string; closed: Promise<void>; close: () => Promise<void>; state: ConnectionState; getDebugState: () => ConnectDebugState; } interface InFlightRequest { requestId: string; runId: string; stepId: string | undefined; appId: string; envId: string; functionSlug: string; accountId: string; /** * Timestamp (ms since epoch) when the worker acknowledged the request and * took the lease. Used to compute age for shutdown diagnostics. * * Optional so external callers constructing an `InFlightRequest` (e.g. * from {@link ConnectDebugState}) aren't forced to provide it. */ leaseAcquiredAt?: number; /** * Timestamp (ms since epoch) of the most recent successful lease-extend send * for this request. Starts equal to `leaseAcquiredAt` and is updated each * time the worker sends a WORKER_REQUEST_EXTEND_LEASE message. Useful * during shutdown diagnostics to tell whether a stuck request is still * being actively leased or has gone silent. * * Optional for the same reason as {@link leaseAcquiredAt}. */ leaseLastExtendedAt?: number; } interface ConnectDebugState { /** Current connection state */ state: ConnectionState; /** Active connection ID, if any */ activeConnectionId: string | undefined; /** Draining connection ID (during gateway drain), if any */ drainingConnectionId: string | undefined; /** Timestamp of last heartbeat we sent */ lastHeartbeatSentAt: number | undefined; /** Timestamp of last heartbeat response from gateway */ lastHeartbeatReceivedAt: number | undefined; /** Timestamp of last WS message received (any type) */ lastMessageReceivedAt: number | undefined; /** Whether shutdown has been requested (WORKER_PAUSE sent) */ shutdownRequested: boolean; /** Number of in-flight requests */ inFlightRequestCount: number; /** Detailed info about in-flight requests */ inFlightRequests: InFlightRequest[]; } declare enum ConnectionState { CONNECTING = "CONNECTING", ACTIVE = "ACTIVE", PAUSED = "PAUSED", RECONNECTING = "RECONNECTING", CLOSING = "CLOSING", CLOSED = "CLOSED", } //#endregion export { ConnectApp, ConnectDebugState, ConnectHandlerOptions, ConnectionState, DEFAULT_SHUTDOWN_SIGNALS, InFlightRequest, WorkerConnection }; //# sourceMappingURL=types.d.ts.map