Data class describing worker behaviour.

Remarks

The Agents framework provides sane worker defaults, and works out-of-the-box with no tweaking necessary. The only mandatory parameter is agent, which points to the entry function.

This class is mostly useful in conjunction with cli.runApp.

Constructors

  • Parameters

    • options: {
          agent: string;
          agentName?: string;
          apiKey?: string;
          apiSecret?: string;
          host?: string;
          initializeProcessTimeout?: number;
          loadFunc?: (() => Promise<number>);
          loadThreshold?: number;
          logLevel?: string;
          maxRetry?: number;
          numIdleProcesses?: number;
          permissions?: WorkerPermissions;
          port?: number;
          production?: boolean;
          requestFunc?: ((job) => Promise<void>);
          shutdownProcessTimeout?: number;
          workerType?: JobType;
          wsURL?: string;
      }
      • agent: string

        Path to a file that has Agent as a default export, dynamically imported later for entrypoint and prewarm functions

      • Optional agentName?: string
      • Optional apiKey?: string
      • Optional apiSecret?: string
      • Optional host?: string
      • Optional initializeProcessTimeout?: number
      • Optional loadFunc?: (() => Promise<number>)

        Called to determine the current load of the worker. Should return a value between 0 and 1.

          • (): Promise<number>
          • Returns Promise<number>

      • Optional loadThreshold?: number

        When the load exceeds this threshold, the worker will be marked as unavailable.

      • Optional logLevel?: string
      • Optional maxRetry?: number
      • Optional numIdleProcesses?: number
      • Optional permissions?: WorkerPermissions
      • Optional port?: number
      • Optional production?: boolean
      • Optional requestFunc?: ((job) => Promise<void>)
          • (job): Promise<void>
          • Parameters

            Returns Promise<void>

      • Optional shutdownProcessTimeout?: number
      • Optional workerType?: JobType
      • Optional wsURL?: string

    Returns WorkerOptions

Properties

agent: string
agentName: string
apiKey?: string
apiSecret?: string
host: string
initializeProcessTimeout: number
loadFunc: (() => Promise<number>)

Type declaration

    • (): Promise<number>
    • Returns Promise<number>

loadThreshold: number
logLevel: string
maxRetry: number
numIdleProcesses: number
permissions: WorkerPermissions
port: number
production: boolean
requestFunc: ((job) => Promise<void>)

Type declaration

    • (job): Promise<void>
    • Parameters

      Returns Promise<void>

shutdownProcessTimeout: number
workerType: JobType
wsURL: string