Пример #1
0
 internal HealthDataService(
     HealthDataProducer producer,
     TraceWriterWrapper traceWriter,
     IServiceConfiguration config,
     EntityFilterRepository filterRepository)
 {
     this.Producer         = Guard.IsNotNull(producer, nameof(producer));
     this.Trace            = Guard.IsNotNull(traceWriter, nameof(traceWriter));
     this.Config           = Guard.IsNotNull(config, nameof(config));
     this.FilterRepository = Guard.IsNotNull(filterRepository, nameof(filterRepository));
 }
Пример #2
0
        /// <summary>
        /// This is the main entry point for your service instance.
        /// </summary>
        /// <param name="cancellationToken">Canceled when Service Fabric needs to shut down this service instance.</param>
        protected override async Task RunAsync(CancellationToken cancellationToken)
        {
            if (this.healthDataService == null)
            {
                // compose the HealthDataService instance with all the dependencies.
                var config           = new ServiceConfiguration(this.serviceContext.CodePackageActivationContext, TraceWriter);
                var filterRepository = new EntityFilterRepository(config);

                var healthClient = new FabricHealthClientWrapper(
                    TraceWriter,
                    this.Context.ServiceTypeName,
                    this.Context.PartitionId,
                    this.Context.ReplicaOrInstanceId);

                var consumer = new SampleHealthDataConsumer();
                var producer = new HealthDataProducer(healthClient, consumer, TraceWriter, config, filterRepository);
                this.healthDataService = new HealthDataService(producer, TraceWriter, config, filterRepository);

                //this.TraceInfo("Service.RunAsync: Composed new HealthDataService instance");
            }

            //this.TraceInfo("Service.RunAsync: Invoking HealthDataService.RunAsync");
            await this.healthDataService.RunAsync(cancellationToken).ConfigureAwait(false);
        }