1
0
Fork 0
mirror of https://git.sr.ht/~ashkeel/strimertul synced 2024-09-20 02:00:49 +00:00
strimertul/modules/manager.go

55 lines
865 B
Go
Raw Normal View History

package modules
2022-01-27 15:49:18 +00:00
import (
"go.uber.org/zap"
)
2021-12-09 09:46:14 +00:00
type ModuleStatus struct {
Enabled bool
Working bool
Data interface{}
StatusString string
}
func (m ModuleStatus) String() string {
return m.StatusString
}
type Module interface {
2021-12-09 09:46:14 +00:00
Status() ModuleStatus
Close() error
}
type ModuleID string
const (
2022-06-16 22:51:27 +00:00
// Required
ModuleDB ModuleID = "db"
ModuleHTTP ModuleID = "http"
// Feature modules
ModuleLoyalty ModuleID = "loyalty"
ModuleStulbe ModuleID = "stulbe"
2022-06-16 22:51:27 +00:00
// Streaming providers
ModuleTwitch ModuleID = "twitch"
)
type Manager struct {
Modules map[ModuleID]Module
2022-01-27 15:49:18 +00:00
logger *zap.Logger
}
2022-01-27 15:49:18 +00:00
func NewManager(log *zap.Logger) *Manager {
return &Manager{
Modules: make(map[ModuleID]Module),
logger: log,
}
}
2022-01-27 15:49:18 +00:00
func (m *Manager) Logger(module ModuleID) *zap.Logger {
return m.logger.With(zap.String("module", string(module)))
}