public Task <BaseCommand> Outgoing(CommandGetOrCreateSchema command) { command.RequestId = _requestId.FetchNext(); var request = StandardRequest.WithRequestId(command.RequestId); return(_requests.CreateTask(request)); }
public static BaseCommand ToBaseCommand(this CommandGetOrCreateSchema value) { return(new BaseCommand { type = BaseCommand.Type.GetOrCreateSchema, getOrCreateSchema = value }); }
public async Task <BaseCommand> Send(CommandGetOrCreateSchema 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 ValueTask <byte[]?> GetSchemaVersion(IConnection connection, CancellationToken cancellationToken) { if (_schema is null || _schema.Type == Schema.SchemaType.None) { return(null); } var command = new CommandGetOrCreateSchema { Schema = _schema, Topic = _commandProducer.Topic }; var response = await connection.Send(command, cancellationToken).ConfigureAwait(false); response.Expect(BaseCommand.Type.GetOrCreateSchemaResponse); if (response.GetOrCreateSchemaResponse.ShouldSerializeErrorCode()) { response.GetOrCreateSchemaResponse.Throw(); } return(response.GetOrCreateSchemaResponse.SchemaVersion); }
public Task <BaseCommand> Outgoing(CommandGetOrCreateSchema command) => _requestResponseHandler.Outgoing(command);