-
Notifications
You must be signed in to change notification settings - Fork 2k
/
AdoNetGrainStorageServiceCollectionExtensions.cs
68 lines (64 loc) · 3.76 KB
/
AdoNetGrainStorageServiceCollectionExtensions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
using Orleans.Configuration;
using Orleans.Hosting;
using Orleans.Providers;
using Orleans.Runtime;
using Orleans.Runtime.Hosting;
using Orleans.Storage;
namespace Orleans.Hosting
{
/// <summary>
/// <see cref="IServiceCollection"/> extensions.
/// </summary>
public static class AdoNetGrainStorageServiceCollectionExtensions
{
/// <summary>
/// Configure silo to use AdoNet grain storage as the default grain storage. Instructions on configuring your database are available at <see href="http://aka.ms/orleans-sql-scripts"/>.
/// </summary>
/// <remarks>
/// Instructions on configuring your database are available at <see href="http://aka.ms/orleans-sql-scripts"/>.
/// </remarks>
public static IServiceCollection AddAdoNetGrainStorage(this IServiceCollection services, Action<AdoNetGrainStorageOptions> configureOptions)
{
return services.AddAdoNetGrainStorage(ProviderConstants.DEFAULT_STORAGE_PROVIDER_NAME, ob => ob.Configure(configureOptions));
}
/// <summary>
/// Configure silo to use AdoNet grain storage for grain storage. Instructions on configuring your database are available at <see href="http://aka.ms/orleans-sql-scripts"/>.
/// </summary>
/// <remarks>
/// Instructions on configuring your database are available at <see href="http://aka.ms/orleans-sql-scripts"/>.
/// </remarks>
public static IServiceCollection AddAdoNetGrainStorage(this IServiceCollection services, string name, Action<AdoNetGrainStorageOptions> configureOptions)
{
return services.AddAdoNetGrainStorage(name, ob => ob.Configure(configureOptions));
}
/// <summary>
/// Configure silo to use AdoNet grain storage as the default grain storage. Instructions on configuring your database are available at <see href="http://aka.ms/orleans-sql-scripts"/>.
/// </summary>
/// <remarks>
/// Instructions on configuring your database are available at <see href="http://aka.ms/orleans-sql-scripts"/>.
/// </remarks>
public static IServiceCollection AddAdoNetGrainStorageAsDefault(this IServiceCollection services, Action<OptionsBuilder<AdoNetGrainStorageOptions>> configureOptions = null)
{
return services.AddAdoNetGrainStorage(ProviderConstants.DEFAULT_STORAGE_PROVIDER_NAME, configureOptions);
}
/// <summary>
/// Configure silo to use AdoNet grain storage for grain storage. Instructions on configuring your database are available at <see href="http://aka.ms/orleans-sql-scripts"/>.
/// </summary>
/// <remarks>
/// Instructions on configuring your database are available at <see href="http://aka.ms/orleans-sql-scripts"/>.
/// </remarks>
public static IServiceCollection AddAdoNetGrainStorage(this IServiceCollection services, string name,
Action<OptionsBuilder<AdoNetGrainStorageOptions>> configureOptions = null)
{
configureOptions?.Invoke(services.AddOptions<AdoNetGrainStorageOptions>(name));
services.ConfigureNamedOptionForLogging<AdoNetGrainStorageOptions>(name);
services.AddTransient<IPostConfigureOptions<AdoNetGrainStorageOptions>, DefaultStorageProviderSerializerOptionsConfigurator<AdoNetGrainStorageOptions>>();
services.AddTransient<IConfigurationValidator>(sp => new AdoNetGrainStorageOptionsValidator(sp.GetRequiredService<IOptionsMonitor<AdoNetGrainStorageOptions>>().Get(name), name));
return services.AddGrainStorage(name, AdoNetGrainStorageFactory.Create);
}
}
}