Documentation / @andrew_l/app / WorkerDefinition
Interface: WorkerDefinition<P, S, M, C, RuntimeContext, EntryContext, SetupContext> ​
Worker definition — extends AppDefinition with strategy, per-task entry, and concurrency config.
Extends ​
AppDefinition<P,S,M,RuntimeContext,EntryContext,SetupContext>
Type Parameters ​
P ​
P extends ObjectPropsOptions = { }
S ​
S extends Record<string, any> = { }
M ​
M extends Record<string, AnyFunction> = { }
C ​
C extends WorkerStrategy = WorkerStrategy
RuntimeContext ​
RuntimeContext extends RuntimeContext = RuntimeContext<S & M>
EntryContext ​
EntryContext extends EntryContext = EntryContext<C> & S & M
SetupContext ​
SetupContext extends SetupContext = SetupContext<M>
Properties ​
description? ​
optionaldescription:string
Describe what your application does
Inherited from ​
disabled? ​
optionaldisabled:boolean
Disable worker
Default ​
falseexecuteStrategy ​
executeStrategy:
C
filePath? ​
optionalfilePath:null|string
Path to the file where this definition exports default Usually you should not use this option, because it tracks automatically
Inherited from ​
logger? ​
optionallogger:false|Logger| (definition) =>Logger
Logger instance or constructor function
Inherited from ​
methods? ​
optionalmethods:M&ThisType<RuntimeContext>
Custom methods which will be available under this context
Inherited from ​
name ​
name:
string
Name of your awesome application
Inherited from ​
props? ​
optionalprops:P
Props options to be parsed from cli arguments of env variables
Inherited from ​
taskLimit? ​
optionaltaskLimit:number
Maximum limit of queued tasks
Default ​
50taskParallel? ​
optionaltaskParallel:number
Amount of task to be executed in parallel
Default ​
2Methods ​
entry()? ​
optionalentry(this,props):Awaitable<void|WorkerResult|WorkerResult[]>
Entry function that will be called each time when worker handle a job
Parameters ​
this ​
EntryContext
props ​
Returns ​
Awaitable<void | WorkerResult | WorkerResult[]>
Overrides ​
setup()? ​
optionalsetup(this,props):Awaitable<S>
Setup function will be called once while worker setup.
Parameters ​
this ​
SetupContext
props ​
Returns ​
Awaitable<S>
Overrides ​
shutdown()? ​
optionalshutdown(this,props):Awaitable<void>
Shutdown function that will be called before application/process graceful shutdown
Parameters ​
this ​
RuntimeContext
props ​
Returns ​
Awaitable<void>
Inherited from ​
stop()? ​
optionalstop(this,props):Awaitable<void>
Stop function that will be called each time when application stops
Parameters ​
this ​
RuntimeContext
props ​
Returns ​
Awaitable<void>