AgendaCommandScheduler
Hierarchy
StatefulMixin
↳ AgendaCommandScheduler
Implements
- Stateful
- CommandScheduler
- Stateful
- CommandScheduler
Index
Constructors
Properties
Methods
- getInterval
- getJob
- getSelectableStates
- getState
- handleScheduledCommand
- hasState
- initialize
- isInOneOfStates
- isInState
- schedule
- setState
- startScheduling
- stopScheduling
- unschedule
- unscheduleAll
- validateState
Object literals
Constructors
constructor
+ new AgendaCommandScheduler(jobName?
: string, options?
: AgendaConfiguration): AgendaCommandScheduler
Creates an instance of AgendaCommandScheduler. Creates an instance of AgendaCommandScheduler.
Parameters:
Name | Type | Description |
---|---|---|
jobName? | string | Name of the job that is being scheduled on Agenda. |
options? | AgendaConfiguration | Optional options passed to Agenda client. |
Returns: AgendaCommandScheduler
Properties
Readonly
agendaClient
• agendaClient: AgendaClient
Readonly
jobName
• jobName: string
Optional
Readonly
options
• options? : AgendaConfiguration
state
• state: State
Implementation of CommandScheduler.state
Overrides StatefulMixin.state
Methods
getInterval
▸ getInterval(): number
Implementation of CommandScheduler
Returns frequency at which schedule will query looking for scheduled commands that need to be processed.
Returns: number
Interval for query frequency as a number
, else undefined
.
getJob
▸ getJob(commandType
: string, assignerId
: string | Guid, assignerType
: string, assignmentId?
: string | Guid): Promise‹ScheduledJob | undefined›
Implementation of CommandScheduler
Returns ScheduledJob if it can be found on Scheduler
.
Parameters:
Name | Type | Description |
---|---|---|
commandType | string | Command type name for which schedule was made. |
assignerId | string | Guid | Source of scheduled job i.e. Event Sourceable's identifier. |
assignerType | string | Event Sourceable type name. |
assignmentId? | string | Guid | Assignment identifier. |
Returns: Promise‹ScheduledJob | undefined›
Instance implementing ScheduledJob
interface, else undefined
.
getSelectableStates
▸ getSelectableStates(): Record‹string, State›
Implementation of CommandScheduler
Inherited from StatefulMixin.getSelectableStates
Overrides Task.getSelectableStates
Returns: Record‹string, State›
getState
▸ getState(): State
Implementation of CommandScheduler
Inherited from StatefulMixin.getState
Returns: State
handleScheduledCommand
▸ handleScheduledCommand(job
: Agenda.Job): Promise‹void›
Agenda job handler for ScheduledCommand.
async
Parameters:
Name | Type | Description |
---|---|---|
job | Agenda.Job | Instance implementing Agenda.Job interface. |
Returns: Promise‹void›
hasState
▸ hasState(): boolean
Implementation of CommandScheduler
Inherited from StatefulMixin.hasState
Returns: boolean
initialize
▸ initialize(): Promise‹void›
Implementation of CommandScheduler
Initializes Agenda command scheduler.
async
throws
{InactiveClientError}
Thrown if agenda client is not connected.
Returns: Promise‹void›
isInOneOfStates
▸ isInOneOfStates(states
: State | State[]): boolean
Implementation of CommandScheduler
Inherited from StatefulMixin.isInOneOfStates
Overrides Task.isInOneOfStates
Parameters:
Name | Type |
---|---|
states | State | State[] |
Returns: boolean
isInState
▸ isInState(state
: State | State[]): boolean
Implementation of CommandScheduler
Inherited from StatefulMixin.isInState
Parameters:
Name | Type |
---|---|
state | State | State[] |
Returns: boolean
schedule
▸ schedule(scheduleCommand
: ScheduleCommand): Promise‹void›
Implementation of CommandScheduler
Schedules command with Agenda.
async
throws
{CommandSchedulingError}
Thrown if scheduled command cannot be scheduled.
Parameters:
Name | Type | Description |
---|---|---|
scheduleCommand | ScheduleCommand | Instance of ScheduleCommand . |
Returns: Promise‹void›
setState
▸ setState(state
: State): void
Implementation of CommandScheduler
Inherited from StatefulMixin.setState
Parameters:
Name | Type |
---|---|
state | State |
Returns: void
startScheduling
▸ startScheduling(): Promise‹void›
Implementation of CommandScheduler
Starts processing on CommandScheduler.
Returns: Promise‹void›
stopScheduling
▸ stopScheduling(): Promise‹void›
Implementation of CommandScheduler
Stops processing on CommandScheduler.
Returns: Promise‹void›
unschedule
▸ unschedule(unscheduleCommand
: UnscheduleCommand): Promise‹boolean›
Implementation of CommandScheduler
Unschedules command from Agenda.
async
throws
{CommandUnschedulingError}
Thrown if scheduled command cannot be canceled.
Parameters:
Name | Type | Description |
---|---|---|
unscheduleCommand | UnscheduleCommand | Instance of UnscheduleCommand . |
Returns: Promise‹boolean›
unscheduleAll
▸ unscheduleAll(): Promise‹void›
Implementation of CommandScheduler
Unschedules all commands(jobs matching scheduler's job name) from Agenda.
async
Returns: Promise‹void›
validateState
▸ validateState(stateOrStates
: State | State[], error?
: Error): boolean
Implementation of CommandScheduler
Inherited from StatefulMixin.validateState
Overrides Task.validateState
Parameters:
Name | Type |
---|---|
stateOrStates | State | State[] |
error? | Error |
Returns: boolean
Object literals
Static
STATES
▪ STATES: object
active
• active: string = "active"
constructed
• constructed: string = "constructed"
initialized
• initialized: string = "initialized"
stopped
• stopped: string = "stopped"