44 lines
869 B
Go
44 lines
869 B
Go
package agent
|
|
|
|
import (
|
|
"time"
|
|
|
|
"forge.cadoles.com/Cadoles/emissary/internal/agent/metadata"
|
|
"forge.cadoles.com/Cadoles/emissary/pkg/client"
|
|
)
|
|
|
|
type Options struct {
|
|
Client *client.Client
|
|
Interval time.Duration
|
|
Controllers []Controller
|
|
Collectors []metadata.Collector
|
|
}
|
|
|
|
type OptionFunc func(*Options)
|
|
|
|
func defaultOption() *Options {
|
|
return &Options{
|
|
Controllers: make([]Controller, 0),
|
|
Interval: 10 * time.Second,
|
|
Collectors: make([]metadata.Collector, 0),
|
|
}
|
|
}
|
|
|
|
func WithControllers(controllers ...Controller) OptionFunc {
|
|
return func(opt *Options) {
|
|
opt.Controllers = controllers
|
|
}
|
|
}
|
|
|
|
func WithInterval(interval time.Duration) OptionFunc {
|
|
return func(opt *Options) {
|
|
opt.Interval = interval
|
|
}
|
|
}
|
|
|
|
func WithCollectors(collectors ...metadata.Collector) OptionFunc {
|
|
return func(opts *Options) {
|
|
opts.Collectors = collectors
|
|
}
|
|
}
|