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

Allow the Host interface to return services. #6348

Merged
merged 5 commits into from
Feb 13, 2024

Conversation

tpaschalis
Copy link
Member

PR Description

This PR enables the Host interface to access other running services. Currently, this simplifies the handling around the UI service and the cluster.Cluster interface it calls to, but in the future this can also help the remotecfg service populate some UI interface.

Which issue(s) this PR fixes

No issue filed.

Notes to the Reviewer

cc @rfratto from a TODO comment as he's already thought about this in the past.

PR Checklist

  • CHANGELOG.md updated (N/A)
  • Documentation added (N/A)
  • Tests updated (N/A)

The new method on the Host interface allows services to call out to
other services during runtime.

Signed-off-by: Paschalis Tsilias <[email protected]>
This commit introduces a service.Provider interface as a counterpart to
component.Provider.

Signed-off-by: Paschalis Tsilias <[email protected]>
Using the previous commits as groundwork, we can now directly call to
the clustering service from the web/api package.

Signed-off-by: Paschalis Tsilias <[email protected]>
Signed-off-by: Paschalis Tsilias <[email protected]>
Copy link
Member

@rfratto rfratto left a comment

Choose a reason for hiding this comment

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

Thanks!

@@ -26,6 +26,15 @@ func (f *Flow) GetServiceConsumers(serviceName string) []service.Consumer {
return consumers
}

func (f *Flow) GetService(name string) (service.Service, bool) {
Copy link
Member

Choose a reason for hiding this comment

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

Godoc?

Comment on lines 40 to 44
// A Provider exposes information around services.
type Provider interface {
// GetService looks up a running service using its name.
GetService(name string) (Service, bool)
}
Copy link
Member

Choose a reason for hiding this comment

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

I'm guessing we need this and can't just use service.Host?

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought that maybe there was a reason we'd hooked it up as component.Provider in web/api, but yeah, we can use service.Host directly here.

This commit removes the service.Provider interface since web/api can use
service.Host itself as an implementation for retrieving components and
services.

Signed-off-by: Paschalis Tsilias <[email protected]>
@tpaschalis tpaschalis merged commit 1f3943d into grafana:main Feb 13, 2024
10 checks passed
BarunKGP pushed a commit to BarunKGP/grafana-agent that referenced this pull request Feb 20, 2024
@github-actions github-actions bot added the frozen-due-to-age Locked due to a period of inactivity. Please open new issues or PRs if more discussion is needed. label Mar 15, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
frozen-due-to-age Locked due to a period of inactivity. Please open new issues or PRs if more discussion is needed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants