2015-10-02 37 views

回答

1

我只能回答奧爾良。

有表示堅持要求各個部分的一些樣品狀態:

https://github.com/dotnet/orleans/tree/master/Samples/StorageProviders

基本上你創建一個類的五穀狀態存儲這樣的:

public class MyState : GrainState 
{ 
    public string StringValue { get; set; } 
    public int IntValue { get; set; } 
    public DateTime DateTimeValue { get; set; } 
    public Guid GuidValue { get; set; } 
    public IGrain1 GrainValue { get; set; } 
} 

(確定,所以這不是POCO)

然後你可以創建一個使用這個類的穀物,因爲它的狀態:

[ StorageProvider(ProviderName = "myprovider") ] 
public class Grain1 : Grain<MyState>, IGrain1 
{ 
    public Task Set(string stringValue, int intValue, DateTime dateTimeValue, Guid guidValue, IGrain1 grainValue) 
    { 
    State.StringValue = stringValue; 
    State.IntValue = intValue; 
    State.DateTimeValue = dateTimeValue; 
    State.GuidValue = guidValue; 
    State.GrainValue = grainValue; 
    return WriteStateAsync(); 
    } 
} 

用於實際存儲狀態的底層機制是配置選項。開箱即用的Azure表存儲,但還有其他幾個選項,包括Redis,Azure Blob存儲和SQL Server。