Class BaseSchedulableTask
Base class for schedulable tasks.
Inherited Members
Namespace: Cognite.Extractor.Utils.Unstable.Tasks
Assembly: ExtractorUtils.dll
Syntax
public abstract class BaseSchedulableTask
Properties
| Edit this page View SourceCancellationIsFatal
Return whether this task being cancelled via an explicit Stop action (CancelTask(string, string?)) should be considered fatal, on the same terms as ErrorIsFatal.
Defaults to ErrorIsFatal: a task that is fatal-on-error is, by
default, also fatal if stopped before it completes, since the framework has no
way to know whether this particular task can safely be interrupted mid-run.
Override this to return false only if the task is known to tolerate being
stopped at any point without leaving the extractor in an inconsistent state.
This has no effect on cancellation caused by the extractor itself shutting down
(e.g. Shutdown()/DisposeAsync()) -- that is always non-fatal,
regardless of this setting, since there is nothing left to protect by crashing a
process that is already exiting.
Declaration
public virtual bool CancellationIsFatal { get; }
Property Value
| Type | Description |
|---|---|
| bool |
ErrorIsFatal
Return whether this task failing should be considered fatal and terminate the task scheduler completely.
Declaration
public abstract bool ErrorIsFatal { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Metadata
Provide metadata about the task, reported to integration during startup.
Declaration
public abstract TaskMetadata Metadata { get; }
Property Value
| Type | Description |
|---|---|
| TaskMetadata |
Name
Unique name of the task.
Declaration
public abstract string Name { get; }
Property Value
| Type | Description |
|---|---|
| string |
ReadyCallback
Callback registered on task startup, should be called to notify the task runner that this task is now ready to run.
Declaration
protected Action? ReadyCallback { get; }
Property Value
| Type | Description |
|---|---|
| Action |
Schedule
Task schedule, how often it runs automatically. Should be null if the task only runs manually or on startup.
Declaration
public virtual ITimeSpanProvider? Schedule { get; }
Property Value
| Type | Description |
|---|---|
| ITimeSpanProvider |
Methods
| Edit this page View SourceCanRunNow()
Return whether the task can run now.
The task should make sure to call the callback provided in RegisterReadyCallback
once this will return true.
Once this returns true, the task may be started immediately.
Note that this may be called frequently, and should not do any expensive calculations.
Declaration
public abstract bool CanRunNow()
Returns
| Type | Description |
|---|---|
| bool |
RegisterReadyCallback(Action)
Register a callback that should be invoked once CanRunNow returns true.
You may call this callback even if CanRunNow isn't guaranteed to return true.
Declaration
public virtual void RegisterReadyCallback(Action callback)
Parameters
| Type | Name | Description |
|---|---|---|
| Action | callback |
Run(BaseErrorReporter, CancellationToken)
Run the task, this may throw an exception which is treated as a fatal error.
Declaration
public abstract Task<TaskUpdatePayload?> Run(BaseErrorReporter task, CancellationToken token)
Parameters
| Type | Name | Description |
|---|---|---|
| BaseErrorReporter | task | Callbacks for reporting errors. |
| CancellationToken | token | Optional cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<TaskUpdatePayload> |