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

Method _execute_op

couchbase/datastructures.py:375–414  ·  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

373 self._full_map = None
374
375 def _execute_op(self,
376 fn: DatastructureCallable,
377 req: PycbcCoreKeyValueRequest,
378 obs_handler: ObservableRequestHandler,
379 parent_span: WrappedSpan,
380 create_type: Optional[bool] = None,
381 transcoder: Optional[Transcoder] = None) -> Any:
382 try:
383 fn_args = [req]
384 if transcoder:
385 fn_args.append(transcoder)
386 fn_args.append(obs_handler)
387 return fn(*fn_args)
388 except DocumentNotFoundException as ex:
389 if create_type is True:
390 orig_opt_type = obs_handler.op_type
391 obs_handler.reset(KeyValueOperationType.Insert, exc_val=ex)
392 try:
393 ins_req = self._impl.request_builder.build_insert_request(self._key,
394 dict(),
395 obs_handler,
396 parent_span=parent_span)
397 self._impl.insert(ins_req, obs_handler)
398 except DocumentExistsException:
399 pass
400 obs_handler.reset(orig_opt_type)
401 obs_handler.create_kv_span(self._impl._request_builder._collection_dtls.get_details_as_dict(),
402 parent_span=parent_span)
403 # Legacy tracing relies on passing the actual span in w/ the request. Since we are re-using the
404 # request object, we need to set the request parent span to the newly created span if we are in
405 # legacy tracing mode.
406 if obs_handler.is_legacy_tracer:
407 req.parent_span = obs_handler.legacy_request_span
408 fn_args = [req]
409 if transcoder:
410 fn_args.append(transcoder)
411 fn_args.append(obs_handler)
412 return fn(*fn_args)
413 else:
414 raise
415
416 def _get(self, parent_span: Optional[WrappedSpan] = None) -> Dict[str, Any]:
417 """

Callers 5

_getMethod · 0.95
addMethod · 0.95
getMethod · 0.95
sizeMethod · 0.95
existsMethod · 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