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

refactor: decouple conflicting ModuleContext requirements #2376

Merged
merged 1 commit into from
Aug 15, 2024

Conversation

alecthomas
Copy link
Collaborator

The ModuleContext was designed to be an abstract data model in the Controller for the resources required by a module, but along the way it started to be used for storing DB connections for use by the go-runtime. This change cleanly separates those requirements so that the go-runtime is entirely responsible for creating new connections from the DSN provided by the ModuleContext.

I think there's a bit more work to be done here, in that the ModuleContext knows about testing in the go-runtime, which it really shouldn't, but this will unblock #2373 for now.

@alecthomas alecthomas requested review from deniseli, a team and matt2e August 15, 2024 03:11
@ftl-robot ftl-robot mentioned this pull request Aug 15, 2024
@alecthomas alecthomas added the run-all A PR with this label will run the full set of CI jobs in the PR rather than in the merge queue label Aug 15, 2024
The ModuleContext was designed to be an abstract data model in the
Controller for the resources required by a module, but along the way it
started to be used for storing DB connections for use by the go-runtime.
This change cleanly separates those requirements so that the go-runtime
is entirely responsible for creating new connections from the DSN
provided by the ModuleContext.
@alecthomas alecthomas force-pushed the aat/separate-modulecontext-concerns branch from 17900c6 to 3dff7a2 Compare August 15, 2024 03:19
@alecthomas alecthomas added this pull request to the merge queue Aug 15, 2024
Merged via the queue into main with commit e339fb6 Aug 15, 2024
69 checks passed
@alecthomas alecthomas deleted the aat/separate-modulecontext-concerns branch August 15, 2024 03:38
@matt2e matt2e added the approved Marks an already closed PR as approved label Aug 15, 2024
github-merge-queue bot pushed a commit that referenced this pull request Aug 20, 2024
Fixes #2285

Unreverts #2305 with these
changes:

* Reverts
[`copyAny`](https://github.com/TBD54566975/ftl/blob/main/internal/reflect/reflect.go#L149)
changes except for the `list.List` handling.
* The original PR caused a panic when deploying to prod: `reflect:
internal error: must be a Pointer or Ptr; got unsafe.Pointer`
* #2376 removed the DB handles
from the module context Database struct, so we no longer need to handle
all these types in `DeepCopy`.
* Updates all `reflect.Ptr` refs to `reflect.Pointer`. Not a big deal,
but `Ptr` is the [old
name](https://cs.opensource.google/go/go/+/refs/tags/go1.23.0:src/reflect/type.go;l=303),
and since we're using `reflect.Pointer` elsewhere in this file, it's
better to stay consistent. Accordingly, this also fixes the error
message that we saw in the prod deployment, which previously implied
`Pointer` and `Ptr` were two _separate_ types.

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Marks an already closed PR as approved run-all A PR with this label will run the full set of CI jobs in the PR rather than in the merge queue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants