34 lines
868 B
Go
34 lines
868 B
Go
package services
|
|
|
|
import (
|
|
"github.com/rs/zerolog/log"
|
|
"github.com/spf13/viper"
|
|
)
|
|
|
|
type ServicesHandler struct {
|
|
MobilityAccounts MobilityAccountService
|
|
Push *PushService
|
|
}
|
|
|
|
func NewServicesHandler(cfg *viper.Viper) (*ServicesHandler, error) {
|
|
var (
|
|
mobilityAccountsDial = cfg.GetString("services.internal.mobility_accounts.dial")
|
|
pushDial = cfg.GetString("services.internal.push.dial")
|
|
)
|
|
mobilityAccounts, err := NewMobilityAccountService(mobilityAccountsDial)
|
|
if err != nil {
|
|
log.Fatal().Err(err).Msg("Could not connect to Mobility Accounts Service")
|
|
return nil, err
|
|
}
|
|
push, err := NewPushService(pushDial)
|
|
if err != nil {
|
|
log.Fatal().Err(err).Msg("Could not connect to Push Notifications Service")
|
|
return nil, err
|
|
}
|
|
|
|
return &ServicesHandler{
|
|
MobilityAccounts: mobilityAccounts,
|
|
Push: push,
|
|
}, nil
|
|
}
|