예제 #1
0
        public Task <BaseCommand> Outgoing(CommandGetOrCreateSchema command)
        {
            command.RequestId = _requestId.FetchNext();
            var request = StandardRequest.WithRequestId(command.RequestId);

            return(_requests.CreateTask(request));
        }
예제 #2
0
 public static BaseCommand ToBaseCommand(this CommandGetOrCreateSchema value)
 {
     return(new BaseCommand
     {
         type = BaseCommand.Type.GetOrCreateSchema,
         getOrCreateSchema = value
     });
 }
예제 #3
0
        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));
        }
예제 #4
0
        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);
        }
예제 #5
0
 public Task <BaseCommand> Outgoing(CommandGetOrCreateSchema command)
 => _requestResponseHandler.Outgoing(command);