Documents / @faasjs/jobs / Job
Class: Job<TSchema, TContext, TResult>
Executable job definition returned by defineJob.
Extends
Func<JobEvent<TSchema>,TContext,TResult>
Type Parameters
TSchema
TSchema extends ZodType | undefined = undefined
TContext
TContext = any
TResult
TResult = any
Indexable
[
key:string]:any
Constructors
Constructor
new Job<
TSchema,TContext,TResult>(options):Job<TSchema,TContext,TResult>
Parameters
options
DefineJobOptions<TSchema, TContext, TResult>
Returns
Job<TSchema, TContext, TResult>
Overrides
Func<JobEvent<TSchema>, TContext, TResult>.constructor
Methods
export()
export():
object
Build the exported handler wrapper for the function.
The wrapper initializes request id/runtime context fields, invokes mount hooks on
first use, and throws any Error object stored in data.response.
Returns
object
Object containing the exported handler.
handler
handler:
ExportedHandler<JobEvent<TSchema>,TContext,TResult>
Inherited from
Func.export
invoke()
invoke(
data):Promise<void>
Invoke the function.
Parameters
data
InvokeData<JobEvent<TSchema>, TContext, TResult>
Invocation state mutated by plugins and the final handler.
Returns
Promise<void>
Promise that resolves after invoke hooks complete.
Inherited from
Func.invoke
mount()
mount(
data?):Promise<void>
First time mount the function.
Parameters
data?
Optional initial event, context, config, and logger used during mount.
config?
Config
Function config override used during mount.
context
TContext
Initial context value passed through mount hooks.
event
Initial event value passed through mount hooks.
logger?
Logger
Logger override used during mount.
Returns
Promise<void>
Promise that resolves after mount hooks complete.
Inherited from
Func.mount
Properties
__faasjsJob
readonly__faasjsJob:true=true
Internal
Marker used by the job loader to recognize job definitions.
config
config:
Config
Mutable runtime configuration used by the function.
Inherited from
Func.config
cron
readonlycron:JobCron<SchemaOutput<TSchema,Record<string,never>>>[]
Cron rules used by JobScheduler to enqueue scheduled jobs.
filename?
optionalfilename?:string
Resolved source filename inferred from the constructor call stack.
Inherited from
Func.filename
handler?
optionalhandler?:Handler<JobEvent<TSchema>,TContext,TResult>
Final business handler invoked after plugins finish.
Inherited from
Func.handler
maxAttempts
readonlymaxAttempts:number
Normalized maximum attempts before a job is marked failed.
mounted
mounted:
boolean=false
Indicates whether mount hooks have already run.
Inherited from
Func.mounted
plugins
plugins:
Plugin[]
Ordered plugin instances attached to this function.
Inherited from
Func.plugins
queue
readonlyqueue:string
Normalized queue name used by default enqueues and workers.
retry
readonlyretry:JobRetry|undefined
Retry strategy used after failed attempts.
runtime
runtime:
FuncRuntime|undefined
Default runtime value written to context.runtime when the caller does not
provide one.
Inherited from
Func.runtime
schema
readonlyschema:TSchema|undefined
Zod schema used to validate job params before the handler runs.