2023-07-04 11:48:16 +01:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
|
|
|
"git.ctrlz.es/mgdelacroix/birthdaybot/model"
|
2023-07-10 12:39:25 +01:00
|
|
|
"git.ctrlz.es/mgdelacroix/birthdaybot/notification"
|
2023-07-04 11:48:16 +01:00
|
|
|
"github.com/charmbracelet/log"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Option func(*Server) *Server
|
|
|
|
|
|
|
|
func WithConfig(config *model.Config) Option {
|
|
|
|
return func(server *Server) *Server {
|
2023-07-10 20:08:05 +01:00
|
|
|
server.Config = config
|
2023-07-04 11:48:16 +01:00
|
|
|
return server
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func WithLogger(logger *log.Logger) Option {
|
|
|
|
return func(server *Server) *Server {
|
|
|
|
server.Logger = logger
|
|
|
|
return server
|
|
|
|
}
|
|
|
|
}
|
2023-07-10 12:39:25 +01:00
|
|
|
|
|
|
|
func WithBirthdays(birthdays []*model.Birthday) Option {
|
|
|
|
return func(server *Server) *Server {
|
|
|
|
server.birthdays = birthdays
|
|
|
|
return server
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func WithNotificationServices(notificationServices []notification.NotificationService) Option {
|
|
|
|
return func(server *Server) *Server {
|
|
|
|
server.notificationServices = notificationServices
|
|
|
|
return server
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func WithWorkers(workers []Worker) Option {
|
|
|
|
return func(server *Server) *Server {
|
|
|
|
server.workers = workers
|
|
|
|
return server
|
|
|
|
}
|
|
|
|
}
|