![]() |
VOOZH | about |
Microsoft.Orleans.Clustering.Cosmos
Additional DetailsThis project was merged to Orleans main codebase. Starting on Orleans v7.2.0, all the providers are published to NuGet along with the core Orleans packages. New issues and contributions should be directed to https://github.com/dotnet/orleans.
dotnet add package Orleans.Clustering.CosmosDB --version 3.0.4
NuGet\Install-Package Orleans.Clustering.CosmosDB -Version 3.0.4
<PackageReference Include="Orleans.Clustering.CosmosDB" Version="3.0.4" />
<PackageVersion Include="Orleans.Clustering.CosmosDB" Version="3.0.4" />Directory.Packages.props
<PackageReference Include="Orleans.Clustering.CosmosDB" />Project file
paket add Orleans.Clustering.CosmosDB --version 3.0.4
#r "nuget: Orleans.Clustering.CosmosDB, 3.0.4"
#:package Orleans.Clustering.CosmosDB@3.0.4
#addin nuget:?package=Orleans.Clustering.CosmosDB&version=3.0.4Install as a Cake Addin
#tool nuget:?package=Orleans.Clustering.CosmosDB&version=3.0.4Install as a Cake Tool
It is not mandatory to use all the providers at once. Just pick the one you are interested in from the samples and you should be good as they don't depend on each other.
Example
var silo = new SiloHostBuilder()
.UseCosmosDBMembership(opt =>
{
// Use CosmosDB as the cluster membership table.
// Configure CosmosDB settings in opt.
})
.AddCosmosDBGrainStorageAsDefault(opt =>
{
// Configure CosmosDB persistence provider.
// Configure CosmosDB settings in opt.
})
.UseCosmosDBReminderService(op =>
{
// Configure CosmosDB reminders provider.
// Configure CosmosDB settings in opt.
})
.Build();
await silo.StartAsync();
Example
var clientConfig = new ClientConfiguration();
var client = new ClientBuilder()
.UseCosmosDBGatewayListProvider(opt =>
{
// Use CosmosDB as the Gateway list provider.
// Configure CosmosDB settings in opt.
})
.Build();
await client.Connect();
Great! Now you have Orleans configured to use Azure CosmosDB as the back storage for its providers!
By default the grain type is used as partition key, however this limits the storage size for a single grain type as a single logical partition has an upper limit of 10 GB storage.
It is possible to override the default by implementing a custom IPartitionKeyProvider. The custom implementation of IPartitionKeyProvider can be registered by using the dependency injection usual methods like:
services.AddSingleton<IPartitionKeyProvider, MyCustomPKProvider>();
There is also some overloads of AddCosmosDBGrainStorage and AddCosmosDBGrainStorageAsDefault that allow you to pass the IPartitionKeyProvider implementation.
If no IPartitionKeyProvider is used, the default one will be uses which use full name of the grain type will be used as partition key.
Example
public class PrimaryKeyPartitionKeyProvider : IPartitionKeyProvider
{
public ValueTask<string> GetPartitionKey(string grainType, GrainReference grainReference)
{
return new ValueTask<string>(grainReference.GetPrimaryKey().ToString());
}
}
The example above use the Primary key as partition key.
In order to prevent cross partition queries the partition key must be available to the client upon reading data, hence the delegate input is limited to the graintype and grainreference. The grain reference contains the grain id, with combination, and a type identifier.
For further details on partitioning in CosmosDB see https://docs.microsoft.com/en-us/azure/cosmos-db/partitioning-overview.
The change will not affect existing systems. Configuring custom partition key builders for an existing system will throw a BadGrainStorageConfigException stating incompatibility. To start using custom partition key builders the old documents must be updated with a /PartitionKey property where the value is set using the same functionality as the Func<GrainReference, string> delegate specified in options. Once all documents are updated, the data must be migrated to a new CosmosDB collection using Azure Data Factory, CosmosDB Migration tool or custom code.
The current indexing fork relies on CosmosDB stored procedures for lookup. As stored procedures must be executed against a specific partition, the use of custom partition key builders is not compatible with the Orleans indexing fork.
PRs and feedback are very welcome!
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 3.0.4 | 172,159 | 6/16/2021 | 3.0.4 is deprecated because it is no longer maintained. |
| 3.0.3 | 2,461 | 4/24/2020 | |
| 3.0.2 | 784 | 3/23/2020 | |
| 3.0.1 | 1,029 | 1/29/2020 | |
| 3.0.0 | 984 | 11/14/2019 | |
| 1.3.0 | 1,208 | 4/3/2019 | |
| 1.2.1 | 982 | 3/20/2019 | |
| 1.2.0 | 986 | 3/19/2019 | |
| 1.1.42 | 1,613 | 9/28/2018 | |
| 1.1.41 | 1,079 | 9/28/2018 | |
| 1.1.40 | 1,721 | 3/28/2018 | |
| 1.1.38 | 1,457 | 3/28/2018 | |
| 1.1.0-rc2-36 | 1,450 | 3/13/2018 | |
| 1.1.0-rc1-34 | 1,456 | 3/12/2018 | |
| 1.1.0-rc1-29 | 1,442 | 2/27/2018 | |
| 1.0.1-preview-27 | 1,410 | 2/10/2018 | |
| 1.0.1-preview-25 | 1,464 | 2/5/2018 | |
| 1.0.1-preview-21 | 1,225 | 2/1/2018 | |
| 1.0.1-preview-19 | 1,439 | 2/1/2018 | |
| 1.0.0-preview-17 | 1,232 | 2/1/2018 |