Orleans.Iterator
This project allows to iterate over all grains that have some state(even nulled state) in persistence available. The iterator returns only the useable GrainId`s to prevent any activation of grains that are maybe unnessecary.
Packages
Contributors
- Berhnard Pollersp�ck The core maintainer of this Project.
- Don Alvarez: Contributor and maintainer for Orleans.Iterator.Azure
Sample Explaination
Server Setup
To configure the server side to be able to use this package you need to use the correct extension to add the required configurations. The Sample shows all current Providers.
builder.UseOrleans((hostContext, siloBuilder) =>
siloBuilder
.UseAdoNetGrainIterator(o =>
{
o.Invariant = adoNetInvariant;
o.ConnectionString = adoNetConnectionString;
})
.UseAzureBlobGrainIterator(o =>
{
o.ConnectionString = azureStorageConnectionString;
o.ContainerName = azureStorageContainerName;
});
);
Client Setup
To configure the client, you just need to call the 'UseIterator' Extension.
builder.UseOrleansClient(clientBuilder =>
{
clientBuilder.UseIterator();
});
Usage
To get a working async enumerator you just need to get a factory, which is used to request an iterator.
var iteratorFactory = host.Services.GetRequiredService<IIteratorFactory>();
var iterator = iteratorFactory.CreateIterator<IReverseGrain>(new[]
{
// Example for use with grain showing [GrainType("Reverse2")]
// and grain constructor showing [PersistentState("Reverse","STORE_NAME")]
new("Reverse2", "Reverse"),
});
await foreach (var entry in iterator)
{
Console.WriteLine($"ID: {entry}");
}
Sample Projects:
-
If you are only using one or the other of AdoNet or Azure Storage, comment out the unused storage types in
Orleans.Iterator.Dev/program.cs
andOrleans.Iterator.Dev.Server/program.cs
. -
Open the .NET Secrets file for the
Orleans.Iterator.Dev
project and copy into it the contents of theOrleans.Iterator.Dev/secrets.template.json
file. -
Edit the StorageType and ConnectionString properties in the file to match your storage configuration.
-
Open the .NET Secrets file for the
Orleans.Iterator.Dev.Server
project and copy into it the contents of theOrleans.Iterator.Dev.Server/secrets.template.json
file, editing in your own connection strings as appropriate. -
Edit the StorageType and ConnectionString properties in the file to match your storage configuration.
-
Start the
Orleans.Iterator.Dev.Server
project, which host the example silo. -
Start the
Orleans.Iterator.Dev
project, which hosts the example client and uses the iterator to find grains.
Contribution
Contributions in any way are appechiated (More providers, improvements, documentation or anything else). I Kindly ask you to create a Issue to talk about the planned changes or contact me directly on the Orleans Discord.