Skip to content

Instantly share code, notes, and snippets.

@HelloGrayson
Last active June 27, 2024 15:55
Show Gist options
  • Save HelloGrayson/ca4f6b9c17861327aa8a to your computer and use it in GitHub Desktop.
Save HelloGrayson/ca4f6b9c17861327aa8a to your computer and use it in GitHub Desktop.
tchannel .call api change
# raw
response = yield tchannel.call(
argscheme="raw",
service="someservice",
endpoint="something",
body="RAWRESPONSE",
headers={
'X-Source': 'geo'
},
ttl=1000
)
# json
response = yield tchannel.call(
argscheme = "json"
service="someservice",
endpoint="maps",
body="{
'lat': 100,
'lng': 140
}",
headers={
'X-Source': 'geo'
},
ttl=1000
)
# thrift
Foo = get_tchannel_thrift(FooThrift, 'fooservice')
response = yield tchannel.call(
argscheme="thrift",
"some_binary",
headers={
'X-Source': 'geo'
},
ttl=1000
)
response = yield tchannel.call_thrift(
Foo.getBar(Foo.BarResponse("hi")),
headers={
'X-Source': 'geo'
},
timeout=5000
)
response = yield tchannel.as_thrift().call(
Foo.getBar(Foo.BarResponse("hi")),
headers={
'X-Source': 'geo'
},
timeout=5000
)
response = yield tchannel.thrift.call(
Foo.getBar(Foo.BarResponse("hi")),
headers={
'X-Source': 'geo'
},
timeout=5000
)
future = tchannel_sync.call(
Foo.baz(True),
headers={
'X-Source': 'geo'
},
ttl=1000
)
@blampe
Copy link

blampe commented Jul 28, 2015

Suggestion: make the streamed response iterable, e.g. for thing in response.

@HelloGrayson
Copy link
Author

@blampe +1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment