emissary/internal/agent/options.go

44 lines
869 B
Go
Raw Normal View History

package agent
import (
"time"
"forge.cadoles.com/Cadoles/emissary/internal/agent/metadata"
2023-06-25 19:45:43 +02:00
"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
}
}