示例#1
0
        public static IServiceCollection AddChunklerClient(this IServiceCollection services, Action <ChunklerClientOptions> configureOptions)
        {
            var options = new ChunklerClientOptions();

            configureOptions(options);
            return(AddChunklerClient(services, options));
        }
示例#2
0
        public ChunklerClient(ChunklerClientOptions options, ILogger logger)
        {
            _options = options ?? throw new ArgumentNullException(nameof(options));
            _logger  = logger ?? throw new ArgumentNullException(nameof(logger));

            _clusterClient = new ClientBuilder()
                             .UseLocalhostClustering()
                             .Configure <ClusterOptions>(cfg =>
            {
                cfg.ClusterId = options.ClusterOptions.ClusterId;
                cfg.ServiceId = options.ClusterOptions.ServiceId;
            })
                             .AddSimpleMessageStreamProvider(ChunklerConstants.SimpleChunkStreamProvider)
                             .Build();

            _clusterClient.Connect().Wait();
            _streamProvider = _clusterClient.GetStreamProvider(ChunklerConstants.SimpleChunkStreamProvider);
        }
示例#3
0
 public static IServiceCollection AddChunklerClient(this IServiceCollection services, ChunklerClientOptions options)
 {
     return(services
            .AddScoped <IChunklerClient, ChunklerClient>()
            .AddSingleton <ChunklerClientOptions>(options));
 }