MCPcopy Index your code
hub / github.com/couchbase/couchbase-python-client / _execute_op

Method _execute_op

couchbase/datastructures.py:642–681  ·  view source on GitHub ↗
(self,
                    fn: DatastructureCallable,
                    req: PycbcCoreKeyValueRequest,
                    obs_handler: ObservableRequestHandler,
                    parent_span: WrappedSpan,
                    create_type: Optional[bool] = None,
                    transcoder: Optional[Transcoder] = None)

Source from the content-addressed store, hash-verified

640 self._impl = collection_impl
641
642 def _execute_op(self,
643 fn: DatastructureCallable,
644 req: PycbcCoreKeyValueRequest,
645 obs_handler: ObservableRequestHandler,
646 parent_span: WrappedSpan,
647 create_type: Optional[bool] = None,
648 transcoder: Optional[Transcoder] = None) -> Any:
649 try:
650 fn_args = [req]
651 if transcoder:
652 fn_args.append(transcoder)
653 fn_args.append(obs_handler)
654 return fn(*fn_args)
655 except DocumentNotFoundException as ex:
656 if create_type is True:
657 orig_opt_type = obs_handler.op_type
658 obs_handler.reset(KeyValueOperationType.Insert, exc_val=ex)
659 try:
660 ins_req = self._impl.request_builder.build_insert_request(self._key,
661 list(),
662 obs_handler,
663 parent_span=parent_span)
664 self._impl.insert(ins_req, obs_handler)
665 except DocumentExistsException:
666 pass
667 obs_handler.reset(orig_opt_type)
668 obs_handler.create_kv_span(self._impl._request_builder._collection_dtls.get_details_as_dict(),
669 parent_span=parent_span)
670 # Legacy tracing relies on passing the actual span in w/ the request. Since we are re-using the
671 # request object, we need to set the request parent span to the newly created span if we are in
672 # legacy tracing mode.
673 if obs_handler.is_legacy_tracer:
674 req.parent_span = obs_handler.legacy_request_span
675 fn_args = [req]
676 if transcoder:
677 fn_args.append(transcoder)
678 fn_args.append(obs_handler)
679 return fn(*fn_args)
680 else:
681 raise
682
683 def _get(self, parent_span: Optional[WrappedSpan] = None) -> List[Any]:
684 """

Callers 3

_getMethod · 0.95
addMethod · 0.95
sizeMethod · 0.95

Calls 6

build_insert_requestMethod · 0.80
get_details_as_dictMethod · 0.80
appendMethod · 0.45
resetMethod · 0.45
insertMethod · 0.45
create_kv_spanMethod · 0.45

Tested by

no test coverage detected