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); }
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; }
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)); }
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 }; }
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)); }