private async Task Start(CancellationToken ct) { var stopWatch = Stopwatch.StartNew(); IStreamProviderImpl provider = this.services.GetServiceByName <TService>(this.config.Name) as IStreamProviderImpl; if (provider == null) { return; } await Schedule(() => provider.Start()); stopWatch.Stop(); this.logger.Info(ErrorCode.SiloStartPerfMeasure, $"Starting provider {this.config.Name} of type {this.config.Type} in stage {this.startStage} took {stopWatch.ElapsedMilliseconds} Milliseconds."); }
public Task Init(string name, IProviderRuntime runtime, IProviderConfiguration configuration) { Name = name; system = runtime.ServiceProvider.GetRequiredService <IActorSystem>(); specifications = StreamSubscriptionMatcher.configuration.Find(name) ?? Enumerable.Empty <StreamSubscriptionSpecification>(); var type = Type.GetType(configuration.Properties[TypeKey]); Debug.Assert(type != null); provider = (IStreamProviderImpl)Activator.CreateInstance(type); return(provider.Init(name, runtime, configuration)); }
internal StreamImpl(StreamId streamId, IStreamProviderImpl provider, bool isRewindable) { if (null == streamId) { throw new ArgumentNullException("streamId"); } if (null == provider) { throw new ArgumentNullException("provider"); } this.streamId = streamId; this.provider = provider; producerInterface = null; consumerInterface = null; initLock = new object(); this.isRewindable = isRewindable; }
private async Task Start(CancellationToken ct) { var stopWatch = Stopwatch.StartNew(); try { IStreamProviderImpl provider = this.provider.Value as IStreamProviderImpl; if (provider == null) return; await Schedule(() => provider.Start()); stopWatch.Stop(); this.logger.Info(ErrorCode.SiloStartPerfMeasure, $"Starting stream provider {this.config.Name} of type {this.config.Type} in stage {this.startStage} took {stopWatch.ElapsedMilliseconds} Milliseconds."); } catch (Exception ex) { stopWatch.Stop(); this.logger.Error(ErrorCode.Provider_ErrorFromStart, $"Start failed for stream provider {this.config.Name} of type {this.config.Type} in stage {this.startStage} in {stopWatch.ElapsedMilliseconds} Milliseconds.", ex); throw; } }
public Task Init(string name, IProviderRuntime pr, IProviderConfiguration pc) { Name = name; system = ClusterActorSystem.Initialized ? (IActorSystem)ClusterActorSystem.Current : ClientActorSystem.Current; specifications = configuration.Find(name) ?? Enumerable.Empty <StreamSubscriptionSpecification>(); var type = Type.GetType(pc.Properties[TypeKey]); Debug.Assert(type != null); provider = (IStreamProviderImpl)Activator.CreateInstance(type); return(provider.Init(name, pr, pc)); }
internal IAsyncObservable <T> GetConsumerInterface() { if (consumerInterface == null) { lock (initLock) { if (consumerInterface == null) { if (provider == null) { provider = GetStreamProvider(); } consumerInterface = provider.GetConsumerInterface <T>(this); } } } return(consumerInterface); }
internal IAsyncBatchObserver <T> GetProducerInterface() { if (producerInterface != null) { return(producerInterface); } lock (initLock) { if (producerInterface != null) { return(producerInterface); } if (provider == null) { provider = GetStreamProvider(); } producerInterface = provider.GetProducerInterface <T>(this); } return(producerInterface); }