Install
dotnet add package Microsoft.Orleans.Persistence.DynamoDB --version 9.2.0
| Product | Versions |
|---|---|
| .NET |
README
Microsoft Orleans Persistence for DynamoDB
Introduction
Microsoft Orleans Persistence for DynamoDB provides grain persistence for Microsoft Orleans using Amazon's DynamoDB. This allows your grains to persist their state in DynamoDB and reload it when they are reactivated.
Getting Started
To use this package, install it via NuGet:
dotnet add package Microsoft.Orleans.Persistence.DynamoDB
Example - Configuring DynamoDB Persistence
using Microsoft.Extensions.Hosting;
using Orleans.Configuration;
using Orleans.Hosting;
var builder = Host.CreateApplicationBuilder(args)
.UseOrleans(siloBuilder =>
{
siloBuilder
.UseLocalhostClustering()
// Configure DynamoDB as grain storage
.AddDynamoDBGrainStorage(
name: "dynamoStore",
configureOptions: options =>
{
options.AccessKey = "YOUR_AWS_ACCESS_KEY";
options.SecretKey = "YOUR_AWS_SECRET_KEY";
options.Region = "us-east-1";
options.TableName = "OrleansGrainState";
options.CreateIfNotExists = true;
});
});
// Run the host
await builder.RunAsync();
Example - Using Grain Storage in a Grain
// Define grain state class
public class MyGrainState
{
public string Data { get; set; }
public int Version { get; set; }
}
// Grain implementation that uses the DynamoDB storage
public class MyGrain : Grain, IMyGrain, IGrainWithStringKey
{
private readonly IPersistentState<MyGrainState> _state;
public MyGrain([PersistentState("state", "dynamoStore")] IPersistentState<MyGrainState> state)
{
_state = state;
}
public async Task SetData(string data)
{
_state.State.Data = data;
_state.State.Version++;
await _state.WriteStateAsync();
}
public Task<string> GetData()
{
return Task.FromResult(_state.State.Data);
}
}
Documentation
For more comprehensive documentation, please refer to:
Feedback & Contributing
- If you have any issues or would like to provide feedback, please open an issue on GitHub
- Join our community on Discord
- Follow the @msftorleans Twitter account for Orleans announcements
- Contributions are welcome! Please review our contribution guidelines
- This project is licensed under the MIT license
Changes from Previous Version
No structural changes between v9.2.0-preview3 and v9.2.0.
Adoption Assessment
A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.
Compatibility metadata lists 1 target framework; confirm the exact target used by your application.The published metadata declares 29 direct dependency entries across framework groups. Inspect the resolved dependency graph for your target framework.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.