Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
formatUrl(request.uri),
request.methodName || 'post',
)
const normalHeaders: any = Object.keys(
headers,
).reduce((acc: any, name: string) => {
acc[name.toLowerCase()] = headers[name]
return acc
}, {})
const requestHeader: TTwitter.IRequestHeader = {
trace_id: new Int64(
`0x${normalHeaders[ZipkinHeaders.TraceId]}`,
),
span_id: new Int64(
`0x${normalHeaders[ZipkinHeaders.SpanId]}`,
),
parent_span_id:
normalHeaders[ZipkinHeaders.ParentId] !==
undefined
? new Int64(
`0x${
normalHeaders[
ZipkinHeaders.ParentId
]
}`,
)
: undefined,
sampled:
normalHeaders[ZipkinHeaders.Sampled] ===
'1',
constructor(args: ISpanArgs = {}) {
super();
if (args.trace_id != null) {
const value_32: thrift.Int64 = (typeof args.trace_id === "number" ? new thrift.Int64(args.trace_id) : args.trace_id);
this.trace_id = value_32;
}
if (args.name != null) {
const value_33: string = args.name;
this.name = value_33;
}
if (args.id != null) {
const value_34: thrift.Int64 = (typeof args.id === "number" ? new thrift.Int64(args.id) : args.id);
this.id = value_34;
}
if (args.parent_id != null) {
const value_35: thrift.Int64 = (typeof args.parent_id === "number" ? new thrift.Int64(args.parent_id) : args.parent_id);
this.parent_id = value_35;
}
if (args.annotations != null) {
const value_36: Array = new Array();
addInt64(a: Int64, b: Int64, context?: Hapi.Request): Int64 {
return new Int64(a.toNumber() + b.toNumber())
},
})
fetchThing(): ICommonStruct {
return {
code: {
status: new Int64(0),
},
value: 'test',
}
},
fetchUnion(): ICommonUnionArgs {
output.writeI64((typeof obj.trace_id === "number" ? new thrift.Int64(obj.trace_id) : typeof obj.trace_id === "string" ? thrift.Int64.fromDecimalString(obj.trace_id) : obj.trace_id));
output.writeFieldEnd();
}
if (obj.name != null) {
output.writeFieldBegin("name", thrift.TType.STRING, 3);
output.writeString(obj.name);
output.writeFieldEnd();
}
if (obj.id != null) {
output.writeFieldBegin("id", thrift.TType.I64, 4);
output.writeI64((typeof obj.id === "number" ? new thrift.Int64(obj.id) : typeof obj.id === "string" ? thrift.Int64.fromDecimalString(obj.id) : obj.id));
output.writeFieldEnd();
}
if (obj.parent_id != null) {
output.writeFieldBegin("parent_id", thrift.TType.I64, 5);
output.writeI64((typeof obj.parent_id === "number" ? new thrift.Int64(obj.parent_id) : typeof obj.parent_id === "string" ? thrift.Int64.fromDecimalString(obj.parent_id) : obj.parent_id));
output.writeFieldEnd();
}
if (obj.annotations != null) {
output.writeFieldBegin("annotations", thrift.TType.LIST, 6);
output.writeListBegin(thrift.TType.STRUCT, obj.annotations.length);
obj.annotations.forEach((value_1: Annotation.IAnnotationArgs): void => {
Annotation.AnnotationCodec.encode(value_1, output);
});
output.writeListEnd();
output.writeFieldEnd();
}
if (obj.binary_annotations != null) {
output.writeFieldBegin("binary_annotations", thrift.TType.LIST, 8);
output.writeListBegin(thrift.TType.STRUCT, obj.binary_annotations.length);
obj.binary_annotations.forEach((value_2: BinaryAnnotation.IBinaryAnnotationArgs): void => {
BinaryAnnotation.BinaryAnnotationCodec.encode(value_2, output);
encode(args: IRequestHeaderArgs, output: thrift.TProtocol): void {
const obj: any = {
trace_id: (typeof args.trace_id === "number" ? new thrift.Int64(args.trace_id) : typeof args.trace_id === "string" ? thrift.Int64.fromDecimalString(args.trace_id) : args.trace_id),
span_id: (typeof args.span_id === "number" ? new thrift.Int64(args.span_id) : typeof args.span_id === "string" ? thrift.Int64.fromDecimalString(args.span_id) : args.span_id),
parent_span_id: (typeof args.parent_span_id === "number" ? new thrift.Int64(args.parent_span_id) : typeof args.parent_span_id === "string" ? thrift.Int64.fromDecimalString(args.parent_span_id) : args.parent_span_id),
sampled: args.sampled,
client_id: args.client_id,
flags: (typeof args.flags === "number" ? new thrift.Int64(args.flags) : typeof args.flags === "string" ? thrift.Int64.fromDecimalString(args.flags) : args.flags),
contexts: args.contexts,
dest: args.dest,
delegations: args.delegations
};
output.writeStructBegin("RequestHeader");
if (obj.trace_id != null) {
output.writeFieldBegin("trace_id", thrift.TType.I64, 1);
output.writeI64((typeof obj.trace_id === "number" ? new thrift.Int64(obj.trace_id) : typeof obj.trace_id === "string" ? thrift.Int64.fromDecimalString(obj.trace_id) : obj.trace_id));
output.writeFieldEnd();
}
if (obj.span_id != null) {
output.writeFieldBegin("span_id", thrift.TType.I64, 2);
output.writeI64((typeof obj.span_id === "number" ? new thrift.Int64(obj.span_id) : typeof obj.span_id === "string" ? thrift.Int64.fromDecimalString(obj.span_id) : obj.span_id));
return client.getStruct(1).then((response: ISharedStruct) => {
const expected = {
code: {
status: new Int64(0),
},
value: 'test',
}
expect(response).to.equal(expected)
})
})
encode(args: IRequestHeaderArgs, output: thrift.TProtocol): void {
const obj = {
trace_id: (typeof args.trace_id === "number" ? new thrift.Int64(args.trace_id) : args.trace_id),
span_id: (typeof args.span_id === "number" ? new thrift.Int64(args.span_id) : args.span_id),
parent_span_id: (typeof args.parent_span_id === "number" ? new thrift.Int64(args.parent_span_id) : args.parent_span_id),
sampled: args.sampled,
client_id: args.client_id,
flags: (typeof args.flags === "number" ? new thrift.Int64(args.flags) : args.flags),
contexts: args.contexts,
dest: args.dest,
delegations: args.delegations
};
output.writeStructBegin("RequestHeader");
if (obj.trace_id != null) {
output.writeFieldBegin("trace_id", thrift.TType.I64, 1);
output.writeI64(obj.trace_id);
output.writeFieldEnd();
}
if (obj.span_id != null) {
output.writeFieldBegin("span_id", thrift.TType.I64, 2);
constructor(args?: IRequestHeaderArgs) {
if (args != null && args.trace_id != null) {
if (typeof args.trace_id === "number") {
this.trace_id = new thrift.Int64(args.trace_id);
}
else {
this.trace_id = args.trace_id;
}
}
if (args != null && args.span_id != null) {
if (typeof args.span_id === "number") {
this.span_id = new thrift.Int64(args.span_id);
}
else {
this.span_id = args.span_id;
}
}
if (args != null && args.parent_span_id != null) {
if (typeof args.parent_span_id === "number") {
this.parent_span_id = new thrift.Int64(args.parent_span_id);
}
else {
this.parent_span_id = args.parent_span_id;
}
}
if (args != null && args.sampled != null) {
this.sampled = args.sampled;
}
constructor(args: ISpanArgs = {}) {
super();
if (args.trace_id != null) {
const value_32: thrift.Int64 = (typeof args.trace_id === "number" ? new thrift.Int64(args.trace_id) : args.trace_id);
this.trace_id = value_32;
}
if (args.name != null) {
const value_33: string = args.name;
this.name = value_33;
}
if (args.id != null) {
const value_34: thrift.Int64 = (typeof args.id === "number" ? new thrift.Int64(args.id) : args.id);
this.id = value_34;
}
if (args.parent_id != null) {
const value_35: thrift.Int64 = (typeof args.parent_id === "number" ? new thrift.Int64(args.parent_id) : args.parent_id);
this.parent_id = value_35;
}
if (args.annotations != null) {
const value_36: Array = new Array();
args.annotations.forEach((value_39: IAnnotationArgs): void => {
const value_40: IAnnotation = new Annotation(value_39);
value_36.push(value_40);
});
this.annotations = value_36;
}
if (args.binary_annotations != null) {
const value_37: Array = new Array();