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

[service] Define strategy for 'privileged' components #10181

Closed
mx-psi opened this issue May 20, 2024 · 4 comments · Fixed by #10720
Closed

[service] Define strategy for 'privileged' components #10181

mx-psi opened this issue May 20, 2024 · 4 comments · Fixed by #10720

Comments

@mx-psi
Copy link
Member

mx-psi commented May 20, 2024

For some components we cast the component.Host passed by the service to an interface that implements

We have also used this strategy the other way around in the ballast extension:

for _, ext := range host.GetExtensions() {
if bExt, ok := ext.(interface{ GetBallastSize() uint64 }); ok {
return bExt.GetBallastSize()
}
}

In the context of service 1.0, I want to answer the following questions:

  1. Is this an acceptable strategy? Is it our preferred way of doing things in some cases?
  2. If the answer to (1) is yes, what stability guarantees do we provide for this? (I'd argue the standard stability guarantee for this is 'none', but maybe we should make this crystal clear in VERSIONING.md)
  3. If the answer to (1) is yes, then should we address [component] Review component.Host.GetFactory #9511?
@yurishkuro
Copy link
Member

@mx-psi Are all those even valid use cases to have something in the Host?

E.g. the ballast extension example does not depend on Host implementing anything, it just looks for a specific extension + interface, which is a pattern that I think is more useful (e.g. Jaeger components often interact this way by requiring a specific extension to exist and then using that extension's specific APIs).

The zpages example looks like a hack that was not well-designed. It seems that it's adding an endpoint handler to some central server (admin server?). If so, it seems it could also be solved with an extension dependency, e.g. we could have an admin server extension that other components could add endpoints too (e.g. healthcheck extension could add HC endpoint).

@mx-psi
Copy link
Member Author

mx-psi commented May 20, 2024

It seems that it's adding an endpoint handler to some central server (admin server?). If so, it seems it could also be solved with an extension dependency, e.g. we could have an admin server extension that other components could add endpoints too (e.g. healthcheck extension could add HC endpoint).

The way we would do this right now is to add the method to component.Host.

I guess the question here is: is it required for the service to implement this zpages support? Or do we consider it optional?

@TylerHelmuth
Copy link
Member

guess the question here is: is it required for the service to implement this zpages support? Or do we consider it optional?

Optional. I don't think every component.Host implementation needs to be compatible with zpagesextension. Conversely, I do think it is ok for a component.Host to chose to be compatible with zpagesextenstion.

If I understand zpages correctly, the zpagesextension handles creating the server, but it depends on the component.Host to provide the data being served up. This is because the component.Host is the thing managing all the pipelines, and it knows all the data zpagesextension wants to serve up. If feels ok to me for a component.Host implementation to simply not supply the information. This could because they have a different way of providing the same data and don't want to make it exposable via an extension.

Whatever the reason, it feels reasonable for zpagesextension to check if the component.Host implements the interfaces it requires. This pattern feels reasonable for any component that needs something extra from the component.Host that isn't generally used by all components.

We have also used this strategy the other way around in the ballast extension:

I don't care for the pattern in this direction. When the component.Host implementation (in our case service), uses the pattern I feel like we're leaking component dependency into our component.Host implementation. In my opinion it is ok for a component to ask the component.Host for something but it is not ok for the component.Host to ask a component for something.

Luckily the ballast extension is deprecated, so that use case will be removed soon.

@mx-psi
Copy link
Member Author

mx-psi commented Jul 22, 2024

Whatever the reason, it feels reasonable for zpagesextension to check if the component.Host implements the interfaces it requires. This pattern feels reasonable for any component that needs something extra from the component.Host that isn't generally used by all components.

This seems acceptable to me. We can require said components to specify the interface they need as part of their public API

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants