|
25 | 25 |
|
26 | 26 | class ReqRep:
|
27 | 27 |
|
28 |
| - def process_call(self, context, bufchan, req_event, functor): |
| 28 | + def process_call(self, context, channel, req_event, functor): |
29 | 29 | context.hook_server_before_exec(req_event)
|
30 | 30 | result = functor(*req_event.args)
|
31 |
| - rep_event = bufchan.create_event('OK', (result,), |
| 31 | + rep_event = channel.create_event('OK', (result,), |
32 | 32 | context.hook_get_task_context())
|
33 | 33 | context.hook_server_after_exec(req_event, rep_event)
|
34 |
| - bufchan.emit_event(rep_event) |
| 34 | + channel.emit_event(rep_event) |
35 | 35 |
|
36 | 36 | def accept_answer(self, event):
|
37 | 37 | return True
|
38 | 38 |
|
39 |
| - def process_answer(self, context, bufchan, req_event, rep_event, |
| 39 | + def process_answer(self, context, channel, req_event, rep_event, |
40 | 40 | handle_remote_error):
|
41 | 41 | if rep_event.name == 'ERR':
|
42 | 42 | exception = handle_remote_error(rep_event)
|
43 | 43 | context.hook_client_after_request(req_event, rep_event, exception)
|
44 | 44 | raise exception
|
45 | 45 | context.hook_client_after_request(req_event, rep_event)
|
46 |
| - bufchan.close() |
| 46 | + channel.close() |
47 | 47 | result = rep_event.args[0]
|
48 | 48 | return result
|
49 | 49 |
|
50 | 50 |
|
51 | 51 | class ReqStream:
|
52 | 52 |
|
53 |
| - def process_call(self, context, bufchan, req_event, functor): |
| 53 | + def process_call(self, context, channel, req_event, functor): |
54 | 54 | context.hook_server_before_exec(req_event)
|
55 | 55 | xheader = context.hook_get_task_context()
|
56 | 56 | for result in iter(functor(*req_event.args)):
|
57 |
| - bufchan.emit('STREAM', result, xheader) |
58 |
| - done_event = bufchan.create_event('STREAM_DONE', None, xheader) |
| 57 | + channel.emit('STREAM', result, xheader) |
| 58 | + done_event = channel.create_event('STREAM_DONE', None, xheader) |
59 | 59 | # NOTE: "We" made the choice to call the hook once the stream is done,
|
60 | 60 | # the other choice was to call it at each iteration. I don't think that
|
61 | 61 | # one choice is better than the other, so I'm fine with changing this
|
62 | 62 | # or adding the server_after_iteration and client_after_iteration hooks.
|
63 | 63 | context.hook_server_after_exec(req_event, done_event)
|
64 |
| - bufchan.emit_event(done_event) |
| 64 | + channel.emit_event(done_event) |
65 | 65 |
|
66 | 66 | def accept_answer(self, event):
|
67 | 67 | return event.name in ('STREAM', 'STREAM_DONE')
|
68 | 68 |
|
69 |
| - def process_answer(self, context, bufchan, req_event, rep_event, |
| 69 | + def process_answer(self, context, channel, req_event, rep_event, |
70 | 70 | handle_remote_error):
|
71 | 71 |
|
72 | 72 | def is_stream_done(rep_event):
|
73 | 73 | return rep_event.name == 'STREAM_DONE'
|
74 |
| - bufchan.on_close_if = is_stream_done |
| 74 | + channel.on_close_if = is_stream_done |
75 | 75 |
|
76 | 76 | def iterator(req_event, rep_event):
|
77 | 77 | while rep_event.name == 'STREAM':
|
78 | 78 | # Like in process_call, we made the choice to call the
|
79 | 79 | # after_exec hook only when the stream is done.
|
80 | 80 | yield rep_event.args
|
81 |
| - rep_event = bufchan.recv() |
| 81 | + rep_event = channel.recv() |
82 | 82 | if rep_event.name == 'ERR':
|
83 | 83 | exception = handle_remote_error(rep_event)
|
84 | 84 | context.hook_client_after_request(req_event, rep_event, exception)
|
85 | 85 | raise exception
|
86 | 86 | context.hook_client_after_request(req_event, rep_event)
|
87 |
| - bufchan.close() |
| 87 | + channel.close() |
88 | 88 |
|
89 | 89 | return iterator(req_event, rep_event)
|
90 | 90 |
|
|
0 commit comments