Skip to content

refactor: Create database drivers from factories#874

Merged
gfieni merged 4 commits into
masterfrom
feat/database-driver-factory
Jul 9, 2026
Merged

refactor: Create database drivers from factories#874
gfieni merged 4 commits into
masterfrom
feat/database-driver-factory

Conversation

@gfieni

@gfieni gfieni commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

This PR refactors database driver initialization to rely on database factories instead of prebuilt driver instances.
Puller and pusher actors now receive database factories and create database drivers during initialization.

gfieni added 2 commits July 6, 2026 16:19
Introduce readable and writable database driver factory interfaces and
add factory implementations for the database backends.

Factories carry pickable database configuration and create concrete
driver instances on demand. This prepares the puller and pusher actors
to avoir storing driver instances before process startup.
Update puller and pusher generation to build database driver factories
instead of concrete database drivers.
@gfieni gfieni self-assigned this Jul 8, 2026
@gfieni gfieni requested a review from a team as a code owner July 8, 2026 16:14
@gfieni gfieni added enhancement New feature or request refactoring and removed enhancement New feature or request labels Jul 8, 2026
Comment thread src/powerapi/database/driver.py Dismissed
Comment thread src/powerapi/database/driver.py Dismissed
@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.96721% with 33 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.87%. Comparing base (8f549ff) to head (287447b).

Files with missing lines Patch % Lines
src/powerapi/puller/database_poller.py 30.00% 7 Missing ⚠️
src/powerapi/database/json/driver.py 71.42% 6 Missing ⚠️
src/powerapi/database/socket/driver.py 64.28% 5 Missing ⚠️
src/powerapi/database/csv/driver.py 76.47% 4 Missing ⚠️
src/powerapi/database/mongodb/driver.py 84.21% 3 Missing ⚠️
src/powerapi/database/influxdb2/driver.py 85.71% 2 Missing ⚠️
src/powerapi/database/opentsdb/driver.py 83.33% 2 Missing ⚠️
src/powerapi/database/prometheus/driver.py 83.33% 2 Missing ⚠️
src/powerapi/puller/puller_actor.py 85.71% 1 Missing ⚠️
src/powerapi/pusher/pusher_actor.py 85.71% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #874      +/-   ##
==========================================
- Coverage   76.05%   73.87%   -2.18%     
==========================================
  Files          90       82       -8     
  Lines        3003     3097      +94     
==========================================
+ Hits         2284     2288       +4     
- Misses        719      809      +90     
Files with missing lines Coverage Δ
src/powerapi/cli/generator.py 89.40% <100.00%> (ø)
src/powerapi/database/driver.py 100.00% <100.00%> (ø)
src/powerapi/pusher/handlers.py 100.00% <100.00%> (ø)
src/powerapi/puller/puller_actor.py 87.50% <85.71%> (ø)
src/powerapi/pusher/pusher_actor.py 82.60% <85.71%> (+0.79%) ⬆️
src/powerapi/database/influxdb2/driver.py 53.33% <85.71%> (-8.44%) ⬇️
src/powerapi/database/opentsdb/driver.py 50.00% <83.33%> (-9.38%) ⬇️
src/powerapi/database/prometheus/driver.py 46.80% <83.33%> (-15.36%) ⬇️
src/powerapi/database/mongodb/driver.py 46.91% <84.21%> (-7.06%) ⬇️
src/powerapi/database/csv/driver.py 48.57% <76.47%> (-6.99%) ⬇️
... and 3 more

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

gfieni added 2 commits July 8, 2026 18:52
Use a writable database factory in the pusher actor and create the
concrete driver during actor startup, so database resources are
initialized inside the actor process.
Use a readable database factory in the puller actor and create the
concrete driver from the database poller thread, so database resources
are initialized inside the actor process.
@gfieni gfieni force-pushed the feat/database-driver-factory branch from a28e682 to 287447b Compare July 8, 2026 16:52
@sonarqubecloud

sonarqubecloud Bot commented Jul 8, 2026

Copy link
Copy Markdown

@gfieni gfieni merged commit 3566d75 into master Jul 9, 2026
11 checks passed
@gfieni gfieni deleted the feat/database-driver-factory branch July 9, 2026 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants