40 lines
1010 B
Go
40 lines
1010 B
Go
|
package services
|
||
|
|
||
|
import (
|
||
|
groupsmanagement "git.coopgo.io/coopgo-platform/groups-management/grpcapi"
|
||
|
mobilityaccounts "git.coopgo.io/coopgo-platform/mobility-accounts/grpcapi"
|
||
|
"github.com/spf13/viper"
|
||
|
)
|
||
|
|
||
|
type ServicesHandler struct {
|
||
|
GRPC GRPCServices
|
||
|
}
|
||
|
|
||
|
type GRPCServices struct {
|
||
|
MobilityAccounts mobilityaccounts.MobilityAccountsClient
|
||
|
GroupsManagement groupsmanagement.GroupsManagementClient
|
||
|
}
|
||
|
|
||
|
func NewServicesHandler(cfg *viper.Viper) (*ServicesHandler, error) {
|
||
|
var (
|
||
|
mobilityAccountsDial = cfg.GetString("services.grpc.mobilityaccounts.dial")
|
||
|
groupsManagementDial = cfg.GetString("services.grpc.groupsmanagement.dial")
|
||
|
)
|
||
|
mobilityAccounts, err := NewMobilityAccountService(mobilityAccountsDial)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
groupsManagement, err := NewGroupsManagementService(groupsManagementDial)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
return &ServicesHandler{
|
||
|
GRPC: GRPCServices{
|
||
|
MobilityAccounts: mobilityAccounts,
|
||
|
GroupsManagement: groupsManagement,
|
||
|
},
|
||
|
}, nil
|
||
|
}
|