refactoring
This commit is contained in:
36
webui/options.go
Normal file
36
webui/options.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package webui
|
||||
|
||||
import "github.com/mudler/local-agent-framework/core/state"
|
||||
|
||||
type Config struct {
|
||||
DefaultChunkSize int
|
||||
Pool *state.AgentPool
|
||||
}
|
||||
|
||||
type Option func(*Config)
|
||||
|
||||
func WithDefaultChunkSize(size int) Option {
|
||||
return func(c *Config) {
|
||||
c.DefaultChunkSize = size
|
||||
}
|
||||
}
|
||||
|
||||
func WithPool(pool *state.AgentPool) Option {
|
||||
return func(c *Config) {
|
||||
c.Pool = pool
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Config) Apply(opts ...Option) {
|
||||
for _, opt := range opts {
|
||||
opt(c)
|
||||
}
|
||||
}
|
||||
|
||||
func NewConfig(opts ...Option) *Config {
|
||||
c := &Config{
|
||||
DefaultChunkSize: 2048,
|
||||
}
|
||||
c.Apply(opts...)
|
||||
return c
|
||||
}
|
||||
Reference in New Issue
Block a user