Exemple #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);
        }
Exemple #2
0
        public Task <BaseCommand> Outgoing(CommandUnsubscribe command)
        {
            command.RequestId = _requestId.FetchNext();
            var request = StandardRequest.WithConsumerId(command.RequestId, command.ConsumerId);

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

            var unsubscribe = new CommandUnsubscribe();
            await _executor.Execute(() => Unsubscribe(unsubscribe, cancellationToken), cancellationToken).ConfigureAwait(false);
        }
Exemple #4
0
 public static BaseCommand ToBaseCommand(this CommandUnsubscribe value)
 {
     return(new BaseCommand
     {
         type = BaseCommand.Type.Unsubscribe,
         Unsubscribe = value
     });
 }
Exemple #5
0
 public static BaseCommand AsBaseCommand(this CommandUnsubscribe command)
 {
     return(new BaseCommand
     {
         CommandType = BaseCommand.Type.Unsubscribe,
         Unsubscribe = command
     });
 }
Exemple #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);
        }
Exemple #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()));
        }
Exemple #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);
        }
Exemple #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));
        }
Exemple #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);
        }
Exemple #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;
            }
        }
        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();
Exemple #15
0
 private async ValueTask Unsubscribe(CommandUnsubscribe command, CancellationToken cancellationToken)
 => await _channel.Send(command, cancellationToken).ConfigureAwait(false);
Exemple #16
0
 public Task <CommandSuccess> Send(CommandUnsubscribe command) => throw GetException();
 public Builder()
 {
     _command = new CommandUnsubscribe();
 }