Table of Contents

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 string

Name 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

Func<T, Task>

GetDelayInSecondsAfterOnFetchException

Method to get a delay to wait after a fetch exception

public Func<Exception, int> GetDelayInSecondsAfterOnFetchException

Field Value

Func<Exception, int>

GetDelayInSecondsAfterOnProcessException

Method to get a delay to wait after a process exception

public Func<Exception, int> GetDelayInSecondsAfterOnProcessException

Field Value

Func<Exception, int>

SafeReleaseWorkItem

Method to execute for safely releasing a work item

public Func<T, Task> SafeReleaseWorkItem

Field Value

Func<T, Task>

Properties

DispatcherCount

Gets or sets the number of dispatchers to create

public int DispatcherCount { get; set; }

Property Value

int

MaxConcurrentWorkItems

Gets or sets the maximum concurrent work items

public int MaxConcurrentWorkItems { get; set; }

Property Value

int

Methods

Dispose()

public void Dispose()

Dispose(bool)

Releases unmanaged and - optionally - managed resources.

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

true 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

dispatcherId string

Id of the dispatcher

message string

The message to format

Returns

string

The formatted message

StartAsync()

Starts the work item dispatcher

public Task StartAsync()

Returns

Task

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 bool

Flag indicating whether to stop gracefully and wait for work item completion or just stop immediately

Returns

Task