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 the API of the Store type #118

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Simplify the API of the Store type #118

wants to merge 3 commits into from

Conversation

creachadair
Copy link
Member

@creachadair creachadair commented Aug 22, 2024

A proposal to simplify the API of the Store type a bit, to make it harder to
misuse. This is the first of two changes we discussed separately.

As a first step, this change unexports the Watcher type, which is mainly useful
as a plumbing tool inside the package. There are multiple commits here that can
be reviewed (mostly) separately.

We also talked about maybe removing (or unexporting) the Secret type too. That
isn't included here, but can be done as a follow-up. We have a bunch of
existing use of that API that will require some adjusting, whereas Watcher was
entirely unused outside the package.

Copy link
Member

@danderson danderson left a comment

Choose a reason for hiding this comment

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

Does each intermediate commit build, with this order of unexporting before changing NewUpdater's signature? Obviously NewUpdater becomes unusable in one of the intermediate commits until a later one, but as long as each commit builds that seems okay.

(I'm trying to work out whether you can rebase-and-merge or whether you should squash-and-merge, to try and keep all commits in the history buildable where possible)

Either way, LGTM!

@creachadair
Copy link
Member Author

I was planning to squash it anyway, though mainly at this point it was an essay in the idea.

I realized later that I have some usage of the Watcher in tailsql that would need to be updated too, so I may revisit this and ask for a second opinion before I attempt to merge it.

Move the unexported utility type into the shared test package.
Update the tests to use the test package version instead.
The watcher semantics are still useful for plumbing, but it's hard to use
correctly, so unexport it.  Now that watcher is unexported, move its tests from
a separate package into an internal package test.

It is now no longer necessary to have the "watcher" method, so remove it.
Instead of taking a watcher (which is now unexported), take the *Store and the
secret name directly. Report an error, and add an error field so that updates
can detect and recover from them.

Add a StaticUpdater constructor to make an Updater that vends a static value,
analogous to StaticSecret.
@creachadair
Copy link
Member Author

Switching back to a draft to think on't some more.

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