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

Simplify default database resolution in sqlite #2840

Merged
merged 3 commits into from
Sep 18, 2024
Merged

Conversation

rylev
Copy link
Collaborator

@rylev rylev commented Sep 17, 2024

This greatly simplifies how labels are resolved to connection creators in factor-sqlite.

Instead of treating default labels as something special, the factor loses all knowledge of "default" labels. The label to connection creator mapping resides entirely inside of the factor's runtime config. The sqlite factor's runtime config was previously responsible for label to connection creator mapping for all database labels except for the default one. Now it handles the default one as well.

This removes the very notion of a "default" labeled database from the factor and instead moves that to a higher level concern (how the runtime configures each factors runtime config).

The tests for the sqlite factor have also be massively simplified as they no longer use the Spin CLI's notion of runtime config toml and instead just supply the runtime config directly. This makes it much easier to understand the what the test is actually testing.

If you're happy with this approach, I'd like to also do the same thing for key-value.

Instead of treating the SQLite Factor's runtime config as 1 on 1 the
same as the Spin CLI runtime config toml, we inject handling of the
"default" label into the factor's runtime config struct. This makes
handling of label resolution happen in just one place instead of
spliting it into two.

Signed-off-by: Ryan Levick <ryan.levick@fermyon.com>
Signed-off-by: Ryan Levick <ryan.levick@fermyon.com>
@rylev rylev requested a review from lann September 17, 2024 19:24
@itowlson
Copy link
Contributor

@rylev Just to confirm I'm reading the code right: this doesn't change the user experience, right? It's solely moving the implementation of that user experience to a different part of the code.

@rylev
Copy link
Collaborator Author

rylev commented Sep 17, 2024

@itowlson correct if by "user" you mean "user of the Spin CLI" - this is purely a library change so it will change the experience for those using Spin as a library building their own Spin compliant runtime.

@itowlson
Copy link
Contributor

@rylev Yes, sorry, I should have been clearer. Thanks for clarifying - sounds good!

Signed-off-by: Ryan Levick <ryan.levick@fermyon.com>
@rylev rylev merged commit 21c66f4 into main Sep 18, 2024
17 checks passed
@rylev rylev deleted the simplify-default-sqlite branch September 18, 2024 07:45
@rylev rylev mentioned this pull request Sep 18, 2024
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.

3 participants