Skip to content

SystemTarget Methods

Base class for various system services, such as grain directory, reminder service, etc. Made public for GrainService to inherit from it. Can be turned to internal after a refactoring that would remove the inheritance relation.

Activate(Dictionary<string, object>, CancellationToken)

View source
public void Activate(Dictionary<string, object>? requestContext, CancellationToken cancellationToken)
Start activating this instance.

Parameters

requestContextDictionary<string, object>
The request context of the request which is causing this instance to be activated, if any.
cancellationTokenCancellationToken
A cancellation token which, when canceled, indicates that the process should complete promptly.

Deactivate(DeactivationReason, CancellationToken)

View source
public void Deactivate(DeactivationReason deactivationReason, CancellationToken cancellationToken)
Start deactivating this instance.

Parameters

deactivationReasonDeactivationReason
The reason for deactivation, for informational purposes.
cancellationTokenCancellationToken
A cancellation token which, when canceled, indicates that the process should complete promptly.

Dispose

View source
public void Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

GetComponent

View source
public TComponent? GetComponent<TComponent>()
Gets the component with the specified type.

Returns

The component with the specified type.

GetExtension

View source
public TExtensionInterface GetExtension<TExtensionInterface>()
Returns the grain extension registered for the provided TExtensionInterface.

Returns

The implementation of the extension which is bound to this grain.

GetOrSetExtension(Func<TExtension>)

View source
public (TExtension, TExtensionInterface) SystemTarget.GetOrSetExtension<TExtension, TExtensionInterface>(Func<TExtension> newExtensionFunc)
Binds an extension to an addressable object, if not already done.

Parameters

newExtensionFuncFunc<TExtension>
A factory function that constructs a new extension object.

Returns

A tuple, containing first the extension and second an addressable reference to the extension's interface.

Migrate(Dictionary<string, object>, CancellationToken)

View source
public void Migrate(Dictionary<string, object>? requestContext, CancellationToken cancellationToken)
Starts an attempt to migrating this instance to another location. Migration captures the current RequestContext, making it available to the activation's placement director so that it can consider it when selecting a new location. Migration will occur asynchronously, when no requests are executing, and will not occur if the activation's placement director does not select an alternative location.

Parameters

requestContextDictionary<string, object>
The request context, which is provided to the placement director so that it can be examined when selecting a new location.
cancellationTokenCancellationToken
A cancellation token which, when canceled, indicates that the process should complete promptly.

RegisterGrainTimer(Func<CancellationToken, Task>, TimeSpan, TimeSpan)

View source
public IGrainTimer RegisterGrainTimer(Func<CancellationToken, Task> callback, TimeSpan dueTime, TimeSpan period)
Registers a timer to send regular callbacks to this system target.

Parameters

callbackFunc<CancellationToken, Task>
The timer callback, which will fire whenever the timer becomes due.
dueTimeTimeSpan
The amount of time to delay before the callback is invoked. Specify System.Threading.Timeout.InfiniteTimeSpan to prevent the timer from starting. Specify System.TimeSpan.Zero to invoke the callback promptly.
periodTimeSpan
The time interval between invocations of callback. Specify System.Threading.Timeout.InfiniteTimeSpan to disable periodic signaling.

Returns

An System.IDisposable object which will cancel the timer upon disposal.

RegisterGrainTimer(Func<TState, CancellationToken, Task>, TState, TimeSpan, TimeSpan)

View source
public IGrainTimer RegisterGrainTimer<TState>(Func<TState, CancellationToken, Task> callback, TState state, TimeSpan dueTime, TimeSpan period)
Registers a timer to send regular callbacks to this grain. This timer will keep the current grain from being deactivated.

Parameters

callbackFunc<TState, CancellationToken, Task>
The timer callback, which will fire whenever the timer becomes due.
stateTState
The state object passed to the callback.
dueTimeTimeSpan
The amount of time to delay before the callback is invoked. Specify System.Threading.Timeout.InfiniteTimeSpan to prevent the timer from starting. Specify System.TimeSpan.Zero to invoke the callback promptly.
periodTimeSpan
The time interval between invocations of callback. Specify System.Threading.Timeout.InfiniteTimeSpan to disable periodic signaling.

Returns

An System.IDisposable object which will cancel the timer upon disposal.

RegisterTimer(Func<object?, Task>, object?, TimeSpan, TimeSpan)

View source
public IGrainTimer RegisterTimer(Func<object?, Task> callback, object? state, TimeSpan dueTime, TimeSpan period)
Registers a timer to send regular callbacks to this system target.

Parameters

callbackFunc<object?, Task>
The timer callback, which will fire whenever the timer becomes due.
stateobject?
The state object passed to the callback.
dueTimeTimeSpan
The amount of time to delay before the callback is invoked. Specify System.Threading.Timeout.InfiniteTimeSpan to prevent the timer from starting. Specify System.TimeSpan.Zero to invoke the callback promptly.
periodTimeSpan
The time interval between invocations of callback. Specify System.Threading.Timeout.InfiniteTimeSpan to disable periodic signaling.

Returns

An System.IDisposable object which will cancel the timer upon disposal.

SetComponent(TComponent?)

View source
public void SetComponent<TComponent>(TComponent? instance)
Sets the provided value as the component for type TComponent.

Parameters

instanceTComponent?
The component instance.

ToString

override
View source
public sealed override string ToString()
Returns a string that represents the current object.

Returns

A string that represents the current object.