Пример #1
0
 protected OperationBase()
 {
     Opaque = SequenceGenerator.GetNext();
     Header = new OperationHeader {
         Status = ResponseStatus.None
     };
     Key = string.Empty;
 }
        private void Read(IMemoryOwner <byte> buffer, OperationHeader header, ErrorCode errorCode = null)
        {
            Header    = header;
            ErrorCode = errorCode;
            Cas       = header.Cas;
            _data     = buffer;

            ReadExtras(_data.Memory.Span);
        }
Пример #3
0
        private Task ReadAsync(IMemoryOwner <byte> buffer, OperationHeader header, ErrorCode errorCode = null)
        {
            Header    = header;
            ErrorCode = errorCode;
            Cas       = header.Cas;
            _data     = buffer;

            ReadExtras(_data.Memory.Span);
            return(Task.CompletedTask);
        }
        protected OperationBase()
        {
            Opaque = SequenceGenerator.GetNext();
            Header = new OperationHeader {
                Status = ResponseStatus.None
            };
            Key = string.Empty;

            //temporarily make a static - later should be pluggable/set externally
            Transcoder = DefaultTranscoder;
        }
Пример #5
0
        internal static long?GetServerDuration(this OperationHeader header, ReadOnlySpan <byte> buffer)
        {
            if (header.FramingExtrasLength <= 0)
            {
                return(null);
            }

            // copy framing extra bytes
            Span <byte> bytes = new byte[header.FramingExtrasLength];

            buffer.Slice(OperationHeader.Length, header.FramingExtrasLength).CopyTo(bytes);

            return(GetServerDuration(bytes));
        }
Пример #6
0
        public virtual void Reset(ResponseStatus status)
        {
            _data?.Dispose();
            _data = null;

            Header = new OperationHeader
            {
                Magic      = Header.Magic,
                OpCode     = OpCode,
                Cas        = Header.Cas,
                BodyLength = Header.BodyLength,
                Key        = Key,
                Status     = status
            };
        }
Пример #7
0
        internal static long?GetServerDuration(this OperationHeader header, MemoryStream stream)
        {
            if (header.FramingExtrasLength <= 0)
            {
                return(null);
            }

            // copy framing extra bytes then reset steam position
            var bytes = new byte[header.FramingExtrasLength];

            stream.Position = OperationHeader.Length;
            stream.Read(bytes, 0, header.FramingExtrasLength);
            stream.Position = 0;

            return(GetServerDuration(bytes));
        }