GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - uber/tchannel-node

This repository was archived by the owner on May 3, 2022. It is now read-only.
BranchesTags
Open more actions menu

Latest commit

 

History

4,171 Commits
4,171 Commits

Folders and files

NameName
Last commit message
Last commit date
as
as
 
 
benchmarks
benchmarks
 
 
bin
bin
 
 
docs
docs
 
 
examples
examples
 
 
hyperbahn
hyperbahn
 
 
lib
lib
 
 
scripts
scripts
 
 
tcollector
tcollector
 
 
test
test
 
 
trace
trace
 
 
v1
v1
 
 
v2
v2
 
 
.eslintignore
.eslintignore
 
 
.eslintrc
.eslintrc
 
 
.gitignore
.gitignore
 
 
.travis.yml
.travis.yml
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CONTRIBUTION.md
CONTRIBUTION.md
 
 
LICENSE
LICENSE
 
 
MIGRATION.md
MIGRATION.md
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
argstream.js
argstream.js
 
 
channel.js
channel.js
 
 
connection.js
connection.js
 
 
docs.jsig
docs.jsig
 
 
drain.js
drain.js
 
 
endpoint-handler.js
endpoint-handler.js
 
 
errors.js
errors.js
 
 
host-port.js
host-port.js
 
 
hyperbahn-client.js
hyperbahn-client.js
 
 
hyperbahn.thrift
hyperbahn.thrift
 
 
in_request.js
in_request.js
 
 
in_response.js
in_response.js
 
 
lazy_relay.js
lazy_relay.js
 
 
mkdocs.yml
mkdocs.yml
 
 
monitor.js
monitor.js
 
 
null-logger.js
null-logger.js
 
 
operations.js
operations.js
 
 
out_request.js
out_request.js
 
 
out_response.js
out_response.js
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
peer-file-watcher.js
peer-file-watcher.js
 
 
peer.js
peer.js
 
 
peer_heap.js
peer_heap.js
 
 
peer_score_strategies.js
peer_score_strategies.js
 
 
peers_base.js
peers_base.js
 
 
publish.sh
publish.sh
 
 
range.js
range.js
 
 
relay_handler.js
relay_handler.js
 
 
reqres_states.js
reqres_states.js
 
 
request-handler.js
request-handler.js
 
 
request.js
request.js
 
 
retry-flags.js
retry-flags.js
 
 
root_peers.js
root_peers.js
 
 
service-name-handler.js
service-name-handler.js
 
 
services.js
services.js
 
 
stat-tags.js
stat-tags.js
 
 
streaming_in_request.js
streaming_in_request.js
 
 
streaming_in_response.js
streaming_in_response.js
 
 
streaming_out_request.js
streaming_out_request.js
 
 
streaming_out_response.js
streaming_out_response.js
 
 
sub_peers.js
sub_peers.js
 
 
tag.sh
tag.sh
 
 
time_heap.js
time_heap.js
 
 

Repository files navigation

This project is no longer active. See #372

TChannel

network multiplexing and framing protocol for RPC

Stability: stable

stable

Example

var TChannel = require('tchannel');

var server = new TChannel();
var client = new TChannel();

var serverChan = server.makeSubChannel({
    serviceName: 'server'
});

// normal response
serverChan.register('func1', function onReq(req, res, arg2, arg3) {
    console.log('func1 responding', { arg2: arg2.toString(), arg3: arg3.toString() });
    res.headers.as = 'raw';
    res.sendOk('result', 'indeed it did');
});

// err response
serverChan.register('func2', function onReq2(req, res) {
    res.headers.as = 'raw';
    res.sendNotOk(null, 'it failed');
});

server.listen(4040, '127.0.0.1', function onListen() {
    var clientChan = client.makeSubChannel({
        serviceName: 'server',
        peers: [server.hostPort],
        requestDefaults: {
            hasNoParent: true,
            headers: { 'as': 'raw', 'cn': 'example-client' }
        }
    });

    clientChan.request({
        serviceName: 'server',
        timeout: 1000
    }).send('func1', 'arg 1', 'arg 2', function onResp(err, res, arg2, arg3) {
        console.log('normal res:', { arg2: arg2.toString(), arg3: arg3.toString() });
    });

    clientChan.request({
        serviceName: 'server'
    }).send('func2', 'arg 1', 'arg 2', function onResp(err, res, arg2, arg3) {
        console.log('err res: ', { ok: res.ok, message: String(arg3) });
    });
});

This example registers two functions on the "server". "func 1" always works and "func 2" always returns an error. The client sends a request for each function, then prints the result.

Note that every instance is bidirectional. New connections are initiated on demand.

Overview

TChannel is a network protocol with the following goals:

  • request / response model
  • multiple requests multiplexed across the same TCP socket
  • out of order responses
  • streaming request and responses
  • all frames checksummed
  • transport arbitrary payloads
  • easy to implement in multiple languages
  • near-redis performance

This protocol is intended to run on datacenter networks for inter-process communication.

Protocol

TChannel frames have a fixed length header and 3 variable length fields. The underlying protocol does not assign meaning to these fields, but the included client/server implementation uses the first field to represent a unique endpoint or function name in an RPC model. The next two fields can be used for arbitrary data. Some suggested way to use the 3 fields are:

  • URI path, HTTP method and headers as JSON, body
  • function name, headers, thrift / protobuf

Note however that the only encoding supported by TChannel is UTF-8. If you want JSON, you'll need to stringify and parse outside of TChannel.

This design supports efficient routing and forwarding of data where the routing information needs to parse only the first or second field, but the 3rd field is forwarded without parsing.

There is no notion of client and server in this system. Every TChannel instance is capable of making or receiving requests, and thus requires a unique port on which to listen. This requirement may change in the future.

  • See protocol.md for more details

Performance

On a Macbook Pro, we see around 50,000 ops/sec from a single node process talking to one other node process.

Documentation

See the docs folder.

Further examples

See the examples folder

Installation

npm install tchannel

Tests

npm test

Contributors

  • mranney
  • jwolski
  • Raynos
  • jcorbin
  • kriskowal
  • shannili
  • rf

MIT Licenced

About

No description, website, or topics provided.

Resources

Readme
MIT license

Code of conduct

Code of conduct
Activity
Custom properties

Stars

201 stars

Watchers

497 watching

Forks

36 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.