Solidarity transport
This commit is contained in:
@@ -74,3 +74,32 @@ func (s *ServicesHandler) GetAccounts() (accounts []storage.Account, err error)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (s *ServicesHandler) GetAccountsInNamespace(namespace string) (accounts []storage.Account, err error) {
|
||||
accounts = []storage.Account{}
|
||||
request := &mobilityaccounts.GetAccountsRequest{
|
||||
Namespaces: []string{namespace},
|
||||
}
|
||||
resp, err := s.GRPC.MobilityAccounts.GetAccounts(context.TODO(), request)
|
||||
|
||||
if err == nil {
|
||||
for _, v := range resp.Accounts {
|
||||
a := v.ToStorageType()
|
||||
accounts = append(accounts, a)
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (s *ServicesHandler) GetAccount(id string) (account storage.Account, err error) {
|
||||
request := &mobilityaccounts.GetAccountRequest{
|
||||
Id: id,
|
||||
}
|
||||
resp, err := s.GRPC.MobilityAccounts.GetAccount(context.TODO(), request)
|
||||
if err != nil {
|
||||
return storage.Account{}, err
|
||||
}
|
||||
|
||||
return resp.Account.ToStorageType(), nil
|
||||
}
|
||||
|
||||
@@ -2,10 +2,11 @@ package services
|
||||
|
||||
import (
|
||||
agenda "git.coopgo.io/coopgo-platform/agenda/grpcapi"
|
||||
diags "git.coopgo.io/coopgo-platform/diags/grpcapi"
|
||||
fleets "git.coopgo.io/coopgo-platform/fleets/grpcapi"
|
||||
groupsmanagement "git.coopgo.io/coopgo-platform/groups-management/grpcapi"
|
||||
mobilityaccounts "git.coopgo.io/coopgo-platform/mobility-accounts/grpcapi"
|
||||
diags "git.coopgo.io/coopgo-platform/diags/grpcapi"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
@@ -18,7 +19,7 @@ type GRPCServices struct {
|
||||
GroupsManagement groupsmanagement.GroupsManagementClient
|
||||
Fleets fleets.FleetsClient
|
||||
Agenda agenda.AgendaClient
|
||||
Diags diags.DiagsClient
|
||||
Diags diags.DiagsClient
|
||||
}
|
||||
|
||||
func NewServicesHandler(cfg *viper.Viper) (*ServicesHandler, error) {
|
||||
@@ -27,32 +28,37 @@ func NewServicesHandler(cfg *viper.Viper) (*ServicesHandler, error) {
|
||||
groupsManagementDial = cfg.GetString("services.grpc.groupsmanagement.dial")
|
||||
fleetsDial = cfg.GetString("services.grpc.fleets.dial")
|
||||
agendaDial = cfg.GetString("services.grpc.agenda.dial")
|
||||
diagsDial = cfg.GetString("services.grpc.diags.dial")
|
||||
// diagsDial = cfg.GetString("services.grpc.diags.dial")
|
||||
)
|
||||
mobilityAccounts, err := NewMobilityAccountService(mobilityAccountsDial)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Mobility Accounts service issue")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
groupsManagement, err := NewGroupsManagementService(groupsManagementDial)
|
||||
log.Error().Err(err).Msg("Groups mgmt service issue")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
fleetsSvc, err := NewFleetsService(fleetsDial)
|
||||
log.Error().Err(err).Msg("Fleets service issue")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
agendaSvc, err := NewAgendaService(agendaDial)
|
||||
log.Error().Err(err).Msg("Agenda service issue")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
diagsSvc, err := NewDiagsService(diagsDial)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
//diagsSvc, err := NewDiagsService(diagsDial)
|
||||
// log.Error().Err(err).Msg("Mobility Accounts service issue")
|
||||
//if err != nil {
|
||||
// return nil, err
|
||||
//}
|
||||
|
||||
return &ServicesHandler{
|
||||
GRPC: GRPCServices{
|
||||
@@ -60,7 +66,7 @@ func NewServicesHandler(cfg *viper.Viper) (*ServicesHandler, error) {
|
||||
GroupsManagement: groupsManagement,
|
||||
Fleets: fleetsSvc,
|
||||
Agenda: agendaSvc,
|
||||
Diags: diagsSvc,
|
||||
// Diags: diagsSvc,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user