@@ -25,7 +25,11 @@ public static ISiloBuilder AddAzureBlobGrainStorageAsDefault(this ISiloBuilder b
25
25
/// </summary>
26
26
public static ISiloBuilder AddAzureBlobGrainStorage ( this ISiloBuilder builder , string name , Action < AzureBlobStorageOptions > configureOptions )
27
27
{
28
- return builder . ConfigureServices ( services => services . AddAzureBlobGrainStorage ( name , configureOptions ) ) ;
28
+ return builder . AddGrainStorage ( name , configure =>
29
+ {
30
+ configure . UseOrleansSerializer ( ) ;
31
+ configure . UseAzureBlob ( configureOptions ) ;
32
+ } ) ;
29
33
}
30
34
31
35
/// <summary>
@@ -41,48 +45,41 @@ public static ISiloBuilder AddAzureBlobGrainStorageAsDefault(this ISiloBuilder b
41
45
/// </summary>
42
46
public static ISiloBuilder AddAzureBlobGrainStorage ( this ISiloBuilder builder , string name , Action < OptionsBuilder < AzureBlobStorageOptions > > configureOptions = null )
43
47
{
44
- return builder . ConfigureServices ( services => services . AddAzureBlobGrainStorage ( name , configureOptions ) ) ;
48
+ return builder . AddGrainStorage ( name , configure =>
49
+ {
50
+ configure . UseOrleansSerializer ( ) ;
51
+ configure . UseAzureBlob ( configureOptions ) ;
52
+ } ) ;
45
53
}
46
54
47
55
/// <summary>
48
- /// Configure silo to use azure blob storage as the default grain storage.
56
+ /// Use Azure Blob as grain storage
49
57
/// </summary>
50
- public static IServiceCollection AddAzureBlobGrainStorageAsDefault ( this IServiceCollection services , Action < AzureBlobStorageOptions > configureOptions )
58
+ public static void UseAzureBlob ( this IGrainStorageProviderConfigurator configurator , Action < AzureBlobStorageOptions > options )
51
59
{
52
- return services . AddAzureBlobGrainStorage ( ProviderConstants . DEFAULT_STORAGE_PROVIDER_NAME , ob => ob . Configure ( configureOptions ) ) ;
60
+ configurator . UseAzureBlob ( builder => builder . Configure ( options ) ) ;
53
61
}
54
62
55
63
/// <summary>
56
- /// Configure silo to use azure blob storage for grain storage.
64
+ /// Use Azure Blob as grain storage
57
65
/// </summary>
58
- public static IServiceCollection AddAzureBlobGrainStorage ( this IServiceCollection services , string name , Action < AzureBlobStorageOptions > configureOptions )
66
+ public static void UseAzureBlob ( this IGrainStorageProviderConfigurator configurator , Action < OptionsBuilder < AzureBlobStorageOptions > > configureOptions )
59
67
{
60
- return services . AddAzureBlobGrainStorage ( name , ob => ob . Configure ( configureOptions ) ) ;
61
- }
68
+ configurator . ConfigureStorage ( AzureBlobGrainStorageFactory . Create , configureOptions ) ;
69
+ configurator . ConfigureDelegate . Invoke ( services =>
70
+ {
71
+ if ( string . Equals ( configurator . Name , ProviderConstants . DEFAULT_STORAGE_PROVIDER_NAME , StringComparison . Ordinal ) )
72
+ {
73
+ services . TryAddSingleton ( sp => sp . GetServiceByName < IGrainStorage > ( ProviderConstants . DEFAULT_STORAGE_PROVIDER_NAME ) ) ;
74
+ }
62
75
63
- /// <summary>
64
- /// Configure silo to use azure blob storage as the default grain storage.
65
- /// </summary>
66
- public static IServiceCollection AddAzureBlobGrainStorageAsDefault ( this IServiceCollection services , Action < OptionsBuilder < AzureBlobStorageOptions > > configureOptions = null )
67
- {
68
- return services . AddAzureBlobGrainStorage ( ProviderConstants . DEFAULT_STORAGE_PROVIDER_NAME , configureOptions ) ;
69
- }
76
+ services . AddSingletonNamedService (
77
+ configurator . Name ,
78
+ ( s , n ) => ( ILifecycleParticipant < ISiloLifecycle > ) s . GetRequiredServiceByName < IGrainStorage > ( n ) ) ;
70
79
71
- /// <summary>
72
- /// Configure silo to use azure blob storage for grain storage.
73
- /// </summary>
74
- public static IServiceCollection AddAzureBlobGrainStorage ( this IServiceCollection services , string name ,
75
- Action < OptionsBuilder < AzureBlobStorageOptions > > configureOptions = null )
76
- {
77
- configureOptions ? . Invoke ( services . AddOptions < AzureBlobStorageOptions > ( name ) ) ;
78
- services . AddTransient < IConfigurationValidator > ( sp => new AzureBlobStorageOptionsValidator ( sp . GetRequiredService < IOptionsMonitor < AzureBlobStorageOptions > > ( ) . Get ( name ) , name ) ) ;
79
- services . ConfigureNamedOptionForLogging < AzureBlobStorageOptions > ( name ) ;
80
- if ( string . Equals ( name , ProviderConstants . DEFAULT_STORAGE_PROVIDER_NAME , StringComparison . Ordinal ) )
81
- {
82
- services . TryAddSingleton ( sp => sp . GetServiceByName < IGrainStorage > ( ProviderConstants . DEFAULT_STORAGE_PROVIDER_NAME ) ) ;
83
- }
84
- return services . AddSingletonNamedService < IGrainStorage > ( name , AzureBlobGrainStorageFactory . Create )
85
- . AddSingletonNamedService < ILifecycleParticipant < ISiloLifecycle > > ( name , ( s , n ) => ( ILifecycleParticipant < ISiloLifecycle > ) s . GetRequiredServiceByName < IGrainStorage > ( n ) ) ;
80
+ services . AddTransient < IConfigurationValidator > (
81
+ sp => new AzureBlobStorageOptionsValidator ( sp . GetRequiredService < IOptionsMonitor < AzureBlobStorageOptions > > ( ) . Get ( configurator . Name ) , configurator . Name ) ) ;
82
+ } ) ;
86
83
}
87
84
}
88
85
}
0 commit comments