@creditkarma/thrift-client-ttwitter-filter

Filter for appending TTwitter context onto thrift-client payload

Usage no npm install needed!

<script type="module">
  import creditkarmaThriftClientTtwitterFilter from 'https://cdn.skypack.dev/@creditkarma/thrift-client-ttwitter-filter';
</script>

README

ThriftClientTTwitterFilter

This plugin can be used in conjuction with Twitter's open source Finagle project to add and receive the headers that project expects.

Installation

ThriftClientTTwitterFilter has a few peerDependencies.

npm install --save @creditkarma/thrift-server-core
npm install --save @creditkarma/thrift-client
npm install --save @creditkarma/thrift-client-context-filter
npm install --save @creditkarma/thrift-client-ttwitter-filter

Usage

import {
    createTcpClient,
} from '@creditkarma/thrift-client'

import {
    ThriftClientTTwitterFilter,
} from '@creditkarma/thrift-client-ttwitter-filter'

import {
    Calculator,
} from './codegen/calculator'

const thriftClient: Calculator.Client<RequestContext> =
    createTcpClient(Calculator.Client, {
        hostName: 'localhost',
        port: 8080,
        register: [ ThriftClientTTwitterFilter({
            localServiceName: 'calculator-client',
            remoteServiceName: 'calculator-service',
            destHeader: 'calculator-service',
            endpoint: 'http://localhost:9411/api/v1/spans',
            sampleRate: 1,
        }) ]
    })

thriftClient.add(5, 6).then((response: number) => {
    // Do stuff...
})

Note: The Twitter types are generated and exported under the name TTwitter

Options

Available options for ThriftClientTTwitterFilter:

  • localServiceName (required): The name of your local service/application.
  • remoteServiceName (required): The name of the remote service you are calling.
  • destHeader (optional): A name for the destination added to the RequestHeader object Finagle expects. Defaults to the value of remoteServiceName.
  • isUpgraded (optional): Is the service using TTwitter context. Defaults to true.
  • clientId (optional): A unique identifier for the client. Defaults to undefined.
  • transportType (optional): The type of transport to use. Currently only 'buffered'.
  • protocolType (optional): The type of protocol to use. Currently only 'binary'.
  • tracerConfig.debug (optional): Zipkin debug mode. Defaults to false.
  • tracerConfig.endpoint (optional): Zipkin endpoint. Defaults to ''.
  • tracerConfig.sampleRate (optional): Zipkin samplerate. Defaults to 0.1.
  • tracerConfig.httpInterval (optional): Rate (in milliseconds) at which to send traces to Zipkin collector. Defaults to 1000.

Contributing

For more information about contributing new features and bug fixes, see our Contribution Guidelines. External contributors must sign Contributor License Agreement (CLA)

License

This project is licensed under Apache License Version 2.0