How to use the @creditkarma/thrift-server-core.readThriftMethod function in @creditkarma/thrift-server-core

To help you get started, we’ve selected a few @creditkarma/thrift-server-core 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-client / src / main / connections / TcpConnection.ts View on Github external
public send(dataToSend: Buffer, context: any = {}): Promise {
        const requestMethod: string = readThriftMethod(
            dataToSend,
            this.Transport,
            this.Protocol,
        )
        const handlers: Array> = this.handlersForMethod(
            requestMethod,
        )
        const thriftRequest: IThriftRequest = {
            data: dataToSend,
            methodName: requestMethod,
            uri: `${this.hostName}:${this.port}`,
            context,
        }

        const applyHandlers = (
            currentRequest: IThriftRequest,
github creditkarma / thrift-server / packages / thrift-integration / src / client / connections / index.spec.ts View on Github external
(
                                    res: IRequestResponse,
                                ): Promise => {
                                    if (readThriftMethod(res.body) === 'add') {
                                        return Promise.resolve(res)
                                    } else {
                                        return Promise.reject(
                                            new Error(
                                                `Unrecognized method name: ${readThriftMethod(
                                                    request.data,
                                                )}`,
                                            ),
                                        )
                                    }
                                },
                            )
github creditkarma / thrift-server / packages / zipkin-tracing-express / src / main / ZipkinTracingExpress.ts View on Github external
tracer.scoped(() => {
            const requestMethod: string =
                isThrift === true
                    ? readThriftMethod(
                          request.body,
                          getTransport(transport),
                          getProtocol(protocol),
                      )
                    : request.method

            const normalHeaders: IRequestHeaders = normalizeHeaders(
                request.headers,
            )

            function readHeader(header: string): option.IOption {
                const val = normalHeaders[header.toLocaleLowerCase()]
                if (val !== null && val !== undefined) {
                    return new option.Some(val)
                } else {
                    return option.None
github creditkarma / thrift-server / packages / thrift-integration / src / client / connections / TcpConnection.spec.ts View on Github external
handler(
                        request: IThriftRequest,
                        next: NextFunction,
                    ): Promise {
                        if (thrift.readThriftMethod(request.data) === 'fake') {
                            return next()
                        } else {
                            return Promise.reject(
                                new Error(
                                    `Unrecognized method name: ${thrift.readThriftMethod(
                                        request.data,
                                    )}`,
                                ),
                            )
                        }
                    },
                },
github creditkarma / thrift-server / packages / thrift-integration / src / client / connections / HttpConnection.spec.ts View on Github external
handler(
                    req: IThriftRequest,
                    next: NextFunction,
                ): Promise {
                    if (thrift.readThriftMethod(req.data) === 'add') {
                        return next()
                    } else {
                        return Promise.reject(
                            new Error(
                                `Unrecognized method name: ${thrift.readThriftMethod(
                                    req.data,
                                )}`,
                            ),
                        )
                    }
                },
            })
github creditkarma / thrift-server / packages / thrift-integration / src / client / connections / index.spec.ts View on Github external
return next().then((response: IRequestResponse) => {
                                if (readThriftMethod(response.body) === 'add') {
                                    return Promise.resolve(response)
                                } else {
                                    return Promise.reject(
                                        new Error(
                                            `Unrecognized method name: ${readThriftMethod(
                                                response.body,
                                            )}`,
                                        ),
                                    )
                                }
                            })
                        },
github creditkarma / thrift-server / packages / thrift-integration / src / client / connections / TcpConnection.spec.ts View on Github external
handler(
                        request: IThriftRequest,
                        next: NextFunction,
                    ): Promise {
                        if (thrift.readThriftMethod(request.data) === 'fake') {
                            return next()
                        } else {
                            return Promise.reject(
                                new Error(
                                    `Unrecognized method name: ${thrift.readThriftMethod(
                                        request.data,
                                    )}`,
                                ),
                            )
                        }
                    },
                },
github creditkarma / thrift-server / packages / thrift-server-hapi / src / main / ThriftServerHapi.ts View on Github external
const handler: Hapi.Lifecycle.Method = (
                request: Hapi.Request,
                reply: Hapi.ResponseToolkit,
            ) => {
                const buffer: Buffer = Core.stripStruct(
                    request.payload as Buffer,
                )

                const method: string = Core.readThriftMethod(
                    buffer,
                    Transport,
                    Protocol,
                )

                request.plugins.thrift = {
                    requestMethod: method,
                }

                return Core.process({
                    processor,
                    buffer,
                    Transport,
                    Protocol,
                    context: request,
                })
github creditkarma / thrift-server / packages / thrift-server-express / src / main / ThriftServerExpress.ts View on Github external
return (
        request: ThriftRequest,
        response: express.Response,
        next: express.NextFunction,
    ): void => {
        const Transport: ITransportConstructor = getTransport(
            pluginOptions.transport,
        )
        const Protocol: IProtocolConstructor = getProtocol(
            pluginOptions.protocol,
        )
        const buffer: Buffer = request.body

        const method: string = readThriftMethod(buffer, Transport, Protocol)

        request.thrift = {
            requestMethod: method,
            processor: pluginOptions.handler,
            transport: pluginOptions.transport || 'buffered',
            protocol: pluginOptions.protocol || 'binary',
        }

        try {
            process({
                processor: pluginOptions.handler,
                buffer,
                Transport,
                Protocol,
                context: request,
            }).then(
github creditkarma / thrift-server / packages / thrift-client / src / main / connections / HttpConnection.ts View on Github external
public send(
        dataToSend: Buffer,
        context: RequestOptions = {},
    ): Promise {
        const requestMethod: string = Core.readThriftMethod(
            dataToSend,
            this.Transport,
            this.Protocol,
        )

        const filters: Array<
            RequestHandler
        > = this.filtersForMethod(requestMethod)

        const thriftRequest: IThriftRequest = {
            data: dataToSend,
            methodName: requestMethod,
            uri: this.url,
            context,
        }