Class WorkItemDispatcher<T>
- Namespace
- DurableTask.Core
- Assembly
- DurableTask.Core.dll
Dispatcher class for fetching and processing work items of the supplied type
public class WorkItemDispatcher<T> : IDisposable
Type Parameters
T
The typed Object to dispatch
- Inheritance
-
WorkItemDispatcher<T>
- Implements
- Inherited Members
Constructors
WorkItemDispatcher(string, Func<T, string>, Func<TimeSpan, CancellationToken, Task<T>>, Func<T, Task>)
Creates a new Work Item Dispatcher with given name and identifier method
public WorkItemDispatcher(string name, Func<T, string> workItemIdentifier, Func<TimeSpan, CancellationToken, Task<T>> fetchWorkItem, Func<T, Task> processWorkItem)
Parameters
name
stringName identifying this dispatcher for logging and diagnostics
workItemIdentifier
Func<T, string>fetchWorkItem
Func<TimeSpan, CancellationToken, Task<T>>processWorkItem
Func<T, Task>
Fields
AbortWorkItem
Method to execute for aborting a work item
public Func<T, Task> AbortWorkItem
Field Value
GetDelayInSecondsAfterOnFetchException
Method to get a delay to wait after a fetch exception
public Func<Exception, int> GetDelayInSecondsAfterOnFetchException
Field Value
GetDelayInSecondsAfterOnProcessException
Method to get a delay to wait after a process exception
public Func<Exception, int> GetDelayInSecondsAfterOnProcessException
Field Value
SafeReleaseWorkItem
Method to execute for safely releasing a work item
public Func<T, Task> SafeReleaseWorkItem
Field Value
Properties
DispatcherCount
Gets or sets the number of dispatchers to create
public int DispatcherCount { get; set; }
Property Value
MaxConcurrentWorkItems
Gets or sets the maximum concurrent work items
public int MaxConcurrentWorkItems { get; set; }
Property Value
Methods
Dispose()
public void Dispose()
Dispose(bool)
Releases unmanaged and - optionally - managed resources.
protected virtual void Dispose(bool disposing)
Parameters
disposing
booltrue
to release both managed and unmanaged resources;false
to release only unmanaged resources.
GetFormattedLog(string, string)
Method for formatting log messages to include dispatcher name and id information
protected string GetFormattedLog(string dispatcherId, string message)
Parameters
Returns
- string
The formatted message
StartAsync()
Starts the work item dispatcher
public Task StartAsync()
Returns
Exceptions
- InvalidOperationException
Exception if dispatcher has already been started
StopAsync(bool)
Stops the work item dispatcher with optional forced flag
public Task StopAsync(bool forced)
Parameters
forced
boolFlag indicating whether to stop gracefully and wait for work item completion or just stop immediately