public RedisService( ILogger <RedisService> logger, ShutdownService shutdown ) { _logger = logger; var redisHost = System.Environment.GetEnvironmentVariable("REDIS_HOST"); var redisPort = System.Environment.GetEnvironmentVariable("REDIS_PORT"); if (redisHost == null || redisHost == "") { redisHost = "localhost"; } if (redisPort == null || redisPort == "") { redisPort = "6379"; } Client = ConnectionMultiplexer.Connect($"{redisHost}:{redisPort}"); Client.ConnectionFailed += (object sender, ConnectionFailedEventArgs args) => { shutdown.HandleFailure($"Redis connection failure : {args.FailureType}"); }; }
public ComputeService( ILogger <ComputeService> logger, PubSubService pubSubService, StorageService redisService, ShutdownService shutdownService, RecordingServiceClient recordServiceClient ) { _logger = logger; _pubSubService = pubSubService; _storageService = redisService; _shutdownService = shutdownService; _recordServiceClient = recordServiceClient; }
public PollSummaryService( ILogger <PollSummaryService> logger, PubSubService pubSubService, StorageService redisService, ShutdownService shutdownService, RecordingServiceClient recordServiceClient ) { _logger = logger; _pubSubService = pubSubService; _storageService = redisService; _shutdownService = shutdownService; _recordServiceClient = recordServiceClient; _cancelTokenSource = new CancellationTokenSource(); // Streaming from a sequence is currently not implemented var streamRecords = new Voting.Record.StreamRecordsRequest(); var readStream = _recordServiceClient.StreamRecords(streamRecords, new CallOptions(cancellationToken: _cancelTokenSource.Token)); HandleResponseStream(readStream); shutdownService.RegisterShutdownCallback(() => { _cancelTokenSource.Cancel(); }); }