You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By default, the parameters passed into the storage provider instance for a tenant are the tenant provider name (which contains the tenant Id) and the tenant options. Some storage providers may expect a different (wrapper) type for the options, or you may want to pass in additional parameters (e.g. `ClusterOptions`).
54
+
55
+
To do this, you can pass in an optional `GrainStorageProviderParametersFactory<TGrainStorageOptions>? getProviderParameters` parameter.
56
+
57
+
E.g. the Orleans ADO.NET storage provider constructor expects an `IOptions<AdoNetGrainStorageOptions>` instead of an `AdoNetGrainStorageOptions`. You can use `getProviderParameters` to wrap the `AdoNetGrainStorageOptions` in an `IOptions<AdoNetGrainStorageOptions>`:
Note that you do not need to include the `tenantProviderName` in the returned provider parameters; it is added automatically.
69
+
70
+
The parameters passed to `getProviderParameters` allow to access relevant services from DI to retrieve additional provider parameters, if needed.
71
+
52
72
### Add multitenant streams
53
73
To configure a silo to use a specific stream provider type as a named stream provider with tenant separation, use `AddMultitenantStreams`. Any Orleans stream provider can be used:
Copy file name to clipboardExpand all lines: src/Orleans.Multitenant/Extensions.cs
+30-1Lines changed: 30 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -39,12 +39,14 @@ public static ISiloBuilder AddMultitenantCommunicationSeparation(
39
39
/// This storage provider instance will not be used to store state - it is only called at silo initialization, to ensure that any shared dependencies needed by the tenant-specific storage provider instances are initialized
40
40
/// </param>
41
41
/// <param name="configureTenantOptions">Action to configure the supplied <typeparamref name="TGrainStorageOptions"/> based on the supplied tenant ID (e.g. use the tenant ID in a storage table name to realize separate storage per tenant)</param>
42
+
/// <param name="getProviderParameters">Optional factory to transform or add constructor parameters for tenant grain storage providers; for details see <see cref="GrainStorageProviderParametersFactory{TGrainStorageOptions}"/><br />When omitted, only <typeparamref name="TGrainStorageOptions"/> is passed in</param>
42
43
/// <param name="configureOptions">Action to configure the <see cref="MultitenantStorageOptions"/></param>
43
44
/// <returns>The same instance of the <see cref="ISiloBuilder"/> for chaining</returns>
@@ -70,13 +73,15 @@ public static ISiloBuilder AddMultitenantGrainStorageAsDefault<TGrainStorage, TG
70
73
/// This storage provider instance will not be used to store state - it is only called at silo initialization, to ensure that any shared dependencies needed by the tenant-specific storage provider instances are initialized
71
74
/// </param>
72
75
/// <param name="configureTenantOptions">Action to configure the supplied <typeparamref name="TGrainStorageOptions"/> based on the supplied tenant ID (e.g. use the tenant ID in a storage table name to realize separate storage per tenant)</param>
76
+
/// <param name="getProviderParameters">Optional factory to transform or add constructor parameters for tenant grain storage providers; for details see <see cref="GrainStorageProviderParametersFactory{TGrainStorageOptions}"/><br />When omitted, only <typeparamref name="TGrainStorageOptions"/> is passed in</param>
73
77
/// <param name="configureOptions">Action to configure the <see cref="MultitenantStorageOptions"/></param>
74
78
/// <returns>The same instance of the <see cref="ISiloBuilder"/> for chaining</returns>
/// <summary>Configure silo to use a specific stream provider type as a named stream provider, with tenant separation</summary>
@@ -121,12 +127,14 @@ public static class ServiceCollectionExtensions
121
127
/// This storage provider instance will not be used to store state - it is only called at silo initialization, to ensure that any shared dependencies needed by the tenant-specific storage provider instances are initialized
122
128
/// </param>
123
129
/// <param name="configureTenantOptions">Action to configure the supplied <typeparamref name="TGrainStorageOptions"/> based on the supplied tenant ID (e.g. use the tenant ID in a storage table name to realize separate storage per tenant)</param>
130
+
/// <param name="getProviderParameters">Optional factory to transform or add constructor parameters for tenant grain storage providers; for details see <see cref="GrainStorageProviderParametersFactory{TGrainStorageOptions}"/><br />When omitted, only <typeparamref name="TGrainStorageOptions"/> is passed in</param>
124
131
/// <param name="configureOptions">Action to configure the <see cref="MultitenantStorageOptions"/></param>
125
132
/// <returns>The same instance of the <see cref="IServiceCollection"/> for chaining</returns>
@@ -135,6 +143,7 @@ public static IServiceCollection AddMultitenantGrainStorageAsDefault<TGrainStora
135
143
ProviderConstants.DEFAULT_STORAGE_PROVIDER_NAME,
136
144
addStorageProvider,
137
145
configureTenantOptions,
146
+
getProviderParameters,
138
147
configureOptions);
139
148
140
149
/// <summary>
@@ -152,13 +161,15 @@ public static IServiceCollection AddMultitenantGrainStorageAsDefault<TGrainStora
152
161
/// This storage provider instance will not be used to store state - it is only called at silo initialization, to ensure that any shared dependencies needed by the tenant-specific storage provider instances are initialized
153
162
/// </param>
154
163
/// <param name="configureTenantOptions">Action to configure the supplied <typeparamref name="TGrainStorageOptions"/> based on the supplied tenant ID (e.g. use the tenant ID in a storage table name to realize separate storage per tenant)</param>
164
+
/// <param name="getProviderParameters">Optional factory to transform or add constructor parameters for tenant grain storage providers; for details see <see cref="GrainStorageProviderParametersFactory{TGrainStorageOptions}"/><br />When omitted, only <typeparamref name="TGrainStorageOptions"/> is passed in</param>
155
165
/// <param name="configureOptions">Action to configure the <see cref="MultitenantStorageOptions"/></param>
156
166
/// <returns>The same instance of the <see cref="IServiceCollection"/> for chaining</returns>
/// <param name="providerName">The name - without the tenant id - of the provider; can be used to access named provider services that are not tenant specific</param>
194
+
/// <param name="tenantProviderName">The name - including the tenant id - of the tenant provider; can be used to access named provider services that are tenant specific</param>
195
+
/// <param name="options">The options to pass to the provider. Note that configureTenantOptions and options validation have already been executed on this</param>
196
+
/// <returns>The tenant storage provider construction parameters to pass to DI. Don't include <paramref name="tenantProviderName"/> in these; it is added automatically</returns>
0 commit comments