Last active
January 25, 2018 02:43
-
-
Save dcomartin/37b7e43cf11e388d076d16cbcc20b7a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CustomerState | |
{ | |
public Guid Id { get; set; } | |
public string Name { get; set; } | |
} | |
public interface ICustomerGrain : IStateHolderGrain<CustomerState> { } | |
[StorageProvider(ProviderName = "OrleansStorage")] | |
public class CustomerGrain : StateHolderGrain<CustomerState>, ICustomerGrain {} | |
public static class CustomerStateService | |
{ | |
public static async Task CreateCustomer(Guid id, string name) | |
{ | |
var state = new CustomerState | |
{ | |
Id = id, | |
Name = name | |
}; | |
var grain = DemoOrleansClient.ClusterClient.GetGrain<ICustomerGrain>(id); | |
await grain.SetItem(state); | |
} | |
public static async Task<CustomerState> GetCustomer(Guid id) | |
{ | |
var grain = DemoOrleansClient.ClusterClient.GetGrain<ICustomerGrain>(id); | |
return await grain.GetItem(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment