Ejemplo n.º 1
0
        /// <summary>
        /// Sends a key/value operation to it's mapped server asynchronously.
        /// </summary>
        /// <typeparam name="T">The <see cref="Type" /> T of the body.</typeparam>
        /// <param name="operation">The <see cref="IOperation{T}" /> to send.</param>
        /// <returns>
        /// A <see cref="Task" /> representing the asynchronous operation.
        /// </returns>
        public async Task SendAsync <T>(IOperation <T> operation)
        {
            operation.CurrentHost = EndPoint;
            if (_isDown)
            {
                var msg = ExceptionUtil.GetNodeUnavailableMsg(EndPoint,
                                                              _clientConfiguration.NodeAvailableCheckInterval);

                operation.Completed(new SocketAsyncState
                {
                    Exception = new NodeUnavailableException(msg),
                    Opaque    = operation.Opaque,
                    Status    = ResponseStatus.NodeUnavailable
                });
                return;
            }
            await _ioService.ExecuteAsync(operation);
        }