Skip to content

Commit

Permalink
Remove service.Provider interface
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
tpaschalis committed Feb 13, 2024
1 parent bee6f14 commit 204ac43
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 13 deletions.
2 changes: 2 additions & 0 deletions pkg/flow/flow_services.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ func (f *Flow) GetServiceConsumers(serviceName string) []service.Consumer {
return consumers
}

// GetService implements [service.Host]. It looks up a [service.Service] by
// name.
func (f *Flow) GetService(name string) (service.Service, bool) {
for _, svc := range f.opts.Services {
if svc.Definition().Name == name {
Expand Down
6 changes: 0 additions & 6 deletions service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ type Definition struct {
DependsOn []string
}

// A Provider exposes information around services.
type Provider interface {
// GetService looks up a running service using its name.
GetService(name string) (Service, bool)
}

// Host is a controller for services and Flow components.
type Host interface {
// GetComponent gets a running component by ID.
Expand Down
9 changes: 2 additions & 7 deletions web/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,11 @@ import (

// FlowAPI is a wrapper around the component API.
type FlowAPI struct {
flow Provider
}

type Provider interface {
component.Provider
service.Provider
flow service.Host
}

// NewFlowAPI instantiates a new Flow API.
func NewFlowAPI(flow Provider) *FlowAPI {
func NewFlowAPI(flow service.Host) *FlowAPI {
return &FlowAPI{flow: flow}
}

Expand Down

0 comments on commit 204ac43

Please sign in to comment.