protected internal override async ValueTask <IOperationResult> ReadResponseAsync(PooledSocket socket)
        {
            var response   = new BinaryResponse();
            var serverData = new Dictionary <string, string>();
            var retval     = false;

            while ((await response.ReadAsync(socket)) && response.KeyLength > 0)
            {
                retval = true;

                var data  = response.Data;
                var key   = BinaryConverter.DecodeKey(data.Array, data.Offset, response.KeyLength);
                var value = BinaryConverter.DecodeKey(data.Array, data.Offset + response.KeyLength, data.Count - response.KeyLength);

                serverData[key] = value;
            }

            this.result     = serverData;
            this.StatusCode = response.StatusCode;

            var result = new BinaryOperationResult()
            {
                StatusCode = StatusCode
            };

            result.PassOrFail(retval, "Failed to read response");
            return(result);
        }
Exemple #2
0
        protected internal override async ValueTask <IOperationResult> ReadResponseAsync(PooledSocket socket)
        {
            var response = new BinaryResponse();
            var retval   = await response.ReadAsync(socket);

            this.Cas        = response.CAS;
            this.StatusCode = response.StatusCode;

            var result = new BinaryOperationResult()
            {
                Success    = retval,
                Cas        = this.Cas,
                StatusCode = this.StatusCode
            };

            IOperationResult responseResult;

            if (!(responseResult = this.ProcessResponse(response)).Success)
            {
                result.InnerResult = responseResult;
                responseResult.Combine(result);
            }

            return(result);
        }
Exemple #3
0
        protected internal override async Task <IOperationResult> ReadResponseAsync(PooledSocket socket, CancellationToken cancellationToken = default(CancellationToken))
        {
            var response   = new BinaryResponse();
            var serverData = new Dictionary <string, string>();
            var success    = false;

            while (await response.ReadAsync(socket, cancellationToken).ConfigureAwait(false) && response.KeyLength > 0)
            {
                success = true;

                var data  = response.Data;
                var key   = BinaryConverter.DecodeKey(data.Array, data.Offset, response.KeyLength);
                var value = BinaryConverter.DecodeKey(data.Array, data.Offset + response.KeyLength, data.Count - response.KeyLength);

                serverData[key] = value;
            }

            this._result    = serverData;
            this.StatusCode = response.StatusCode;

            var result = new BinaryOperationResult()
            {
                StatusCode = StatusCode
            };

            result.PassOrFail(success, "Failed to read response");
            return(result);
        }
        protected internal override async Task <IOperationResult> ReadResponseAsync(PooledSocket socket, CancellationToken cancellationToken = default(CancellationToken))
        {
            var response = new BinaryResponse();
            var success  = await response.ReadAsync(socket, cancellationToken).ConfigureAwait(false);

            this.Cas        = response.CAS;
            this.StatusCode = response.StatusCode;

            var result = new BinaryOperationResult()
            {
                Success    = success,
                Cas        = this.Cas,
                StatusCode = this.StatusCode
            };

            IOperationResult responseResult;

            if (!(responseResult = this.ProcessResponse(response)).Success)
            {
                result.InnerResult = responseResult;
                responseResult.Combine(result);
            }

            return(result);
        }
Exemple #5
0
        protected internal override async ValueTask <IOperationResult> ReadResponseAsync(PooledSocket socket)
        {
            var response = new BinaryResponse();
            var retval   = await response.ReadAsync(socket);

            this.StatusCode = StatusCode;
            var result = new BinaryOperationResult()
            {
                Success    = retval,
                StatusCode = this.StatusCode
            };

            result.PassOrFail(retval, "Failed to read response");
            return(result);
        }
        protected internal override async Task <IOperationResult> ReadResponseAsync(PooledSocket socket, CancellationToken cancellationToken = default(CancellationToken))
        {
            var response = new BinaryResponse();
            var success  = await response.ReadAsync(socket, cancellationToken).ConfigureAwait(false);

            this.StatusCode = StatusCode;
            var result = new BinaryOperationResult()
            {
                Success    = success,
                StatusCode = this.StatusCode
            };

            result.PassOrFail(success, "Failed to read response");
            return(result);
        }
Exemple #7
0
        protected internal override async ValueTask <IOperationResult> ReadResponseAsync(PooledSocket socket)
        {
            this.result = new Dictionary <string, CacheItem>();
            this.Cas    = new Dictionary <string, ulong>();
            var result = new TextOperationResult();

            var response = new BinaryResponse();

            while (await response.ReadAsync(socket))
            {
                this.StatusCode = response.StatusCode;

                // found the noop, quit
                if (response.CorrelationId == this.noopId)
                {
                    return(result.Pass());
                }

                string key;

                // find the key to the response
                if (!this.idToKey.TryGetValue(response.CorrelationId, out key))
                {
                    // we're not supposed to get here tho
                    log.WarnFormat("Found response with CorrelationId {0}, but no key is matching it.", response.CorrelationId);
                    continue;
                }

                if (log.IsDebugEnabled)
                {
                    log.DebugFormat("Reading item {0}", key);
                }

                // deserialize the response
                int flags = BinaryConverter.DecodeInt32(response.Extra, 0);

                this.result[key] = new CacheItem((ushort)flags, response.Data);
                this.Cas[key]    = response.CAS;
            }

            // finished reading but we did not find the NOOP
            return(result.Fail("Found response with CorrelationId {0}, but no key is matching it."));
        }
        protected internal override async Task<IOperationResult> ReadResponseAsync(PooledSocket socket)
        {
            var response = new BinaryResponse();
            var retval = await response.ReadAsync(socket);

            this.Cas = response.CAS;
            this.StatusCode = response.StatusCode;

            var result = new BinaryOperationResult()
            {
                Success = retval,
                Cas = this.Cas,
                StatusCode = this.StatusCode
            };

            IOperationResult responseResult;
            if (!(responseResult = this.ProcessResponse(response)).Success)
            {
                result.InnerResult = responseResult;
                responseResult.Combine(result);
            }

            return result;
        }
        protected override bool ReadResponseAsync(IPooledSocket socket, Action<bool> next)
        {
            var response = new BinaryResponse();

            bool ioPending;
            var retval = response.ReadAsync(socket, (readSuccess) =>
                            {
                                if (readSuccess) this.DecodeResult(response.Data);
                                next(readSuccess);
                            }, out ioPending);

            if (!ioPending && retval)
                this.Result = this.DecodeResult(response.Data);

            return retval;
        }