Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 47cd3af

Browse files
committed
more clear naming
1 parent 0ac1a3b commit 47cd3af

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

Diff for: tchannel/thrift/server.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,12 @@ def hello(request, response, tchannel):
8484
args_type = getattr(service_module, method + '_args')
8585
result_type = getattr(service_module, method + '_result')
8686

87-
# only wrap the handler if we arent using the new server api
88-
if not dispatcher._handler_returns_response:
87+
# if the dispatcher is set to deal with handlers that
88+
# return responses, then use new api, else use deprecated
89+
if dispatcher._handler_returns_response:
8990
handler = build_handler(result_type, handler)
9091
else:
91-
handler = new_build_handler(result_type, handler)
92+
handler = deprecated_build_handler(result_type, handler)
9293

9394
dispatcher.register(
9495
endpoint,
@@ -99,7 +100,7 @@ def hello(request, response, tchannel):
99100
return handler
100101

101102

102-
def new_build_handler(result_type, f):
103+
def build_handler(result_type, f):
103104
@gen.coroutine
104105
def handler(request):
105106

@@ -129,7 +130,7 @@ def handler(request):
129130
return handler
130131

131132

132-
def build_handler(result_type, f):
133+
def deprecated_build_handler(result_type, f):
133134
@gen.coroutine
134135
def handler(request, response, tchannel):
135136
req = yield ThriftRequest._from_raw_request(request)

Diff for: tests/thrift/test_server.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from thrift.Thrift import TType
2626

2727
from tchannel.serializer.thrift import ThriftSerializer
28-
from tchannel.thrift.server import build_handler
28+
from tchannel.thrift.server import deprecated_build_handler
2929
from tchannel.tornado.request import Request
3030
from tchannel.tornado.response import Response
3131
from tchannel.tornado.stream import InMemStream
@@ -89,7 +89,7 @@ def write(self, proto):
8989

9090

9191
@pytest.mark.gen_test
92-
def test_build_handler():
92+
def test_deprecated_build_handler():
9393

9494
def call(treq, tres, tchan):
9595
assert treq.transport.headers == {
@@ -123,7 +123,7 @@ def call(treq, tres, tchan):
123123
)
124124
tchannel = mock.Mock()
125125

126-
handler = build_handler(FakeResult, call)
126+
handler = deprecated_build_handler(FakeResult, call)
127127
yield handler(req, res, tchannel)
128128

129129
serialized_headers = yield response_header.read()
@@ -149,7 +149,7 @@ def call(treq, tres, tchan):
149149

150150

151151
@pytest.mark.gen_test
152-
def test_build_handler_exception():
152+
def test_deprecated_build_handler_exception():
153153
def call(treq, tres, tchan):
154154
raise FakeException('fail')
155155

@@ -175,7 +175,7 @@ def call(treq, tres, tchan):
175175
)
176176
tchannel = mock.Mock()
177177

178-
handler = build_handler(FakeResult, call)
178+
handler = deprecated_build_handler(FakeResult, call)
179179
yield handler(req, res, tchannel)
180180

181181
response_body.write.assert_called_once_with(

0 commit comments

Comments
 (0)