Initial commit
This commit is contained in:
25
application/config.go
Normal file
25
application/config.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package application
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/sethvargo/go-envconfig"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
PacketInputInterval time.Duration `env:"PACKET_INPUT_INTERVAL,default=500ms"`
|
||||
WorkersCount uint `env:"WORKERS_COUNT,default=10"`
|
||||
OutputInterval time.Duration `env:"OUTPUT_INTERVAL,default=1s"`
|
||||
}
|
||||
|
||||
func NewConfig(ctx context.Context) (Config, error) {
|
||||
var cfg Config
|
||||
|
||||
if err := envconfig.Process(ctx, &cfg); err != nil {
|
||||
return Config{}, fmt.Errorf("failed to process env vars: %w", err)
|
||||
}
|
||||
|
||||
return cfg, nil
|
||||
}
|
||||
Reference in New Issue
Block a user