示例#1
0
        public async Task Send(CommandUnsubscribe command, CancellationToken cancellationToken)
        {
            command.ConsumerId = _id;
            var response = await _connection.Send(command, cancellationToken).ConfigureAwait(false);

            response.Expect(BaseCommand.Type.Success);
        }
示例#2
0
        public Task <BaseCommand> Outgoing(CommandUnsubscribe command)
        {
            command.RequestId = _requestId.FetchNext();
            var request = StandardRequest.WithConsumerId(command.RequestId, command.ConsumerId);

            return(_requests.CreateTask(request));
        }
示例#3
0
        public async ValueTask Unsubscribe(CancellationToken cancellationToken)
        {
            ThrowIfDisposed();

            var unsubscribe = new CommandUnsubscribe();
            await _executor.Execute(() => Unsubscribe(unsubscribe, cancellationToken), cancellationToken).ConfigureAwait(false);
        }
示例#4
0
 public static BaseCommand ToBaseCommand(this CommandUnsubscribe value)
 {
     return(new BaseCommand
     {
         type = BaseCommand.Type.Unsubscribe,
         Unsubscribe = value
     });
 }
示例#5
0
 public static BaseCommand AsBaseCommand(this CommandUnsubscribe command)
 {
     return(new BaseCommand
     {
         CommandType = BaseCommand.Type.Unsubscribe,
         Unsubscribe = command
     });
 }
示例#6
0
        public async Task <CommandSuccess> Send(CommandUnsubscribe command)
        {
            command.ConsumerId = _id;
            var response = await _connection.Send(command);

            response.Expect(BaseCommand.Type.Success);
            return(response.Success);
        }
示例#7
0
        public static ReadOnlySequence <byte> NewUnsubscribe(long consumerId, long requestId)
        {
            var unsubscribe = new CommandUnsubscribe
            {
                ConsumerId = (ulong)consumerId, RequestId = (ulong)requestId
            };

            return(Serializer.Serialize(unsubscribe.ToBaseCommand()));
        }
示例#8
0
        public async Task <BaseCommand> Send(CommandUnsubscribe command)
        {
            var response = await SendRequestResponse(command.AsBaseCommand());

            if (response.CommandType == BaseCommand.Type.Success)
            {
                _consumerManager.Remove(command.ConsumerId);
            }
            return(response);
        }
        public void Outgoing(CommandUnsubscribe command, Task <BaseCommand> response)
        {
            var consumerId = command.ConsumerId;

            _ = response.ContinueWith(result =>
            {
                if (result.Result.CommandType == BaseCommand.Type.Success)
                {
                    _consumerChannels.Remove(consumerId)?.Unsubscribed();
                }
            }, TaskContinuationOptions.OnlyOnRanToCompletion);
        }
示例#10
0
        public async Task <BaseCommand> Send(CommandUnsubscribe 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));
        }
示例#11
0
        public async Task <BaseCommand> Send(CommandUnsubscribe command)
        {
            Task <BaseCommand>?responseTask = null;

            using (await _lock.Lock())
            {
                var baseCommand = command.AsBaseCommand();
                responseTask = _requestResponseHandler.Outgoing(baseCommand);
                _channelManager.Outgoing(command, responseTask);
                var sequence = Serializer.Serialize(baseCommand);
                await _stream.Send(sequence);
            }

            return(await responseTask);
        }
示例#12
0
        public async Task <CommandSuccess> Send(CommandUnsubscribe command)
        {
            try
            {
                command.ConsumerId = _id;
                var response = await _connection.Send(command);

                response.Expect(BaseCommand.Type.Success);
                return(response.Success);
            }
            catch (Exception exception)
            {
                OnException(exception);
                throw;
            }
        }
示例#13
0
        public Task <BaseCommand> Outgoing(CommandUnsubscribe command)
        {
            var consumerId = command.ConsumerId;

            Task <BaseCommand> response;

            using (TakeConsumerSenderLock(consumerId))
            {
                response = _requestResponseHandler.Outgoing(command);
            }

            _ = response.ContinueWith(result =>
            {
                if (result.Result.CommandType == BaseCommand.Type.Success)
                {
                    _consumerChannels.Remove(consumerId)?.Unsubscribed();
                }
            }, TaskContinuationOptions.OnlyOnRanToCompletion);

            return(response);
        }
 public Task <CommandSuccess> Send(CommandUnsubscribe command, CancellationToken cancellationToken)
 => throw GetException();
示例#15
0
 private async ValueTask Unsubscribe(CommandUnsubscribe command, CancellationToken cancellationToken)
 => await _channel.Send(command, cancellationToken).ConfigureAwait(false);
示例#16
0
 public Task <CommandSuccess> Send(CommandUnsubscribe command) => throw GetException();
示例#17
0
 public Builder()
 {
     _command = new CommandUnsubscribe();
 }