Couchbase executors
bondi.couchbase.CouchbaseExecutor
Bases: _SyncExecutor
Synchronous database executor with an owned connection.
Create with from_uri(). Use with or explicitly call close() when finished. Calls retain one private event loop and must stay on the creating thread. Works in notebooks: the owned event loop runs on a dedicated background thread. Operation options, results, concurrency and errors match the async executor.
Source code in src/bondi/couchbase/sync_executor.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
close()
Close the connection, stop its loop and join its thread; idempotent.
Source code in src/bondi/_sync.py
107 108 109 110 111 112 113 114 115 | |
explain(query, *, query_kwargs=None)
Synchronously explain; options match AsyncCouchbaseExecutor.explain.
Source code in src/bondi/couchbase/sync_executor.py
63 64 65 66 67 | |
explain_workload(workload, *, query_kwargs=None)
Synchronously explain workload; options match AsyncCouchbaseExecutor.explain_workload.
Source code in src/bondi/couchbase/sync_executor.py
93 94 95 96 97 | |
from_uri(uri, *, username, password, concurrency=1, continue_on_error=False, timeout_seconds=None, cluster_kwargs=None)
classmethod
Create an owned connection on a private event loop.
Accepts the same connection options as the async executor. Close explicitly or use a with block.
Source code in src/bondi/couchbase/sync_executor.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
profile(query, *, collect_results=False, query_kwargs=None)
Synchronously profile; options match AsyncCouchbaseExecutor.profile.
Source code in src/bondi/couchbase/sync_executor.py
69 70 71 72 73 74 75 76 77 78 79 | |
profile_workload(workload, *, collect_results=False, query_kwargs=None)
Synchronously profile workload; options match AsyncCouchbaseExecutor.profile_workload.
Source code in src/bondi/couchbase/sync_executor.py
99 100 101 102 103 104 105 106 107 108 109 | |
run(query, *, collect_results=False, query_kwargs=None)
Synchronously run; options match AsyncCouchbaseExecutor.run.
Source code in src/bondi/couchbase/sync_executor.py
53 54 55 56 57 58 59 60 61 | |
run_workload(workload, *, collect_results=False, query_kwargs=None)
Synchronously run workload; options match AsyncCouchbaseExecutor.run_workload.
Source code in src/bondi/couchbase/sync_executor.py
81 82 83 84 85 86 87 88 89 90 91 | |
bondi.couchbase.AsyncCouchbaseExecutor
Run, explain and profile SQL++ queries with bounded async workload workers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cluster
|
Cluster
|
Borrowed acouchbase Cluster; the caller closes it. |
required |
concurrency
|
int
|
Positive maximum in-flight entries per workload call. |
1
|
continue_on_error
|
bool
|
Continue scheduling after database/timeout failures. |
False
|
timeout_seconds
|
float | None
|
Positive finite per-operation deadline, including row consumption. None retains the SDK's configured query timeout. |
None
|
Install the couchbase extra to instantiate this class. Inputs are retained by reference and must not be modified during calls. Use one event loop per cluster. Single operations raise; workloads capture SDK operation errors. Programming errors and cancellation propagate. No additional retries or write guard are added.
Source code in src/bondi/couchbase/executor.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | |
close()
async
Close an owned cluster once; leave borrowed clusters open.
Source code in src/bondi/couchbase/executor.py
169 170 171 172 173 | |
explain(query, *, query_kwargs=None)
async
Prefix the supplied statement with EXPLAIN and return its native plan in raw.
Supply the original SQL++ statement, without an EXPLAIN prefix. No execution statistics are collected for that statement. row_count/documents remain None; EXPLAIN request metrics are not measurements of the underlying query.
Source code in src/bondi/couchbase/executor.py
212 213 214 215 216 217 218 219 220 221 | |
explain_workload(workload, *, query_kwargs=None)
async
Explain entries with run_workload's scheduling and failure policy.
Source code in src/bondi/couchbase/executor.py
307 308 309 310 311 312 313 314 | |
from_uri(uri, *, username, password, concurrency=1, continue_on_error=False, timeout_seconds=None, cluster_kwargs=None)
async
classmethod
Connect an owned cluster and wait up to 30 seconds for the Query service.
Await this factory before using async with. cluster_kwargs supplies native ClusterOptions; authentication comes from username/password. On readiness failure or cancellation the newly connected cluster is closed. Connection setup is outside per-query timing and uses SDK connection timeout settings.
Source code in src/bondi/couchbase/executor.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | |
profile(query, *, collect_results=False, query_kwargs=None)
async
Execute with TIMINGS profiling, consuming all rows and returning metadata.
Unlike MongoDB profiling, Couchbase can also return the actual query rows. When executionTimings is absent, retain basic metrics and add a warning. No extra EXPLAIN request or automatic summary parsing is performed.
Source code in src/bondi/couchbase/executor.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 | |
profile_workload(workload, *, collect_results=False, query_kwargs=None)
async
Profile entries with run_workload's scheduling and failure policy.
Source code in src/bondi/couchbase/executor.py
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 | |
run(query, *, collect_results=False, query_kwargs=None)
async
Consume all rows, optionally retain them, and return metrics in raw.
query_kwargs accepts native QueryOptions such as scan_consistency or read_only. Bindings, context, timeout, metrics, profile, raw and serializer are reserved. SDK consistency defaults apply unless explicitly overridden.
Source code in src/bondi/couchbase/executor.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 | |
run_workload(workload, *, collect_results=False, query_kwargs=None)
async
Run entries with input-aligned results and bounded concurrency.
None marks unstarted entries. With continue_on_error=False, stop scheduling after observing a failure and drain in-flight operations. True attempts all entries. Partial rows are discarded on failure. Validate all inputs first.
Source code in src/bondi/couchbase/executor.py
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 | |
Workloads, failures and options
from bondi.workload import Workload, WorkloadEntry
workload = Workload([WorkloadEntry(query), WorkloadEntry(query)])
# Inside the executor context:
results = executor.run_workload(workload)
plans = executor.explain_workload(workload)
profiles = executor.profile_workload(workload)
All methods share bounded concurrency, input ordering and failure policy. With
continue_on_error=False, scheduling stops after observing an error while in-flight
operations finish. Unstarted entries are None. With True, remaining entries are
attempted. Expected SDK failures are stored in .error; single-query methods raise.
Partial results are discarded. SDK argument errors, programming errors and caller
cancellation propagate after workers are cleaned up. Timeout status recognizes
both ambiguous and unambiguous SDK timeouts and local deadlines.
timeout_seconds sets both an SDK query timeout and a local deadline through row
consumption. None leaves the SDK timeout in effect. Inputs are not snapshotted;
do not mutate them during operations.
query_kwargs passes native QueryOptions, including scan_consistency, read_only,
adhoc and client_context_id. SDK defaults apply unless overridden; in particular,
NOT_BOUNDED may observe indexes before recent writes arrive. Use REQUEST_PLUS
when fresh index contents matter, and account for that wait in measurements.
Bindings, query context, metrics, profile, timeout and serializer are reserved.
The nested SDK raw escape hatch is also reserved because it can bypass these
controls. No read-only guard or extra retry policy is imposed by the toolkit.
See the official SDK query guide for native options. The implementation is tested with SDK 4.6.3 and both local Couchbase 7.6.2 editions.