orleans icon indicating copy to clipboard operation
orleans copied to clipboard

Need a way to use built-in grain directory locally

Open seenu433 opened this issue 2 years ago • 2 comments

When using an Azure Storage or Redis Grain Directory, it is difficult to test the code locally against the built-in directory unless the code to decorate the grain in commented or conditionally compiled. Is there an elegant way to serve this purpose.

seenu433 avatar Jun 01 '23 21:06 seenu433

That's a very good point, we should add the same config methods for the built-in directory, so you can use it with a name

benjaminpetit avatar Jun 02 '23 13:06 benjaminpetit

If anyone else encounters the need for this, for now it seems registering a named singleton service IGrainDirectory with the name you need and a null implementation does the trick

hostBuilder.UseOrleans(builder =>
            {
                
                    builder.ConfigureServices(services =>
                    {
                        services.AddSingletonNamedService("directory-name", (_, _) => (IGrainDirectory?)null);
                    });
                }
            });

dmitrig89 avatar Dec 05 '23 16:12 dmitrig89