Class Todo
Represents a unit of abstract work that is dispatched to a remote worker in an asynchronous fashion.
Todos are essentially a form of a queueable asynchronous one-way command object (Execute() does not return business object).
Todos are dequeued in the order of submission and SysStartDate constraint, processed sequentially or in-parallel depending on a SysParallelKey
Inheritance
System.Object
Todo
Implements
System.Collections.Generic.IEnumerable<System.Object>
System.Collections.IEnumerable
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Assembly: Azos.Sky.dll
Syntax
[Serializable]
public abstract class Todo : AmorphousTypedDoc, IConfigurable, IConfigurationPersistent, IEquatable<Doc>, IEnumerable<object>, IEnumerable, IValidatable, IJSONWritable, IAmorphousData, IDistributedStableHashProvider
Constructors
Todo()
Declaration
Properties
App
Declaration
public ISkyApplication App { get; }
Property Value
SysCreateTimeStampUTC
Declaration
public DateTime SysCreateTimeStampUTC { get; }
Property Value
Type |
Description |
System.DateTime |
|
SysID
Globally-unique ID of the TODO
Declaration
public GDID SysID { get; }
Property Value
SysParallelKey
Provides the key which is used for parallel processing: items with the same key
get executed sequentially
Declaration
public string SysParallelKey { get; set; }
Property Value
Type |
Description |
System.String |
|
SysPriority
Provides relative processing priority of processing
Declaration
public int SysPriority { get; set; }
Property Value
Type |
Description |
System.Int32 |
|
SysShardingKey
Provides the sharding key which is used for dispatching items into HostSets
Declaration
public string SysShardingKey { get; set; }
Property Value
Type |
Description |
System.String |
|
SysStartDate
When set, tells the system when (UTC) should the item be considered for processing
Declaration
public DateTime SysStartDate { get; set; }
Property Value
Type |
Description |
System.DateTime |
|
SysState
Provides current state machine execution state
Declaration
public Todo.ExecuteState SysState { get; }
Property Value
SysTries
Provides current machine execution retry state
Declaration
public int SysTries { get; }
Property Value
Type |
Description |
System.Int32 |
|
Methods
____Deserialize(GDID, DateTime)
Infrustructure method, developers do not call
Declaration
public void ____Deserialize(GDID id, DateTime ts)
Parameters
Type |
Name |
Description |
GDID |
id |
|
System.DateTime |
ts |
|
DoPrepareForEnqueuePostValidate(String)
Declaration
protected virtual void DoPrepareForEnqueuePostValidate(string targetName)
Parameters
Type |
Name |
Description |
System.String |
targetName |
|
DoPrepareForEnqueuePreValidate(String)
Declaration
protected virtual void DoPrepareForEnqueuePreValidate(string targetName)
Parameters
Type |
Name |
Description |
System.String |
targetName |
|
Equals(Doc)
Declaration
public override bool Equals(Doc other)
Parameters
Type |
Name |
Description |
Doc |
other |
|
Returns
Type |
Description |
System.Boolean |
|
Overrides
Execute(ITodoHost, DateTime)
Executes the todo. Override to perform actual logic.
You have to handle all exceptions, otherwise the leaked exception will
complete the todo with error. Return the result that describes whether the item completed or should be reexecuted again.
Keep in mind: Todos are not designed to execute long-running(tens+ of seconds) processes, launch other async workers instead
Declaration
protected abstract Todo.ExecuteState Execute(ITodoHost host, DateTime utcBatchNow)
Parameters
Type |
Name |
Description |
ITodoHost |
host |
|
System.DateTime |
utcBatchNow |
|
Returns
GetDistributedStableHash()
Declaration
public ulong GetDistributedStableHash()
Returns
Type |
Description |
System.UInt64 |
|
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type |
Description |
System.Int32 |
|
Overrides
MakeNew(IApplication, Type, IConfigSectionNode)
Factory method that creates new Todos from Type and Configuration assigning them new GDID
Declaration
public static Todo MakeNew(IApplication app, Type type, IConfigSectionNode args)
Parameters
Returns
MakeNew<TTodo>(IApplication)
Factory method that creates new Todos assigning them new GDID
Declaration
public static TTodo MakeNew<TTodo>(IApplication app)
where TTodo : Todo, new()
Parameters
Returns
Type Parameters
RetryAfterErrorInMs(DateTime)
Invoked to determine when should the next reexecution takes place after an error.
Throw exception if your buisiness case has exhausted all allowed retries as judjed by SysTries.
Return -1 to indicate the immediate execution without consideration of SysTries (default)
Declaration
protected virtual int RetryAfterErrorInMs(DateTime utcBatchNow)
Parameters
Type |
Name |
Description |
System.DateTime |
utcBatchNow |
|
Returns
Type |
Description |
System.Int32 |
|
ToString()
Declaration
public override string ToString()
Returns
Type |
Description |
System.String |
|
Overrides
System.Object.ToString()
Validate(String)
Declaration
public override Exception Validate(string targetName)
Parameters
Type |
Name |
Description |
System.String |
targetName |
|
Returns
Type |
Description |
System.Exception |
|
Overrides
ValidateAndPrepareForEnqueue(String)
Declaration
public void ValidateAndPrepareForEnqueue(string targetName)
Parameters
Type |
Name |
Description |
System.String |
targetName |
|
Implements
System.IEquatable<T>
System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable
Extension Methods