daprlabs / Orleans.Journal

Event Sourcing for Microsoft Orleans (https://github.com/dotnet/orleans)

Home Page:https://github.com/dotnet/orleans

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NOTE: This repository is obsolete and will not work on current versions of Orleans!

Orleans.Journal

Event Sourcing for Microsoft Orleans (https://github.com/dotnet/orleans)

Usage

Grain implementations must have the [JournalProvider("SomeCloudConfigProperty")] attribute, where the provider is the name of a property defined in the Azure Cloud Service's Configuration.

Providers take the format: Provider=AssemblyQualifiedClassNameOfProvider;OtherSetting=OtherValue;YetAnotherSetting=YetAnotherValue

Example: Provider=Orleans.Journal.AzureTable.AzureTableJournal,Orleans.Journal.AzureTable;Table=grainJournal;ConnectionStringSetting=JournalConnection

  • Derive grain implementation from JournaledGrainBase<TGrain, TGrainState>.
  • Persist a message with await this.Journal.WriteJournal();.
  • Access state by modifying this.State.Value.

See StackGrain.cs for an example of usage. Something akin to this:

[JournalProvider("DefaultJournal")]
public class StackGrain : JournaledGrainBase<StackGrain, Stack<int>>, IStackGrain
{
    public async Task<int> GetSize()
    {
        return this.State.Value.Count;
    }

    public async Task Push(int value)
    {
        await this.Journal.WriteJournal();
        this.State.Value.Push(value);
    }

    public async Task<int> Pop()
    {
        await this.Journal.WriteJournal();
        return this.State.Value.Pop();
    }
}

License

Please see the included LICENSE file. Note that the contents of the Dependencies folder are licensed separately and contain their own license file.

About

Event Sourcing for Microsoft Orleans (https://github.com/dotnet/orleans)

https://github.com/dotnet/orleans


Languages

Language:C# 100.0%