Skip to content

add ingester interface #3352

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

Merged
merged 2 commits into from
Oct 19, 2020
Merged

Conversation

replay
Copy link
Contributor

@replay replay commented Oct 14, 2020

I would like to extend the Ingester by wrapping it in another struct, which overrides some methods and does additional work before calling the original Ingester methods.

Currently the API method .RegisterIngester() expects the concrete type *ingester.Ingester, so I can't pass it the extended ingester type. Outside the api package I also can't easily re-implement the .RegisterIngester() method, because it uses an unexported property of the API (sourceIPs).
By changing the API method RegisterIngester() to expect an interface I'll be able to pass it the extended Ingester type and register its methods on the HTTP and the GRPC server.

What do you think about this approach?
An alternative to creating an Ingester interface would be to export that unexported property .sourceIPs which is used by API.RegisterIngester(), that way I could basically just re-implement what this method is doing outside the package, but that seems less elegant and might be more error-prone because if RegisterIngester() changes in the future I'll have to ensure that my copy stays up2date.

@replay replay force-pushed the ingester_interface branch 2 times, most recently from bf2a859 to 015efd4 Compare October 15, 2020 23:36
@pstibrany
Copy link
Contributor

I would suggest moving new Ingester interface into api package (where it is actually used) while keeping Ingester type in pkg/ingester unchanged (no rename).

@replay
Copy link
Contributor Author

replay commented Oct 16, 2020

I would suggest moving new Ingester interface into api package (where it is actually used) while keeping Ingester type in pkg/ingester unchanged (no rename).

Thx, that's a great idea, I'll do that

@replay replay force-pushed the ingester_interface branch from 015efd4 to 6435d71 Compare October 16, 2020 12:56
@pull-request-size pull-request-size bot added size/S and removed size/L labels Oct 16, 2020
Signed-off-by: Mauro Stettler <[email protected]>
@replay replay force-pushed the ingester_interface branch from 6435d71 to 18a66d8 Compare October 16, 2020 12:57
@replay replay changed the title [WIP] add ingester interface add ingester interface Oct 16, 2020
@replay replay marked this pull request as ready for review October 16, 2020 13:19
@@ -201,8 +200,15 @@ func (a *API) RegisterDistributor(d *distributor.Distributor, pushConfig distrib
a.RegisterRoute("/ha-tracker", d.HATracker, false, "GET")
}

type ingester interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't be exported?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For what I'm trying to do it's not necessary to export it. My goal is just to pass RegisterIngesters() an alternative struct which satisfies the same interface as the "original" ingester. Or is there another reason to export it?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think export is necessary, but a comment explaining why we do this would be nice. Otherwise it looks like magic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, good point, I'll add one

Copy link
Contributor

@pstibrany pstibrany left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -201,8 +200,15 @@ func (a *API) RegisterDistributor(d *distributor.Distributor, pushConfig distrib
a.RegisterRoute("/ha-tracker", d.HATracker, false, "GET")
}

type ingester interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think export is necessary, but a comment explaining why we do this would be nice. Otherwise it looks like magic.

Copy link
Contributor

@jtlisi jtlisi left a comment

Choose a reason for hiding this comment

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

LGTM

@pracucci pracucci merged commit 99c9d6a into cortexproject:master Oct 19, 2020
gotjosh added a commit to gotjosh/cortex that referenced this pull request Oct 20, 2020
…rgid-ctx

* 'master' of github.com:cortexproject/cortex:
  Enforce integration tests default flags config to never be overwritten (cortexproject#3370)
  Avoid deletion of blocks which are not shipped (cortexproject#3346)
  Upgrade Thanos to latest master (cortexproject#3363)
  Migrate CircleCI workflows to GitHub Actions (2/3) (cortexproject#3341)
  Remove comments that doesn't seem right (cortexproject#3361)
  add ingester interface (cortexproject#3352)
  Fail fast an ingester if unable to load existing TSDBs (cortexproject#3354)
  Fixed Gossip memberlist members joining when addresses are configured using DNS-based service discovery (cortexproject#3360)
  Export distributor method to get ingester replication set (cortexproject#3356)
  Correct link for Block Storage reference (cortexproject#3234)
  Added section on Cleaner. (cortexproject#3327)
  Update prometheus vendor to master (cortexproject#3345)
  adding GHA CI env variable check (cortexproject#3351)
  Add ingesters shuffle sharding support on the read path (cortexproject#3252)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants