| 368 | } |
| 369 | |
| 370 | PyObject* |
| 371 | Connection::diagnostics(PyObject* kwargs) |
| 372 | { |
| 373 | std::optional<std::string> report_id; |
| 374 | extract_field<std::optional<std::string>>(kwargs, "report_id", report_id); |
| 375 | |
| 376 | PyObject* pyObj_callback = PyDict_GetItemString(kwargs, "callback"); |
| 377 | PyObject* pyObj_errback = PyDict_GetItemString(kwargs, "errback"); |
| 378 | |
| 379 | if (!validate_and_incref_callbacks(pyObj_callback, pyObj_errback)) { |
| 380 | return nullptr; |
| 381 | } |
| 382 | |
| 383 | std::shared_ptr<std::promise<PyObject*>> barrier = nullptr; |
| 384 | std::future<PyObject*> fut; |
| 385 | if (nullptr == pyObj_callback && nullptr == pyObj_errback) { |
| 386 | barrier = std::make_shared<std::promise<PyObject*>>(); |
| 387 | fut = barrier->get_future(); |
| 388 | } |
| 389 | |
| 390 | try { |
| 391 | Py_BEGIN_ALLOW_THREADS |
| 392 | { |
| 393 | cluster_.diagnostics(report_id, |
| 394 | [pyObj_callback, pyObj_errback, barrier, this]( |
| 395 | couchbase::core::diag::diagnostics_result resp) { |
| 396 | handle_cluster_operation_callback( |
| 397 | resp, pyObj_callback, pyObj_errback, barrier); |
| 398 | }); |
| 399 | } |
| 400 | Py_END_ALLOW_THREADS |
| 401 | |
| 402 | if (barrier) |
| 403 | { |
| 404 | PyObject* result = nullptr; |
| 405 | Py_BEGIN_ALLOW_THREADS result = fut.get(); |
| 406 | Py_END_ALLOW_THREADS return result; |
| 407 | } |
| 408 | Py_RETURN_NONE; |
| 409 | } catch (const std::exception& e) { |
| 410 | if (barrier) { |
| 411 | barrier->set_value(nullptr); |
| 412 | } |
| 413 | PyErr_SetString(PyExc_RuntimeError, e.what()); |
| 414 | Py_XDECREF(pyObj_callback); |
| 415 | Py_XDECREF(pyObj_errback); |
| 416 | return nullptr; |
| 417 | } |
| 418 | } |
| 419 | |
| 420 | PyObject* |
| 421 | Connection::ping(PyObject* kwargs) |
no outgoing calls
no test coverage detected