Created
August 7, 2015 20:27
-
-
Save HelloGrayson/84b6e947c7937084f12b to your computer and use it in GitHub Desktop.
Do we want to pull Hyperbahn specific logic into it's own client like Node & Go?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tchannel import TChannel, Hyperbahn | |
tchannel = TChannel('my-service') | |
tchannel.listen() # or | |
hyperbahn = Hyperbahn(tchannel) | |
hyperbahn.advertise() |
Or, with inheritance:
from tchannel import Hyperbahn
hyperbahn = Hyperbahn('my-service')
hyperbahn.advertise()
This has the benefit of representing the same public API with additional methods.
hyperbahn.raw()
hyperbahn.json()
hyperbahn.thrift()
I don't find that this abuses inheritance.
Let's be consistent with node/go.
I'll look more into it.
From what I can tell, this is consistent with Go & Node:
In app.py
:
from tchannel import TChannel, Hyperbahn
tchannel = TChannel('my-service')
hyperbahn = Hyperbahn(tchannel)
hyperbahn.advertise()
In endpoint.py
or some service layer class:
from app import tchannel
tchannel.thrift(...)
So in summary you compose a TChannel in to a Hyperbahn and call advertise instead of listen, and then continue to use the tchannel object. I think this will work in Python since everything is a reference.
Corbin seems to think we need to consider sub-channels, so I'll bang my head against the design a bit more so we don't get it wrong.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As does Node: https://github.com/uber/tchannel/blob/master/node/hyperbahn/index.js#L100