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: cache with context #1013

Merged
merged 2 commits into from
Dec 7, 2024

Conversation

iwpnd
Copy link
Member

@iwpnd iwpnd commented Nov 25, 2024

to merge after #1012

@iwpnd iwpnd requested review from gdey and ARolek as code owners November 25, 2024 11:58
Copy link
Member

@gdey gdey left a 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?

@iwpnd
Copy link
Member Author

iwpnd commented Nov 26, 2024

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

@iwpnd iwpnd force-pushed the refactor/cache-with-context branch 2 times, most recently from 36d549b to 526348a Compare November 26, 2024 11:13
Copy link
Member

@ARolek ARolek left a 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()
Copy link
Member

@ARolek ARolek Nov 29, 2024

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()

Copy link
Member Author

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. 🤔

Copy link
Member

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:

type InitFunc func(dict.Dicter) (Interface, error)

This is called by the For method:

func For(cacheType string, config dict.Dicter) (Interface, error) {

Which is invoked by the internal cmd/internal/register/ package:

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 ;-)

Copy link
Member Author

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.

@ARolek
Copy link
Member

ARolek commented Dec 5, 2024

@iwpnd can you rebase against master and fix the conflicts please?

iwpnd added 2 commits December 6, 2024 09:14
chore: vendor update

chore: drop gcs context
@iwpnd iwpnd force-pushed the refactor/cache-with-context branch from fa0e1c7 to 63c4e3e Compare December 6, 2024 08:21
@coveralls
Copy link

coveralls commented Dec 6, 2024

Pull Request Test Coverage Report for Build b6a8fe572-PR-1013

Details

  • 18 of 68 (26.47%) changed or added relevant lines in 10 files are covered.
  • 8 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.06%) to 42.844%

Changes Missing Coverage Covered Lines Changed/Added Lines %
cmd/tegola/cmd/cache/worker.go 0 3 0.0%
atlas/atlas.go 0 6 0.0%
cache/file/file.go 7 13 53.85%
cache/s3/s3.go 3 9 33.33%
observability/prometheus/cache.go 0 6 0.0%
cache/gcs/gcs.go 0 11 0.0%
cache/azblob/azblob.go 0 12 0.0%
Files with Coverage Reduction New Missed Lines %
atlas/atlas.go 1 3.62%
cache/redis/redis.go 7 92.31%
Totals Coverage Status
Change from base Build 93b917e04: 0.06%
Covered Lines: 7026
Relevant Lines: 16399

💛 - Coveralls

@ARolek ARolek merged commit 8ca8399 into go-spatial:master Dec 7, 2024
12 checks passed
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.

4 participants