var ArgsRW = require('./args'); var argsrw = ArgsRW(bufrw.buf2); // flags:1 csumtype:1 (csum:4){0,1} (arg~2)+ function CallRequestCont(flags, csum, args) { var self = this; self.type = CallRequestCont.TypeCode; self.flags = flags || 0; self.csum = Checksum.objOrType(csum); self.args = args || []; self.cont = null; } CallRequestCont.TypeCode = 0x13; CallRequestCont.Cont = CallRequestCont; CallRequestCont.RW = bufrw.Base(callReqContLength, readCallReqContFrom, writeCallReqContInto); function callReqContLength(body) { var res; var length = 0; // flags:1 length += bufrw.UInt8.width; // csumtype:1 (csum:4){0,1} (arg~2)* res = argsrw.byteLength(body); if (!res.err) res.length += length; return res; }
var emptySpanId = Buffer(8); var emptyParentId = Buffer(8); var emptyTraceId = Buffer(8); emptySpanId.fill(0); emptyParentId.fill(0); emptyTraceId.fill(0); function Tracing(spanid, parentid, traceid, flags) { this.spanid = spanid || [0, 0]; this.parentid = parentid || [0, 0]; this.traceid = traceid || [0, 0]; this.flags = flags || 0; } Tracing.RW = bufrw.Base(tracingByteLength, readTracingFrom, writeTracingInto, true); function tracingByteLength(destResult) { return destResult.reset( null, 8 + // spanid:8 8 + // parentid:8 8 + // traceid:8 1 // flags:1 ); } function writeTracingInto(destResult, tracing, buffer, offset) { var res; res = bufrw.UInt32BE.poolWriteInto(destResult, tracing.spanid[0], buffer, offset);
function CallRequest(flags, ttl, tracing, service, headers, csum, args) { var self = this; self.type = CallRequest.TypeCode; self.flags = flags || 0; self.ttl = ttl || 0; self.tracing = tracing || Tracing.emptyTracing; self.service = service || ''; self.headers = headers || {}; self.csum = Checksum.objOrType(csum); self.args = args || []; self.cont = null; } CallRequest.Cont = require('./cont').RequestCont; CallRequest.TypeCode = 0x03; CallRequest.RW = bufrw.Base(callReqLength, readCallReqFrom, writeCallReqInto); CallRequest.MaxArg1Size = 0x4000; function callReqLength(body) { var res; var length = 0; // flags:1 length += bufrw.UInt8.width; // ttl:4 length += bufrw.UInt32BE.width; // tracing:24 traceflags:1 res = Tracing.RW.byteLength(body.tracing); if (res.err) return res;