gocron-server/cmd/config.go
2022-02-04 20:23:04 +01:00

27 lines
550 B
Go

package main
import (
gocron_server "github.com/strnophix/gocron-server/pkg"
)
type ServerConfig struct {
Host string `toml:"host"`
}
type UnitConfig struct {
Name string `toml:"name"`
Command string `toml:"command"`
Cron string `toml:"cron"`
}
func (u *UnitConfig) ToSchedulerUnit() *gocron_server.SchedulerUnit {
cmd := gocron_server.NewUnitExecCmd(u.Command)
unit := gocron_server.NewSchedulerUnit(u.Name, u.Cron, cmd)
return unit
}
type Config struct {
Server ServerConfig `toml:"server"`
Unit []UnitConfig `toml:"unit"`
}