Class DashboardHistoryPlugin
Records what a scheduler has run and what it has missed, so the history and misfire pages have something to show.
public sealed class DashboardHistoryPlugin : ISchedulerPlugin, IJobListener, ITriggerListener
- Inheritance
-
DashboardHistoryPlugin
- Implements
- Inherited Members
Remarks
The rows go to the IDashboardHistoryStore in the container, which by default keeps
them in memory for HistoryRetention — a dashboard's history is an operator's recent view
rather than an audit log. Registered by AddQuartzDashboard against every scheduler in the
container, and told its own scheduler's name when it is initialized, which is what its rows are
keyed by.
Constructors
DashboardHistoryPlugin(IServiceProvider, TimeProvider)
Takes the container the history store is resolved from, and the clock a misfire is stamped with.
public DashboardHistoryPlugin(IServiceProvider serviceProvider, TimeProvider timeProvider)
Parameters
serviceProviderIServiceProvidertimeProviderTimeProvider
Remarks
A plugin is constructed by the container — this one is registered for every scheduler by
AddQuartzDashboard — so it asks for what it needs the way any other component does. It used
to read the container back out of scheduler.Context["Quartz.ServiceProvider"], which put
Quartz's plumbing into the application's own map, and left the scheduler-context endpoint of the
HTTP API answering 500 for every scheduler a container had built.
The clock is this scheduler's: a named scheduler is built through a provider that resolves its own parts, so a scheduler given a TimeProvider of its own stamps its misfires with it. An execution needs no clock — it carries the fire time the scheduler already recorded.
Properties
Name
The name this listener is registered and removed under.
public string Name { get; }
Property Value
Remarks
Defaults to the implementing type's name, which is the right answer whenever a scheduler has at most one listener of a given type. Override it when several instances of one type are registered with the same scheduler, because the later registration would otherwise replace the earlier one.
Methods
Initialize(string, IScheduler, CancellationToken)
Called during creation of the IScheduler in order to give the ISchedulerPlugin a chance to Initialize.
public ValueTask Initialize(string pluginName, IScheduler scheduler, CancellationToken cancellationToken = default)
Parameters
pluginNamestringThe name by which the plugin is identified.
schedulerISchedulerThe scheduler to which the plugin is registered.
cancellationTokenCancellationTokenThe cancellation instruction.
Returns
Remarks
At this point, the Scheduler's IJobStore is not yet
If you need direct access your plugin, you can have it explicitly put a reference to itself in the IScheduler's SchedulerContext as part of its Initialize(string, IScheduler, CancellationToken) method.
JobExecutionVetoed(IJobExecutionContext, CancellationToken)
Called by the IScheduler when a IJobDetail was about to be executed (an associated ITrigger has occurred), but a ITriggerListener vetoed it's execution.
public ValueTask JobExecutionVetoed(IJobExecutionContext context, CancellationToken cancellationToken = default)
Parameters
contextIJobExecutionContextcancellationTokenCancellationToken
Returns
Remarks
The default implementation does nothing.
- See Also
JobToBeExecuted(IJobExecutionContext, CancellationToken)
Called by the IScheduler when a IJobDetail is about to be executed (an associated ITrigger has occurred).
This method will not be invoked if the execution of the Job was vetoed by a ITriggerListener.
public ValueTask JobToBeExecuted(IJobExecutionContext context, CancellationToken cancellationToken = default)
Parameters
contextIJobExecutionContextcancellationTokenCancellationToken
Returns
Remarks
The default implementation does nothing.
- See Also
JobWasExecuted(IJobExecutionContext, JobExecutionException?, CancellationToken)
Called by the IScheduler after a IJobDetail has been executed, and be for the associated IOperableTrigger's Triggered(ICalendar?) method has been called.
public ValueTask JobWasExecuted(IJobExecutionContext context, JobExecutionException? jobException, CancellationToken cancellationToken = default)
Parameters
contextIJobExecutionContextjobExceptionJobExecutionExceptioncancellationTokenCancellationToken
Returns
Remarks
The default implementation does nothing.
Shutdown(CancellationToken)
Called in order to inform the ISchedulerPlugin that it should free up all of it's resources because the scheduler is shutting down.
public ValueTask Shutdown(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationToken
Returns
Remarks
Does nothing unless the plugin says otherwise. Most plugins do all their work in Initialize(string, IScheduler, CancellationToken) — attaching a listener, registering a resolver — and have nothing to say at the two lifecycle moments; implement this only when there is something that cannot happen until the scheduler is running.
Start(CancellationToken)
Called when the associated IScheduler is started, in order to let the plug-in know it can now make calls into the scheduler if it needs to.
public ValueTask Start(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationToken
Returns
Remarks
Does nothing unless the plugin says otherwise. Most plugins do all their work in Initialize(string, IScheduler, CancellationToken) — attaching a listener, registering a resolver — and have nothing to say at the two lifecycle moments; implement this only when there is something that cannot happen until the scheduler is running.
TriggerComplete(ITrigger, IJobExecutionContext, SchedulerInstruction, CancellationToken)
Called by the IScheduler when a ITrigger has fired, it's associated IJobDetail has been executed, and it's Triggered(ICalendar?) method has been called.
public ValueTask TriggerComplete(ITrigger trigger, IJobExecutionContext context, SchedulerInstruction triggerInstructionCode, CancellationToken cancellationToken = default)
Parameters
triggerITriggerThe ITrigger that was fired.
contextIJobExecutionContextThe IJobExecutionContext that was passed to the IJob'sExecute(IJobExecutionContext, CancellationToken) method.
triggerInstructionCodeSchedulerInstructionThe result of the call on the ITrigger'sTriggered(ICalendar?) method.
cancellationTokenCancellationTokenThe cancellation instruction.
Returns
Remarks
The default implementation does nothing.
TriggerFired(ITrigger, IJobExecutionContext, CancellationToken)
Called by the IScheduler when a ITrigger has fired, and it's associated IJobDetail is about to be executed.
It is called before the VetoJobExecution(ITrigger, IJobExecutionContext, CancellationToken) method of this interface.
public ValueTask TriggerFired(ITrigger trigger, IJobExecutionContext context, CancellationToken cancellationToken = default)
Parameters
triggerITriggerThe ITrigger that has fired.
contextIJobExecutionContextThe IJobExecutionContext that will be passed to the IJob'sExecute(IJobExecutionContext, CancellationToken) method.
cancellationTokenCancellationTokenThe cancellation instruction.
Returns
Remarks
The default implementation does nothing.
TriggerMisfired(ITrigger, IScheduler, CancellationToken)
Records a firing the scheduler missed.
public ValueTask TriggerMisfired(ITrigger trigger, IScheduler scheduler, CancellationToken cancellationToken = default)
Parameters
triggerITriggerschedulerISchedulercancellationTokenCancellationToken
Returns
Remarks
A misfire never becomes an execution, so it is invisible in the execution history however long a reader stares at it. The scheduler notifies before it applies the trigger's misfire instruction, so NextFireTimeUtc is still the firing that was missed rather than the one it was rescheduled to.
VetoJobExecution(ITrigger, IJobExecutionContext, CancellationToken)
Called by the IScheduler when a ITrigger has fired, and it's associated IJobDetail is about to be executed.
It is called after the TriggerFired(ITrigger, IJobExecutionContext, CancellationToken) method of this interface. If the implementation vetoes the execution (via returning true), the job's execute method will not be called.
public ValueTask<bool> VetoJobExecution(ITrigger trigger, IJobExecutionContext context, CancellationToken cancellationToken = default)
Parameters
triggerITriggerThe ITrigger that has fired.
contextIJobExecutionContextThe IJobExecutionContext that will be passed to the IJob'sExecute(IJobExecutionContext, CancellationToken) method.
cancellationTokenCancellationTokenThe cancellation instruction.
Returns
Remarks
The default implementation vetoes nothing.