Пример #1
0
        private async Task <IPublisher> CreatePublisherInternal(string topicName, PublisherOptions options,
                                                                Func <AsyncDuplexStreamingCall <PublishRequest, PublisherAck>, Publisher> publisherFactory)
        {
            var opt          = options ?? new PublisherOptions();
            var duplexStream = grpcClient.Publish();
            await duplexStream.RequestStream.WriteAsync(new FastQueueService.PublishRequest
            {
                Options = new FastQueueService.PublisherOptions
                {
                    TopicName = topicName,
                    ConfirmationIntervalMilliseconds = opt.ConfirmationIntervalMilliseconds
                }
            });

            var publisher = publisherFactory(duplexStream);

            publisher.StartAckLoop();
            return(publisher);
        }
Пример #2
0
 public Task <IPublisherMany> CreatePublisherMany(string topicName, Func <long, Task> ackHandler, PublisherOptions options = null)
 {
     return(CreatePublisherManyInternal(topicName, options, ackHandler == null, duplexStream => new PublisherMany(duplexStream, ackHandler)));
 }
Пример #3
0
 public Task <IPublisher> CreatePublisher(string topicName, Action <long> ackHandler, PublisherOptions options = null)
 {
     return(CreatePublisherInternal(topicName, options, duplexStream => new Publisher(duplexStream, ackHandler)));
 }
Пример #4
0
 public PublisherOptions(PublisherOptions options)
 {
     ConfirmationIntervalMilliseconds = options.ConfirmationIntervalMilliseconds;
 }