/// <summary> /// Initializes a new instance of the <see cref="ClusterClient"/> class. /// </summary> /// <param name="runtimeClient">The runtime client.</param> /// <param name="loggerFactory">Logger factory used to create loggers</param> /// <param name="clientMessagingOptions">Messaging parameters</param> public ClusterClient(IRuntimeClient runtimeClient, ILoggerFactory loggerFactory, IOptions <ClientMessagingOptions> clientMessagingOptions) { this.runtimeClient = runtimeClient; this.clusterClientLifecycle = new ClusterClientLifecycle(loggerFactory.CreateLogger <LifecycleSubject>()); //set PropagateActivityId flag from node cofnig RequestContext.PropagateActivityId |= clientMessagingOptions.Value.PropagateActivityId; // register all lifecycle participants IEnumerable <ILifecycleParticipant <IClusterClientLifecycle> > lifecycleParticipants = this.ServiceProvider.GetServices <ILifecycleParticipant <IClusterClientLifecycle> >(); foreach (ILifecycleParticipant <IClusterClientLifecycle> participant in lifecycleParticipants) { participant?.Participate(clusterClientLifecycle); } // register all named lifecycle participants IKeyedServiceCollection <string, ILifecycleParticipant <IClusterClientLifecycle> > namedLifecycleParticipantCollections = this.ServiceProvider.GetService <IKeyedServiceCollection <string, ILifecycleParticipant <IClusterClientLifecycle> > >(); foreach (ILifecycleParticipant <IClusterClientLifecycle> participant in namedLifecycleParticipantCollections ?.GetServices(this.ServiceProvider) ?.Select(s => s?.GetService(this.ServiceProvider))) { participant?.Participate(clusterClientLifecycle); } // It is fine for this field to be null in the case that the client is not the host. this.applicationLifetime = runtimeClient.ServiceProvider.GetService <IHostApplicationLifetime>() as ClientApplicationLifetime; }
/// <summary> /// Initializes a new instance of the <see cref="ClusterClient"/> class. /// </summary> /// <param name="runtimeClient">The runtime client.</param> /// <param name="configuration">The client configuration.</param> /// <param name="loggerFactory">Logger factory used to create loggers</param> public ClusterClient(OutsideRuntimeClient runtimeClient, ILoggerFactory loggerFactory, IOptions <ClientMessagingOptions> clientMessagingOptions) { this.runtimeClient = runtimeClient; this.clusterClientLifecycle = new ClusterClientLifecycle(loggerFactory); //set PropagateActivityId flag from node cofnig RequestContext.PropagateActivityId = clientMessagingOptions.Value.PropagateActivityId; // register all lifecycle participants IEnumerable <ILifecycleParticipant <IClusterClientLifecycle> > lifecycleParticipants = this.ServiceProvider.GetServices <ILifecycleParticipant <IClusterClientLifecycle> >(); foreach (ILifecycleParticipant <IClusterClientLifecycle> participant in lifecycleParticipants) { participant?.Participate(clusterClientLifecycle); } // register all named lifecycle participants IKeyedServiceCollection <string, ILifecycleParticipant <IClusterClientLifecycle> > namedLifecycleParticipantCollections = this.ServiceProvider.GetService <IKeyedServiceCollection <string, ILifecycleParticipant <IClusterClientLifecycle> > >(); foreach (ILifecycleParticipant <IClusterClientLifecycle> participant in namedLifecycleParticipantCollections ?.GetServices(this.ServiceProvider) ?.Select(s => s?.GetService(this.ServiceProvider))) { participant?.Participate(clusterClientLifecycle); } }
/// <summary> /// Initializes a new instance of the <see cref="ClusterClient"/> class. /// </summary> /// <param name="serviceProvider">The service provider.</param> /// <param name="runtimeClient">The runtime client.</param> /// <param name="loggerFactory">Logger factory used to create loggers</param> /// <param name="clientMessagingOptions">Messaging parameters</param> public ClusterClient(IServiceProvider serviceProvider, OutsideRuntimeClient runtimeClient, ILoggerFactory loggerFactory, IOptions <ClientMessagingOptions> clientMessagingOptions) { ValidateSystemConfiguration(serviceProvider); _runtimeClient = runtimeClient; _logger = loggerFactory.CreateLogger <ClusterClient>(); _clusterClientLifecycle = new ClusterClientLifecycle(_logger); //set PropagateActivityId flag from node config RequestContext.PropagateActivityId |= clientMessagingOptions.Value.PropagateActivityId; // register all lifecycle participants IEnumerable <ILifecycleParticipant <IClusterClientLifecycle> > lifecycleParticipants = ServiceProvider.GetServices <ILifecycleParticipant <IClusterClientLifecycle> >(); foreach (var participant in lifecycleParticipants) { participant?.Participate(_clusterClientLifecycle); } // register all named lifecycle participants IKeyedServiceCollection <string, ILifecycleParticipant <IClusterClientLifecycle> > namedLifecycleParticipantCollections = ServiceProvider.GetService <IKeyedServiceCollection <string, ILifecycleParticipant <IClusterClientLifecycle> > >(); foreach (var participant in namedLifecycleParticipantCollections ?.GetServices(ServiceProvider) ?.Select(s => s?.GetService(ServiceProvider))) { participant?.Participate(_clusterClientLifecycle); }