Show More
@@ -136,38 +136,40 b' class clienthandler(object):' | |||||
136 | response = self._responses[frame.requestid] |
|
136 | response = self._responses[frame.requestid] | |
137 |
|
137 | |||
138 | if action == 'responsedata': |
|
138 | if action == 'responsedata': | |
139 | # This buffers all data until end of stream is received. This |
|
139 | self._processresponsedata(frame, meta, response) | |
140 | # is bad for performance. |
|
|||
141 | # TODO make response data streamable |
|
|||
142 | response.b.write(meta['data']) |
|
|||
143 |
|
||||
144 | if meta['eos']: |
|
|||
145 | # If the command has a decoder, resolve the future to the |
|
|||
146 | # decoded value. Otherwise resolve to the rich response object. |
|
|||
147 | decoder = COMMAND_DECODERS.get(response.command) |
|
|||
148 |
|
||||
149 | # TODO consider always resolving the overall status map. |
|
|||
150 | if decoder: |
|
|||
151 | objs = response.cborobjects() |
|
|||
152 |
|
||||
153 | overall = next(objs) |
|
|||
154 |
|
||||
155 | if overall['status'] == 'ok': |
|
|||
156 | self._futures[frame.requestid].set_result(decoder(objs)) |
|
|||
157 | else: |
|
|||
158 | e = error.RepoError( |
|
|||
159 | formatrichmessage(overall['error']['message'])) |
|
|||
160 | self._futures[frame.requestid].set_exception(e) |
|
|||
161 | else: |
|
|||
162 | self._futures[frame.requestid].set_result(response) |
|
|||
163 |
|
||||
164 | del self._requests[frame.requestid] |
|
|||
165 | del self._futures[frame.requestid] |
|
|||
166 |
|
||||
167 | else: |
|
140 | else: | |
168 | raise error.ProgrammingError( |
|
141 | raise error.ProgrammingError( | |
169 | 'unhandled action from clientreactor: %s' % action) |
|
142 | 'unhandled action from clientreactor: %s' % action) | |
170 |
|
143 | |||
|
144 | def _processresponsedata(self, frame, meta, response): | |||
|
145 | # This buffers all data until end of stream is received. This | |||
|
146 | # is bad for performance. | |||
|
147 | # TODO make response data streamable | |||
|
148 | response.b.write(meta['data']) | |||
|
149 | ||||
|
150 | if meta['eos']: | |||
|
151 | # If the command has a decoder, resolve the future to the | |||
|
152 | # decoded value. Otherwise resolve to the rich response object. | |||
|
153 | decoder = COMMAND_DECODERS.get(response.command) | |||
|
154 | ||||
|
155 | # TODO consider always resolving the overall status map. | |||
|
156 | if decoder: | |||
|
157 | objs = response.cborobjects() | |||
|
158 | ||||
|
159 | overall = next(objs) | |||
|
160 | ||||
|
161 | if overall['status'] == 'ok': | |||
|
162 | self._futures[frame.requestid].set_result(decoder(objs)) | |||
|
163 | else: | |||
|
164 | e = error.RepoError( | |||
|
165 | formatrichmessage(overall['error']['message'])) | |||
|
166 | self._futures[frame.requestid].set_exception(e) | |||
|
167 | else: | |||
|
168 | self._futures[frame.requestid].set_result(response) | |||
|
169 | ||||
|
170 | del self._requests[frame.requestid] | |||
|
171 | del self._futures[frame.requestid] | |||
|
172 | ||||
171 | def decodebranchmap(objs): |
|
173 | def decodebranchmap(objs): | |
172 | # Response should be a single CBOR map of branch name to array of nodes. |
|
174 | # Response should be a single CBOR map of branch name to array of nodes. | |
173 | bm = next(objs) |
|
175 | bm = next(objs) |
General Comments 0
You need to be logged in to leave comments.
Login now