-
-
Notifications
You must be signed in to change notification settings - Fork 203
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: cache with context #1013
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just a small nit about import lines.
I need to look at the CI issues as well. Looks like it's an issue with valun, and maybe how vendoring is done?
that'll be fine after #1012 |
36d549b
to
526348a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for tackling this! Tegola is much better off with this change. I have a couple minor requests inline, but they're not show stoppers.
@@ -124,10 +124,12 @@ func New(config dict.Dicter) (cache.Interface, error) { | |||
Y: 0, | |||
} | |||
|
|||
ctx := context.Background() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider passing context to the New() call. The CLI framework we're using, cobra, has a context on cmd.Context()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm but caches are initialized in their respective init
not in the root cmd. I don’t see how adding the cmd context makes sense here. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just walked through the code and the cache init routine is a bit confusing. The part I'm referencing enhancing with the context is the InitFunc:
Line 136 in 93b917e
type InitFunc func(dict.Dicter) (Interface, error) |
This is called by the For
method:
Line 165 in 93b917e
func For(cacheType string, config dict.Dicter) (Interface, error) { |
Which is invoked by the internal cmd/internal/register/
package:
tegola/cmd/internal/register/caches.go
Line 16 in 93b917e
func Cache(config dict.Dicter) (cache.Interface, error) { |
The main value we would get with this plumbing is if tegola is started up and then killed before the cache initializes fully.
I'm not going to block the PR on this request, but just following up on the intent of my comment. Your call if you want to make this change ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gotcha! if thats fine with you i'd merge this as is, and tackle this in a separate commit.
526348a
to
fa0e1c7
Compare
@iwpnd can you rebase against master and fix the conflicts please? |
chore: vendor update chore: drop gcs context
fa0e1c7
to
63c4e3e
Compare
Pull Request Test Coverage Report for Build b6a8fe572-PR-1013Details
💛 - Coveralls |
to merge after #1012