ccproxy.plugins.duckdb_storage.storage¶
ccproxy.plugins.duckdb_storage.storage
¶
Simplified DuckDB storage for low-traffic environments.
This module provides a simple, direct DuckDB storage implementation without connection pooling or batch processing. Suitable for dev environments with low request rates (< 10 req/s).
SimpleDuckDBStorage
¶
Simple DuckDB storage with queue-based writes to prevent deadlocks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
database_path
|
str | Path
|
Path to DuckDB database file |
'data/metrics.duckdb'
|
Source code in ccproxy/plugins/duckdb_storage/storage.py
initialize
async
¶
Initialize the storage backend.
Source code in ccproxy/plugins/duckdb_storage/storage.py
optimize
¶
Run PRAGMA optimize on the database engine if available.
This is a lightweight maintenance step to improve performance and reclaim space in DuckDB. Safe to call on file-backed databases.
Source code in ccproxy/plugins/duckdb_storage/storage.py
store_request
async
¶
Store a single request log entry asynchronously via queue.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Mapping[str, Any]
|
Request data to store |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if queued successfully |
Source code in ccproxy/plugins/duckdb_storage/storage.py
store_batch
async
¶
Store a batch of request logs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metrics
|
Sequence[dict[str, Any]]
|
List of metric data entries |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if stored successfully |
Source code in ccproxy/plugins/duckdb_storage/storage.py
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 | |
store
async
¶
close
async
¶
Close the database connection and stop background worker.
Source code in ccproxy/plugins/duckdb_storage/storage.py
is_enabled
¶
health_check
async
¶
Get health status of the storage backend.
Source code in ccproxy/plugins/duckdb_storage/storage.py
reset_data
async
¶
Reset all data in the storage (useful for testing/debugging).
Returns:
| Type | Description |
|---|---|
bool
|
True if reset was successful |
Source code in ccproxy/plugins/duckdb_storage/storage.py
wait_for_queue_processing
async
¶
Wait for all queued items to be processed by the background worker.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
float
|
Maximum time to wait in seconds |
5.0
|
Raises:
| Type | Description |
|---|---|
TimeoutError
|
If processing doesn't complete within timeout |