Show / Hide Table of Contents

Class Grain<TGrainState>

Base class for a Grain with declared persistent state.

Inheritance
System.Object
Grain
Grain<TGrainState>
Implements
IAddressable
ILifecycleParticipant<IGrainLifecycle>
Inherited Members
Grain.GrainReference
Grain.GrainFactory
Grain.ServiceProvider
Grain.IdentityString
Grain.RuntimeIdentity
Grain.RegisterTimer(Func<Object, Task>, Object, TimeSpan, TimeSpan)
Grain.RegisterOrUpdateReminder(String, TimeSpan, TimeSpan)
Grain.UnregisterReminder(IGrainReminder)
Grain.GetReminder(String)
Grain.GetReminders()
Grain.GetStreamProvider(String)
Grain.DeactivateOnIdle()
Grain.DelayDeactivation(TimeSpan)
Grain.OnActivateAsync()
Grain.OnDeactivateAsync()
Namespace: Orleans
Assembly: Orleans.Core.Abstractions.dll
Syntax
public class Grain<TGrainState> : Grain, IAddressable, ILifecycleParticipant<IGrainLifecycle> where TGrainState : new ()
Type Parameters
Name Description
TGrainState

The class of the persistent state object

Constructors

| Improve this Doc View Source

Grain()

This constructor should never be invoked. We expose it so that client code (subclasses of this class) do not have to add a constructor. Client code should use the GrainFactory to get a reference to a Grain.

Declaration
protected Grain()
| Improve this Doc View Source

Grain(IGrainIdentity, IGrainRuntime, IStorage<TGrainState>)

Grain implementers do NOT have to expose this constructor but can choose to do so. This constructor is particularly useful for unit testing where test code can create a Grain and replace the IGrainIdentity, IGrainRuntime and State with test doubles (mocks/stubs).

Declaration
protected Grain(IGrainIdentity identity, IGrainRuntime runtime, IStorage<TGrainState> storage)
Parameters
Type Name Description
IGrainIdentity identity
IGrainRuntime runtime
IStorage<TGrainState> storage

Properties

| Improve this Doc View Source

State

Strongly typed accessor for the grain state

Declaration
protected TGrainState State { get; set; }
Property Value
Type Description
TGrainState

Methods

| Improve this Doc View Source

ClearStateAsync()

Clear the current grain state data from backing store.

Declaration
protected virtual Task ClearStateAsync()
Returns
Type Description
Task
| Improve this Doc View Source

Participate(IGrainLifecycle)

Declaration
public override void Participate(IGrainLifecycle lifecycle)
Parameters
Type Name Description
IGrainLifecycle lifecycle
Overrides
Grain.Participate(IGrainLifecycle)
| Improve this Doc View Source

ReadStateAsync()

Read the current grain state data from backing store.

Declaration
protected virtual Task ReadStateAsync()
Returns
Type Description
Task
Remarks

Any previous contents of the grain state data will be overwritten.

| Improve this Doc View Source

WriteStateAsync()

Write of the current grain state data into backing store.

Declaration
protected virtual Task WriteStateAsync()
Returns
Type Description
Task

Implements

IAddressable
ILifecycleParticipant<TLifecycleObservable>

Extension Methods

LoggerExtensionMethods.GetLogger(Grain, String)
LoggerExtensionMethods.GetLogger(Grain)
Orleans.Storage.GrainStorageExtensions.GetGrainStorage(Orleans.Grain, IServiceProvider)
ImmutableExt.AsImmutable<T>(T)
  • Improve this Doc
  • View Source
Back to top Generated by DocFX