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: refactor out separate dal and sql packages for cronjobs #1860

Merged
merged 17 commits into from
Jul 8, 2024

Conversation

deniseli
Copy link
Contributor

@deniseli deniseli commented Jun 21, 2024

Part 1 of #1567: This PR refactors cronjobs dal and sql packages out from the parent controller package. I'm breaking this refactor into many PRs to combat merge conflicts.

Ultimate plan for the refactor:

  • controller/domain/{dal,sql} packages hold all the query logic for each domain
  • When a domain D contains certain use cases (i.e. functions) that need to exec queries from a different domain E, D/dal will call E/dal. If those queries spanning multiple domains need to be merged into a single transaction, then D/dal will create a wrapper transaction that gets bundled with a qtx for each domain that gets queried. CreateDeployment is an example of this that should eventually be refactored out of controller/dal into controller/deployment/dal.
  • controller/dal will cease to exist.
  • controller/sql will not contain any queries. Instead, it will house top-level db artifacts (e.g. sql/schema)

In the meantime, while this refactor is in progress, controller/dal will contain methods that are yet to be pulled out.

This PR does not yet generalize the top-level Tx logic because controller/dal is still the only dal package that uses it.

@ftl-robot ftl-robot mentioned this pull request Jun 21, 2024
@deniseli deniseli marked this pull request as ready for review June 21, 2024 22:19
@deniseli deniseli requested a review from alecthomas as a code owner June 21, 2024 22:19
@deniseli deniseli requested review from a team and matt2e and removed request for a team June 21, 2024 22:19
backend/controller/controller.go Outdated Show resolved Hide resolved
backend/controller/cronjobs/dal/dal.go Outdated Show resolved Hide resolved
backend/controller/leases/dal/dal.go~ Outdated Show resolved Hide resolved
backend/controller/leases/dal/dal.go Outdated Show resolved Hide resolved
backend/controller/leases/dal/lease.go Outdated Show resolved Hide resolved
backend/controller/sql/conn.go Outdated Show resolved Hide resolved
backend/controller/sql/conn.go Outdated Show resolved Hide resolved
backend/controller/sql/conn.go Outdated Show resolved Hide resolved
@deniseli deniseli force-pushed the dli/split-dal-soup branch from 480bf77 to 46441f6 Compare June 28, 2024 19:47
cronjobs

rm leases conn.go

comments

clarification comment on duplicate field names

unmerge txn interface

lint

remove extraneous comment

better comment
@deniseli deniseli force-pushed the dli/split-dal-soup branch from 46441f6 to c7c0744 Compare July 1, 2024 19:53
@deniseli deniseli changed the title chore: refactor out separate dal and sql pacakges for leases and cronjobs chore: refactor out separate dal and sql pacakges for cronjobs Jul 2, 2024
backend/controller/controller.go Show resolved Hide resolved
backend/controller/controller.go Outdated Show resolved Hide resolved
backend/controller/sql/queries.sql Outdated Show resolved Hide resolved
backend/controller/sql/schema/001_init.sql Outdated Show resolved Hide resolved
@deniseli deniseli changed the title chore: refactor out separate dal and sql pacakges for cronjobs chore: refactor out separate dal and sql packages for cronjobs Jul 2, 2024
@deniseli deniseli merged commit 8fedcd7 into main Jul 8, 2024
47 checks passed
@deniseli deniseli deleted the dli/split-dal-soup branch July 8, 2024 19:41
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.

2 participants