package api import ( "github.com/luscis/openlan/pkg/config" "github.com/luscis/openlan/pkg/libol" "github.com/luscis/openlan/pkg/network" "github.com/luscis/openlan/pkg/schema" ) type Switcher interface { UUID() string UpTime() int64 Alias() string Config() *config.Switch Server() libol.SocketServer Firewall() *network.FireWall Reload() Save() } func NewWorkerSchema(s Switcher) schema.Worker { protocol := "" if cfg := s.Config(); cfg != nil { protocol = cfg.Protocol } return schema.Worker{ UUID: s.UUID(), Uptime: s.UpTime(), Alias: s.Alias(), Protocol: protocol, } }