public async Task Build_Merge_Producer_Test() { var producerA = _builder.UseChannel(_channel) .Partition("Organizations") .Shard("Org: #RedSocks") .AddInterceptor(_rawAsyncInterceptor); var producerB = _builder.UseTestProducerChannel() .Partition("NGOs") .Shard("NGO #2782228") .UseSegmentation(_segmentationStrategy); var producerC = _builder.UseChannel(_channel) .Partition("Fans") .Shard("Geek: @someone") .UseSegmentation(_otherSegmentationStrategy); ISequenceOperationsProducer producer = _builder .Merge(producerA, producerB, producerC) .UseSegmentation(_postSegmentationStrategy) .Build <ISequenceOperationsProducer>(); await producer.RegisterAsync(new User()); await producer.LoginAsync("admin", "1234"); await producer.EarseAsync(4335); }
/// <summary> /// Uses REDIS producer channel. /// </summary> /// <param name="builder">The builder.</param> /// <param name="logger">The logger.</param> /// <param name="configuration">The configuration.</param> /// <param name="resiliencePolicy">The resilience policy.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <param name="endpointEnvKey">The endpoint env key.</param> /// <param name="passwordEnvKey">The password env key.</param> /// <returns></returns> /// <exception cref="NotImplementedException"></exception> public static IProducerOptionsBuilder UseRedisProducerChannel( this IProducerBuilder builder, ILogger?logger = null, Action <ConfigurationOptions>?configuration = null, AsyncPolicy?resiliencePolicy = null, CancellationToken cancellationToken = default, string endpointEnvKey = PRODUCER_END_POINT_KEY, string passwordEnvKey = PRODUCER_PASSWORD_KEY) { var channel = new RedisProducerChannel( logger ?? EventSourceFallbakLogger.Default, configuration, resiliencePolicy, endpointEnvKey, passwordEnvKey); cancellationToken.ThrowIfCancellationRequested(); IProducerOptionsBuilder result = builder.UseChannel(channel); return(result); }
public async Task Build_Serializer_Producer_Test() { //var producerOption = new EventSourceOptions(_serializer); ISequenceOperationsProducer producer = _producerBuilder.UseChannel(_producerChannel) //.WithOptions(producerOption) .Partition("Organizations") .Shard("Org: #RedSocks") .Build <ISequenceOperationsProducer>(); await producer.RegisterAsync(new User()); await producer.LoginAsync("admin", "1234"); await producer.EarseAsync(4335); //var consumerOptions = new EventSourceConsumerOptions(serializer: _serializer); var cts = new CancellationTokenSource(); IAsyncDisposable subscription = _consumerBuilder.UseChannel(_consumerChannel) //.WithOptions(consumerOptions) .WithCancellation(cts.Token) .Partition("Organizations") .Shard("Org: #RedSocks") .Subscribe(meta => _subscriber); ch.Writer.Complete(); await subscription.DisposeAsync(); await ch.Reader.Completion; A.CallTo(() => _subscriber.RegisterAsync(A <User> .Ignored)) .MustHaveHappenedOnceExactly(); A.CallTo(() => _subscriber.LoginAsync("admin", "1234")) .MustHaveHappenedOnceExactly(); A.CallTo(() => _subscriber.EarseAsync(4335)) .MustHaveHappenedOnceExactly(); }
public static IProducerOptionsBuilder UseTestProducerChannel( this IProducerBuilder builder) { return(builder.UseChannel(_producerChannel)); }