private async Task <AzureTableGrainStorage> InitAzureTableGrainStorage(AzureTableStorageOptions options) { AzureTableGrainStorage store = ActivatorUtilities.CreateInstance <AzureTableGrainStorage>(this.providerRuntime.ServiceProvider, options, "TestStorage"); SiloLifecycle lifecycle = ActivatorUtilities.CreateInstance <SiloLifecycle>(this.providerRuntime.ServiceProvider); store.Participate(lifecycle); await lifecycle.OnStart(); return(store); }
private async Task <DynamoDBGrainStorage> InitDynamoDBGrainStorage(DynamoDBStorageOptions options) { DynamoDBGrainStorage store = ActivatorUtilities.CreateInstance <DynamoDBGrainStorage>(this.providerRuntime.ServiceProvider, options); SiloLifecycle lifecycle = ActivatorUtilities.CreateInstance <SiloLifecycle>(this.providerRuntime.ServiceProvider); store.Participate(lifecycle); await lifecycle.OnStart(); return(store); }
private async Task <DynamoDBGrainStorage> InitDynamoDBTableStorageProvider(IProviderRuntime runtime, string storageName) { var options = new DynamoDBStorageOptions(); options.Service = AWSTestConstants.Service; DynamoDBGrainStorage store = ActivatorUtilities.CreateInstance <DynamoDBGrainStorage>(runtime.ServiceProvider, options); SiloLifecycle lifecycle = ActivatorUtilities.CreateInstance <SiloLifecycle>(runtime.ServiceProvider); store.Participate(lifecycle); await lifecycle.OnStart(); return(store); }
/// <summary> /// Returns a correct implementation of the persistence provider according to environment variables. /// </summary> /// <remarks>If the environment invariants have failed to hold upon creation of the storage provider, /// a <em>null</em> value will be provided.</remarks> public async Task <IGrainStorage> GetStorageProvider(string storageInvariant) { //Make sure the environment invariants hold before trying to give a functioning SUT instantiation. //This is done instead of the constructor to have more granularity on how the environment should be initialized. try { using (await StorageLock.LockAsync()) { if (AdoNetInvariants.Invariants.Contains(storageInvariant)) { if (!StorageProviders.ContainsKey(storageInvariant)) { Storage = Invariants.EnsureStorageForTesting(Invariants.ActiveSettings.ConnectionStrings.First(i => i.StorageInvariant == storageInvariant)); var options = new AdoNetGrainStorageOptions() { ConnectionString = Storage.Storage.ConnectionString, Invariant = storageInvariant }; var siloOptions = new SiloOptions() { ServiceId = Guid.NewGuid() }; var storageProvider = new AdoNetGrainStorage(DefaultProviderRuntime.ServiceProvider.GetService <ILogger <AdoNetGrainStorage> >(), DefaultProviderRuntime, Options.Create(options), Options.Create(siloOptions), storageInvariant + "_StorageProvider"); var siloLifeCycle = new SiloLifecycle(NullLoggerFactory.Instance); storageProvider.Participate(siloLifeCycle); await siloLifeCycle.OnStart(CancellationToken.None); StorageProviders[storageInvariant] = storageProvider; } } } } catch { StorageProviders.Add(storageInvariant, null); } return(StorageProviders[storageInvariant]); }