public static BaseCommand ToBaseCommand(this CommandPartitionedTopicMetadata value) { return(new BaseCommand { type = BaseCommand.Type.PartitionedMetadata, partitionMetadata = value }); }
public static ReadOnlySequence <byte> NewPartitionMetadataRequest(string topic, long requestId) { var partitionMetadata = new CommandPartitionedTopicMetadata { Topic = topic, RequestId = (ulong)requestId }; return(Serializer.Serialize(partitionMetadata.ToBaseCommand())); }
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)); }
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); }
public Task <BaseCommand> Outgoing(CommandPartitionedTopicMetadata command) { command.RequestId = _requestId.FetchNext(); return(_requests.CreateTask(StandardRequest.WithRequestId(command.RequestId))); }
public Task <BaseCommand> Outgoing(CommandPartitionedTopicMetadata command) => _requestResponseHandler.Outgoing(command);