コード例 #1
0
 public static BaseCommand ToBaseCommand(this CommandPartitionedTopicMetadata value)
 {
     return(new BaseCommand
     {
         type = BaseCommand.Type.PartitionedMetadata,
         partitionMetadata = value
     });
 }
コード例 #2
0
        public static ReadOnlySequence <byte> NewPartitionMetadataRequest(string topic, long requestId)
        {
            var partitionMetadata = new CommandPartitionedTopicMetadata
            {
                Topic = topic, RequestId = (ulong)requestId
            };

            return(Serializer.Serialize(partitionMetadata.ToBaseCommand()));
        }
コード例 #3
0
        public async Task <BaseCommand> Send(CommandPartitionedTopicMetadata command, CancellationToken cancellationToken)
        {
            ThrowIfDisposed();

            Task <BaseCommand>?responseTask;

            using (await _lock.Lock(cancellationToken).ConfigureAwait(false))
            {
                responseTask = _channelManager.Outgoing(command);
                var sequence = Serializer.Serialize(command.AsBaseCommand());
                await _stream.Send(sequence).ConfigureAwait(false);
            }

            return(await responseTask.ConfigureAwait(false));
        }
コード例 #4
0
        private async Task <uint> GetNumberOfPartitions(string topic, CancellationToken cancellationToken)
        {
            var connection = await _connectionPool.FindConnectionForTopic(topic, cancellationToken).ConfigureAwait(false);

            var commandPartitionedMetadata = new CommandPartitionedTopicMetadata {
                Topic = topic
            };
            var response = await connection.Send(commandPartitionedMetadata, cancellationToken).ConfigureAwait(false);

            response.Expect(BaseCommand.Type.PartitionedMetadataResponse);

            if (response.PartitionMetadataResponse.Response == CommandPartitionedTopicMetadataResponse.LookupType.Failed)
            {
                response.PartitionMetadataResponse.Throw();
            }

            return(response.PartitionMetadataResponse.Partitions);
        }
コード例 #5
0
 public Task <BaseCommand> Outgoing(CommandPartitionedTopicMetadata command)
 {
     command.RequestId = _requestId.FetchNext();
     return(_requests.CreateTask(StandardRequest.WithRequestId(command.RequestId)));
 }
コード例 #6
0
 public Task <BaseCommand> Outgoing(CommandPartitionedTopicMetadata command)
 => _requestResponseHandler.Outgoing(command);