Constructors

Methods

  • Create a worker.

    config carries worker-instance defaults, immutable after creation and delivered to the worker as CloudEvent extension attributes on every triggering event (never process env vars, so values cannot leak between workers co-loaded in one WorkManager process). A worker's own payload field takes precedence; config is the fallback. tags is free-form metadata. secrets maps attribute names to keys of the deployment's worker secret: only these references are stored, and the Runtime stamps the values onto every triggering event (docs/v1/worker-secrets.md).

    Both are proto fields 4 and 5 of CreateWorkerRequest.

    Parameters

    • mimeType: string
    • topics: string[]
    • OptionalcodeUrl: string
    • OptionalcodeContent: Uint8Array<ArrayBufferLike>
    • Optionalconfig: Record<string, string>
    • Optionaltags: Record<string, string>
    • Optionalsecrets: Record<string, string>
    • Optionalshard: string
    • OptionalshardSize: number
    • OptionalshardIndex: number

    Returns Promise<CreateWorkerResponse>

  • Parameters

    • id: string

    Returns Promise<Message<"virtufin.DeleteWorkerResponse">>

  • Parameters

    • id: string
    • key: string

    Returns Promise<GetTagResponse>

  • Hand a running worker one command synchronously and get its outputs back (they are not published). The command becomes a CloudEvent of type com.virtufin.workmanager.worker.command with the name in the command extension and payload as data. A worker that is not running fails with FAILED_PRECONDITION.

    Parameters

    • id: string
    • command: string
    • options: {
          attributes?: Record<string, string>;
          contentType?: string;
          payload?: Uint8Array<ArrayBufferLike>;
          timeoutMs?: number;
      } = {}

    Returns Promise<InvokeWorkerCommandResponse>

  • Parameters

    • id: string
    • codeSource: { url: string } | { content: Uint8Array }

    Returns Promise<Message<"virtufin.LoadCodeResponse">>

  • Parameters

    • id: string
    • key: string
    • value: string

    Returns Promise<Message<"virtufin.SetTagResponse">>

  • Parameters

    • id: string
    • tags: Record<string, string>

    Returns Promise<Message<"virtufin.SetTagsResponse">>

  • Parameters

    • id: string

    Returns Promise<Message<"virtufin.StartWorkerResponse">>

  • Parameters

    • id: string

    Returns Promise<Message<"virtufin.StopWorkerResponse">>

  • Wait for an asynchronously created worker to finish loading.

    CreateWorker returns as soon as the worker is registered (status LOADING); its code and dependencies load in the background. A StartWorker sent meanwhile is deferred until loading completes. Polls the worker's status until it leaves LOADING.

    Parameters

    • id: string
    • timeoutMs: number = 120_000
    • pollIntervalMs: number = 1_000

    Returns Promise<WorkerInfo>

    Error if the worker doesn't exist, failed to load, or is still loading after timeoutMs.