How to use the @creditkarma/thrift-client.createHttpClient function in @creditkarma/thrift-client

To help you get started, we’ve selected a few @creditkarma/thrift-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github creditkarma / thrift-server / packages / thrift-server-ecosystem / src / calculator-service.ts View on Github external
async function init(): Promise {
    const SERVER_CONFIG = await config().get('calculator-service')
    const ADD_SERVER_CONFIG = await config().get('add-service')

    // Create thrift client
    const thriftClient: AddService.Client = createHttpClient(
        AddService.Client,
        {
            hostName: ADD_SERVER_CONFIG.host,
            port: ADD_SERVER_CONFIG.port,
            register: [
                ThriftClientZipkinFilter({
                    localServiceName: 'calculator-service',
                    remoteServiceName: 'add-service',
                    tracerConfig: {
                        endpoint: 'http://localhost:9411/api/v1/spans',
                        httpInterval: 1000,
                        httpTimeout: 5000,
                        sampleRate: 1.0,
                    },
                }),
            ],
github creditkarma / thrift-server / packages / thrift-server-ecosystem / src / client.ts View on Github external
const app = express()

    app.use(
        ZipkinTracingExpress({
            localServiceName: 'calculator-client',
            tracerConfig: {
                endpoint: 'http://localhost:9411/api/v1/spans',
                httpInterval: 1000,
                httpTimeout: 5000,
                sampleRate: 1.0,
            },
        }),
    )

    // Create thrift client
    const thriftClient: Calculator.Client = createHttpClient(
        Calculator.Client,
        {
            hostName: SERVER_CONFIG.host,
            port: SERVER_CONFIG.port,
            register: [
                ThriftClientZipkinFilter({
                    localServiceName: 'calculator-client',
                    remoteServiceName: 'calculator-service',
                    tracerConfig: {
                        endpoint: 'http://localhost:9411/api/v1/spans',
                        httpInterval: 1000,
                        httpTimeout: 5000,
                        sampleRate: 1.0,
                    },
                }),
            ],
github creditkarma / thrift-server / packages / thrift-integration / src / express-calculator-service.ts View on Github external
export function createServer(sampleRate: number = 0): express.Application {
    // Create thrift client
    const addServiceClient: AddService.Client = createHttpClient(
        AddService.Client,
        {
            hostName: ADD_SERVER_CONFIG.hostName,
            port: ADD_SERVER_CONFIG.port,
            register:
                sampleRate > 0
                    ? [
                          ThriftClientZipkinFilter({
                              localServiceName: 'calculator-service',
                              remoteServiceName: 'add-service',
                              tracerConfig: {
                                  endpoint: process.env.ZIPKIN_ENDPOINT,
                                  zipkinVersion:
                                      process.env.ZIPKIN_VERSION === 'v2'
                                          ? 'v2'
                                          : 'v1',
github creditkarma / thrift-server / packages / thrift-integration / src / hapi-calculator-service.ts View on Github external
export async function createServer(
    sampleRate: number = 0,
    protocolType: ProtocolType = 'binary',
): Promise {
    // Create thrift client
    const addServiceClient: AddService.Client = createHttpClient(
        AddService.Client,
        {
            hostName: ADD_SERVER_CONFIG.hostName,
            port: ADD_SERVER_CONFIG.port,
            register:
                sampleRate > 0
                    ? [
                          ThriftClientZipkinFilter({
                              localServiceName: 'calculator-service',
                              remoteServiceName: 'add-service',
                              tracerConfig: {
                                  endpoint: process.env.ZIPKIN_ENDPOINT,
                                  zipkinVersion:
                                      process.env.ZIPKIN_VERSION === 'v2'
                                          ? 'v2'
                                          : 'v1',
github creditkarma / thrift-server / packages / thrift-integration / src / client / client.ts View on Github external
app.use([
            ZipkinTracingExpress({
                localServiceName: 'calculator-client',
                tracerConfig: {
                    endpoint: process.env.ZIPKIN_ENDPOINT,
                    zipkinVersion:
                        process.env.ZIPKIN_VERSION === 'v2' ? 'v2' : 'v1',
                    sampleRate,
                    httpInterval: 0,
                },
            }),
        ])
    }

    // Create thrift client
    const thriftClient: Calculator.Client = createHttpClient(
        Calculator.Client,
        {
            hostName: HAPI_CALC_SERVER_CONFIG.hostName,
            port: HAPI_CALC_SERVER_CONFIG.port,
            protocol: protocolType,
            register:
                sampleRate > 0
                    ? [
                          ThriftClientZipkinFilter({
                              localServiceName: 'calculator-client',
                              remoteServiceName: 'calculator-service',
                              tracerConfig: {
                                  endpoint: process.env.ZIPKIN_ENDPOINT,
                                  zipkinVersion:
                                      process.env.ZIPKIN_VERSION === 'v2'
                                          ? 'v2'
github creditkarma / thrift-server / packages / thrift-integration / src / client / connections / index.spec.ts View on Github external
it('should reject when middleware rejects', async () => {
            const client = createHttpClient(Calculator.Client, {
                hostName: HAPI_CALC_SERVER_CONFIG.hostName,
                port: HAPI_CALC_SERVER_CONFIG.port,
                register: [
                    {
                        handler(
                            request: IThriftRequest,
                            next: NextFunction,
                        ): Promise {
                            return next().then((res: IRequestResponse) => {
                                if (readThriftMethod(res.body) === 'nope') {
                                    return Promise.resolve(res)
                                } else {
                                    return Promise.reject(
                                        new Error(
                                            `Unrecognized method name: ${readThriftMethod(
                                                res.body,
github creditkarma / thrift-server / packages / thrift-integration / src / hapi / index.spec.ts View on Github external
before(async () => {
        calcServer = await createCalcServer()
        addServer = await createAddServer()
        client = createHttpClient(Calculator.Client, HAPI_CALC_SERVER_CONFIG)

        return Promise.all([calcServer.start(), addServer.start()]).then(() => {
            console.log('Thrift server started')
        })
    })
github creditkarma / thrift-server / packages / thrift-integration / src / express / index.spec.ts View on Github external
return new Promise((resolve, reject) => {
            const app: express.Application = createCalcServer()
            client = createHttpClient(
                Calculator.Client,
                EXPRESS_CALC_SERVER_CONFIG,
            )

            calcServer = app.listen(EXPRESS_CALC_SERVER_CONFIG.port, () => {
                console.log(
                    `Express server listening on port: ${EXPRESS_CALC_SERVER_CONFIG.port}`,
                )
                addServer.start().then(() => resolve())
            })
        })
    })
github creditkarma / thrift-server / packages / thrift-integration / src / hapi-calculator-service.ts View on Github external
if (sampleRate > 0) {
        await server.register({
            plugin: ZipkinTracingHapi({
                localServiceName: 'calculator-service',
                tracerConfig: {
                    endpoint: process.env.ZIPKIN_ENDPOINT,
                    zipkinVersion:
                        process.env.ZIPKIN_VERSION === 'v2' ? 'v2' : 'v1',
                    sampleRate,
                    httpInterval: 0,
                },
            }),
        })
    }

    const client: Calculator.Client = createHttpClient(Calculator.Client, {
        serviceName: 'calculator-service',
        hostName: HAPI_CALC_SERVER_CONFIG.hostName,
        port: HAPI_CALC_SERVER_CONFIG.port,
        path: HAPI_CALC_SERVER_CONFIG.path,
        register:
            sampleRate > 0
                ? [
                      ThriftClientZipkinFilter({
                          localServiceName: 'calculator-client',
                          remoteServiceName: 'calculator-service',
                          tracerConfig: {
                              endpoint: process.env.ZIPKIN_ENDPOINT,
                              zipkinVersion:
                                  process.env.ZIPKIN_VERSION === 'v2'
                                      ? 'v2'
                                      : 'v1',