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

chore: split DAL into two packages, with moduleconfig queries moved to common/configuration #1840

Merged
merged 4 commits into from
Jun 20, 2024

Conversation

deniseli
Copy link
Contributor

@deniseli deniseli commented Jun 20, 2024

Fixes #1696

Approach:

  • Duplicate - engine block of sqlc.yaml to support multiple out locations
  • Refactor common error handling vars + funcs into separate dalerrs package. This now lives under the new top level db dir, where we can add additional common DB logic as we split the controller dal further. This change incurred a lot of NOOP lines changed. :/
  • Meat of the change: split moduleconfig CRUD queries out of backend/controller/sql and into common/configuration/sql. Correspondingly, split the moduleconfig DAL functions out of backend/controller/dal and into common/configuration/dal.
  • Questionable choice: Copied backend/controller/sql/conn.go to common/configuration/sql/conn.go with the unnecessary logic stripped out (Tx...). That means that what remains (sql.DBI and sql.NewDB), though a small amount of code, is duplicated with the original conn.go. I could refactor this to use a shared interface instead, but that could also make this messier for readability and take things in a worse direction overall, so pending better ideas, we can rethink this when splitting the controller DAL.

deniseli added 2 commits June 20, 2024 16:24
refactor out dalerrs

copy sql utils

after running sqlc

next step: split out two fully separate directories for sqlc to work with

dup yaml config section

fix test paths

cleanup
@github-actions github-actions bot changed the title Dli/two dals feat: Dli/two dals Jun 20, 2024
@ftl-robot ftl-robot mentioned this pull request Jun 20, 2024
@deniseli deniseli marked this pull request as ready for review June 20, 2024 20:36
@deniseli deniseli requested a review from alecthomas as a code owner June 20, 2024 20:36
@deniseli deniseli requested review from a team and matt2e and removed request for a team June 20, 2024 20:36
@deniseli deniseli changed the title feat: Dli/two dals chore: split DAL into two packages, with moduleconfig queries moved to common/configuration Jun 20, 2024
Copy link
Collaborator

@alecthomas alecthomas left a comment

Choose a reason for hiding this comment

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

This is awesome! I'm keen to start splitting it up further, it'll make the code a lot cleaner.

Justfile Outdated Show resolved Hide resolved
sqlc.yaml Outdated Show resolved Hide resolved
@deniseli deniseli merged commit 027b28d into main Jun 20, 2024
41 checks passed
@deniseli deniseli deleted the dli/two-dals branch June 20, 2024 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor out a separate DAL for ConfigManager
2 participants