(self,
orig, # type: pycbc_result
result_type, # type: Union[GetReplicaResult, GetResult]
return_exceptions, # type: bool
transcoders=None, # type: Optional[Dict[str, Transcoder]]
obs_handler=None # type: Optional[ObservableRequestHandler]
)
| 395 | |
| 396 | class MultiResult: |
| 397 | def __init__(self, |
| 398 | orig, # type: pycbc_result |
| 399 | result_type, # type: Union[GetReplicaResult, GetResult] |
| 400 | return_exceptions, # type: bool |
| 401 | transcoders=None, # type: Optional[Dict[str, Transcoder]] |
| 402 | obs_handler=None # type: Optional[ObservableRequestHandler] |
| 403 | ): |
| 404 | self._orig = orig |
| 405 | self._all_ok = self._orig.raw_result.pop('all_okay', False) |
| 406 | self._results = {} |
| 407 | self._result_type = result_type |
| 408 | for k, v in self._orig.raw_result.items(): |
| 409 | # pycbc_result and pycbc_exception have a core_span member |
| 410 | # need to check if the tracer has already processed the core span (scenario for GetAllReplicasMulti) |
| 411 | if (obs_handler and hasattr(v, 'core_span') |
| 412 | and not obs_handler.tracer_processed_kv_get_all_replicas_core_span): |
| 413 | obs_handler.process_core_span(v.core_span) |
| 414 | if isinstance(v, (CouchbaseException, PycbcCoreException)): |
| 415 | if isinstance(v, PycbcCoreException): |
| 416 | exc = ErrorMapper.build_exception(v) |
| 417 | else: |
| 418 | exc = v |
| 419 | if obs_handler: |
| 420 | obs_handler.process_multi_sub_op(v, exc_val=exc) |
| 421 | if not return_exceptions: |
| 422 | raise exc |
| 423 | else: |
| 424 | self._results[k] = exc |
| 425 | else: |
| 426 | if obs_handler: |
| 427 | obs_handler.process_multi_sub_op(v) |
| 428 | if isinstance(v, list): |
| 429 | self._results[k] = v |
| 430 | else: |
| 431 | if transcoders is None: |
| 432 | raise InvalidArgumentException("Transcoders dictionary must be provided") |
| 433 | self._results[k] = result_type(v, transcoder=transcoders[k]) |
| 434 | |
| 435 | @property |
| 436 | def all_ok(self) -> bool: |
nothing calls this directly
no test coverage detected