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

[WIP] feat(informer): add interface and RPC to see the list of registered plugins #650

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@ require (
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a
golang.org/x/sys v0.0.0-20210309074719-68d13333faf2
)

replace (
github.com/spiral/endure v1.0.1 => ../endure
)
6 changes: 6 additions & 0 deletions plugins/informer/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@ import (
type Informer interface {
Workers() []process.State
}

// Lister interface used to filter available plugins
type Lister interface {
// List gets no args, but returns list of the active plugins
List() []string
}
20 changes: 13 additions & 7 deletions plugins/informer/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const PluginName = "informer"

type Plugin struct {
registry map[string]Informer
plugins map[string]Lister
log logger.Logger
}

Expand All @@ -31,19 +32,24 @@ func (p *Plugin) Workers(name string) ([]process.State, error) {
return svc.Workers(), nil
}

// CollectTarget resettable service.
func (p *Plugin) CollectTarget(name endure.Named, r Informer) error {
p.registry[name.Name()] = r
return nil
}

// Collects declares services to be collected.
func (p *Plugin) Collects() []interface{} {
return []interface{}{
p.CollectTarget,
p.CollectWorkers,
}
}

// CollectPlugins collects all RR plugins
func (p *Plugin) CollectPlugins(name endure.Named, l Lister) {
p.plugins[name.Name()] = l
}

// CollectWorkers obtains plugins with workers inside.
func (p *Plugin) CollectWorkers(name endure.Named, r Informer) error {
p.registry[name.Name()] = r
return nil
}

// Name of the service.
func (p *Plugin) Name() string {
return PluginName
Expand Down