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); }
public Task <BaseCommand> Outgoing(CommandUnsubscribe command) { command.RequestId = _requestId.FetchNext(); var request = StandardRequest.WithConsumerId(command.RequestId, command.ConsumerId); return(_requests.CreateTask(request)); }
public async ValueTask Unsubscribe(CancellationToken cancellationToken) { ThrowIfDisposed(); var unsubscribe = new CommandUnsubscribe(); await _executor.Execute(() => Unsubscribe(unsubscribe, cancellationToken), cancellationToken).ConfigureAwait(false); }
public static BaseCommand ToBaseCommand(this CommandUnsubscribe value) { return(new BaseCommand { type = BaseCommand.Type.Unsubscribe, Unsubscribe = value }); }
public static BaseCommand AsBaseCommand(this CommandUnsubscribe command) { return(new BaseCommand { CommandType = BaseCommand.Type.Unsubscribe, Unsubscribe = command }); }
public async Task <CommandSuccess> Send(CommandUnsubscribe command) { command.ConsumerId = _id; var response = await _connection.Send(command); response.Expect(BaseCommand.Type.Success); return(response.Success); }
public static ReadOnlySequence <byte> NewUnsubscribe(long consumerId, long requestId) { var unsubscribe = new CommandUnsubscribe { ConsumerId = (ulong)consumerId, RequestId = (ulong)requestId }; return(Serializer.Serialize(unsubscribe.ToBaseCommand())); }
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); }
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)); }
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); }
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();
private async ValueTask Unsubscribe(CommandUnsubscribe command, CancellationToken cancellationToken) => await _channel.Send(command, cancellationToken).ConfigureAwait(false);
public Task <CommandSuccess> Send(CommandUnsubscribe command) => throw GetException();
public Builder() { _command = new CommandUnsubscribe(); }