Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BED-5467 Allow DB injection into DAWGS #1314

Merged
merged 10 commits into from
Apr 8, 2025
Merged

Conversation

superlinkx
Copy link
Contributor

@superlinkx superlinkx commented Apr 3, 2025

Description

Changes DAWGS to allow dependency injection of a pgxpool to the pg driver, rather than having the driver set up the connection itself. This allows us to use pgtestdb in our upcoming integration tests, and allows for better separation of concerns.

The way this was done required removing the circular relationship between Driver and SchemaManager, and the simplest fix was to make Driver embed a SchemaManager. A new SchemaManager is initialized when a new Driver is created, and passed the same pool as the Driver. WriteTransaction and ReadTransaction were lowered into the SchemaManager struct since they are common methods used by both Driver and SchemaManager. Using an embed, we write those methods once while still allowing Driver to satisfy the graph.Database interface.

This is not the prettiest, but it does open up further improvements down the road and causes the least disruption while also making bootstrapping the driver straightfoward. The dependency between Driver and SchemaManager is a bit more clear as a result as well.

Motivation and Context

This PR addresses: BED-5467

How Has This Been Tested?

Ran with local dev to ensure schema was brought up properly and that ingest/analysis continued to function as expected.

Types of changes

  • Chore (a change that does not modify the application functionality)

Checklist:

This embeds schemamanager into the driver, so that the transaction methods can live on schemamanager but be accessed from the driver layer.

This did necessitate moving batchWriteSize to a package level var instead of living on the driver.

This ended up being the simplest change to allow injecting a pgxpool into dawgs, and additional work should be done to better unwind the driver and schemamanager responsibilities
@superlinkx superlinkx self-assigned this Apr 4, 2025
@superlinkx superlinkx added the api A pull request containing changes affecting the API code. label Apr 4, 2025
@superlinkx superlinkx marked this pull request as ready for review April 4, 2025 18:50
Copy link
Contributor

@zinic zinic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing here sticks out to me; good to pull.

@superlinkx superlinkx merged commit 3b067d4 into main Apr 8, 2025
8 checks passed
@superlinkx superlinkx deleted the BED-5467/dawgs-db-injection branch April 8, 2025 19:46
@github-actions github-actions bot locked and limited conversation to collaborators Apr 8, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api A pull request containing changes affecting the API code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants