Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise((resolve, reject) => {
connection = new TcpConnection({
hostName: 'localhost',
port: PORT,
})
connection.register(
ThriftClientContextFilter({
RequestCodec: MetadataCodec,
ResponseCodec: MetadataCodec,
}),
)
client = new Calculator.Client(connection)
mockServer = net.createServer((socket: net.Socket): void => {
console.log('TCP server created')
socket.addListener('data', (chunk: Buffer) => {
before(async () => {
connection = new TcpConnection({
hostName: 'localhost',
port: 8888,
})
connection.register(
{
handler(
request: IThriftRequest,
next: NextFunction,
): Promise {
return next(request.data)
},
},
{
methods: ['echoString'],
handler(
before(async () => {
connection = new TcpConnection({
hostName: 'localhost',
port: PORT,
})
connection.register(
ThriftClientTTwitterFilter({
localServiceName: 'tcp-calculator-client',
remoteServiceName: 'calculator-service',
tracerConfig: {
endpoint: 'http://localhost:9411/api/v1/spans',
sampleRate: 1,
httpInterval: 0,
},
}),
)
before(async () => {
connection = new TcpConnection({
hostName: 'localhost',
port: 8888,
})
client = new Calculator.Client(connection)
})