How to use @creditkarma/thrift-server-hapi - 6 common examples

To help you get started, we’ve selected a few @creditkarma/thrift-server-hapi 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-integration / src / calculator-strict-unions.ts View on Github external
},
                value: 'test',
            }
        },
        fetchUnion(): CommonUnion {
            return CommonUnionCodec.create({ option1: 'test' })
        },
        broken(): void {
            throw new Error(`Yeah, this didn't work`)
        },
    })

    /**
     * Creates Hapi server with thrift endpoint.
     */
    const server: Hapi.Server = await createThriftServer({
        port: HAPI_CALC_SERVER_STRICT_CONFIG.port,
        path: HAPI_CALC_SERVER_STRICT_CONFIG.path,
        thriftOptions: {
            serviceName: 'calculator-service',
            handler: impl,
            protocol: protocolType,
        },
    })

    if (sampleRate > 0) {
        await server.register({
            plugin: ZipkinTracingHapi({
                localServiceName: 'calculator-service',
                tracerConfig: {
                    endpoint: process.env.ZIPKIN_ENDPOINT,
                    zipkinVersion:
github creditkarma / thrift-server / packages / thrift-server-ecosystem / src / add-service.ts View on Github external
const impl = new AddService.Processor({
        ping(): void {
            return
        },
        add(a: number, b: number, context?: Hapi.Request): number {
            return a + b
        },
        addInt64(a: Int64, b: Int64, context?: Hapi.Request): Int64 {
            return new Int64(a.toNumber() + b.toNumber())
        },
    })

    /**
     * Creates Hapi server with thrift endpoint.
     */
    const server: Hapi.Server = await createThriftServer({
        port: SERVER_CONFIG.port,
        path: SERVER_CONFIG.path,
        thriftOptions: {
            serviceName: 'add-service',
            handler: impl,
        },
    })

    await server.register({
        plugin: ZipkinTracingHapi({
            localServiceName: 'add-service',
            tracerConfig: {
                endpoint: 'http://localhost:9411/api/v1/spans',
                sampleRate: 1.0,
                httpInterval: 1000,
                httpTimeout: 5000,
github creditkarma / thrift-server / packages / thrift-server-ecosystem / src / calculator-service.ts View on Github external
return thriftClient.add(work.num1, work.num2, {
                        headers: context.headers,
                    })
                case Operation.SUBTRACT:
                    return work.num1 - work.num2
                case Operation.DIVIDE:
                    return work.num1 / work.num2
                case Operation.MULTIPLY:
                    return work.num1 * work.num2
                default:
                    throw new Error(`Invalid operation[${work.op}]`)
            }
        },
    })

    const server: Hapi.Server = await createThriftServer({
        port: SERVER_CONFIG.port,
        path: SERVER_CONFIG.path,
        thriftOptions: {
            serviceName: 'calculator-service',
            handler: impl,
        },
    })

    await server.register({
        plugin: ZipkinTracingHapi({
            localServiceName: '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 / hapi-add-service.ts View on Github external
const impl = new AddService.Processor({
        ping(): void {
            return
        },
        add(a: number, b: number, context?: Hapi.Request): number {
            return a + b
        },
        addInt64(a: Int64, b: Int64, context?: Hapi.Request): Int64 {
            return new Int64(a.toNumber() + b.toNumber())
        },
    })

    /**
     * Creates Hapi server with thrift endpoint.
     */
    const server: Hapi.Server = await createThriftServer({
        port: ADD_SERVER_CONFIG.port,
        path: ADD_SERVER_CONFIG.path,
        thriftOptions: {
            serviceName: 'add-service',
            handler: impl,
        },
    })

    if (sampleRate > 0) {
        await server.register({
            plugin: ZipkinTracingHapi({
                localServiceName: '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
},
                value: 'test',
            }
        },
        fetchUnion(): ICommonUnionArgs {
            return { option1: 'test' }
        },
        broken(): void {
            throw new Error(`Yeah, this didn't work`)
        },
    })

    /**
     * Creates Hapi server with thrift endpoint.
     */
    const server: Hapi.Server = await createThriftServer({
        port: HAPI_CALC_SERVER_CONFIG.port,
        path: HAPI_CALC_SERVER_CONFIG.path,
        thriftOptions: {
            serviceName: 'calculator-service',
            handler: impl,
            protocol: protocolType,
        },
    })

    if (sampleRate > 0) {
        await server.register({
            plugin: ZipkinTracingHapi({
                localServiceName: 'calculator-service',
                tracerConfig: {
                    endpoint: process.env.ZIPKIN_ENDPOINT,
                    zipkinVersion:
github kevinbgreene / thrift-tutorial / src / identity / server.ts View on Github external
} else {
                    throw new UserServiceException({
                        message: `Unable to find user for id[${id}]`,
                    })
                }
            },
        })

    /**
     * Register the thrift plugin.
     *
     * This will add a Thrift route handler to the '/thrift' path.
     * This behaves like any other HTTP route handler, so you can mix and match
     * thrift / REST endpoints on the same server instance.
     */
    server.register(ThriftServerHapi({
        path: '/thrift',
        thriftOptions: {
            serviceName: '',
            handler: serviceProcessor,
        },
    }), (err: any) => {
        if (err) {
            throw err
        }
    })

    /**
     * Finally, we're ready to start the server.
     */
    server.start((err: any) => {
        if (err) {

@creditkarma/thrift-server-hapi

A Hapi server plugin for the Apache Thrift protocol

Apache-2.0
Latest version published 2 years ago

Package Health Score

49 / 100
Full package analysis