connection grpc generique done

This commit is contained in:
Maxime 2024-08-02 15:02:35 +02:00
parent d8771c67d8
commit f4ce62543f
6 changed files with 58 additions and 44 deletions

4
go.mod
View File

@ -32,12 +32,12 @@ require (
)
require (
git.coopgo.io/coopgo-apps/silvermobi v0.0.0-20231208063504-f1d60881e5ab
git.coopgo.io/coopgo-platform/agenda v0.0.0-20230310121901-ef3add576f86
git.coopgo.io/coopgo-platform/emailing v0.0.0-20221017030337-c71888d90c15
git.coopgo.io/coopgo-platform/fleets v0.0.0-20230310144446-feb935f8bf4e
git.coopgo.io/coopgo-platform/groups-management v0.0.0-20230310123255-5ef94ee0746c
git.coopgo.io/coopgo-platform/mobility-accounts v0.0.0-20230430115320-f5bb2e7c2c26
git.coopgo.io/sbouaram/solidarity-service v0.0.0-00010101000000-000000000000
github.com/gorilla/securecookie v1.1.1
github.com/minio/minio-go/v7 v7.0.43
github.com/xuri/excelize/v2 v2.7.1
@ -76,7 +76,6 @@ require (
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/pelletier/go-toml/v2 v2.2.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pquerna/cachecontrol v0.1.0 // indirect
@ -115,7 +114,6 @@ require (
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/mail.v2 v2.3.1 // indirect
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 // indirect

4
go.sum
View File

@ -1,5 +1,7 @@
ariga.io/atlas v0.13.1 h1:oSkEYgI3qUnQZ6b6+teAEiIuizjBvkZ4YDbz0XWfCdQ=
ariga.io/atlas v0.13.1/go.mod h1:+TR129FJZ5Lvzms6dvCeGWh1yR6hMvmXBhug4hrNIGk=
git.coopgo.io/coopgo-apps/silvermobi v0.0.0-20231208063504-f1d60881e5ab h1:Voh7ZtRRnh/9/+b9bqXgwo/98r6HLGRRBGEri0pkP3E=
git.coopgo.io/coopgo-apps/silvermobi v0.0.0-20231208063504-f1d60881e5ab/go.mod h1:p4ueQ2fh8K6foJHxqRFArdO52FvWKR9TTLMDjVNQAgw=
git.coopgo.io/coopgo-platform/emailing v0.0.0-20221017030337-c71888d90c15 h1:+ZI4nGE6mqZ6pc7N/BizheEPRXn6Z84Sj7ikwfP2ZcU=
git.coopgo.io/coopgo-platform/emailing v0.0.0-20221017030337-c71888d90c15/go.mod h1:rmbqiHVkONcECOoPlsXlxZnD315Tiz2oRnn1M7646Kg=
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8=
@ -135,7 +137,6 @@ github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwd
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe h1:iruDEfMl2E6fbMZ9s0scYfZQ84/6SPL6zC8ACM2oIL0=
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
github.com/opencontainers/runc v0.1.1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
@ -351,7 +352,6 @@ gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/mail.v2 v2.3.1 h1:WYFn/oANrAGP2C0dcV6/pbkPzv8yGzqTjPmTeO7qoXk=

View File

@ -1,25 +1,44 @@
package application
import (
"context"
"fmt"
"net/http"
"time"
solidarity_service "git.coopgo.io/coopgo-apps/silvermobi/servers/grpcapi/proto"
"google.golang.org/protobuf/types/known/timestamppb"
)
func (h *ApplicationHandler) SolidarityServiceBookingList(w http.ResponseWriter, r *http.Request) {
func (h *ApplicationHandler) DriversJourney(w http.ResponseWriter, r *http.Request) {
if r.Method == "POST" {
departureTime := time.Now()
timestamp := timestamppb.New(departureTime)
request := &solidarity_service.DriverJourneysRequest{
DepartureDate: timestamp,
Departure: &solidarity_service.Feature{
Lat: 0,
Long: 0,
Address: "7 rue D",
},
}
_, err := h.services.GRPC.SolidarityService.DriverJourneys(context.TODO(), request)
if err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
}
h.Renderer.SolidarityServiceBookingList(w, r)
}
func (h *ApplicationHandler) SolidarityServiceBookingCreate(w http.ResponseWriter, r *http.Request) {
h.Renderer.SolidarityServiceBookingCreate(w, r )
}
func (h *ApplicationHandler) SilvermobiBookingUpdate(w http.ResponseWriter, r *http.Request) {
fmt.Println("SilverBookingU")
}
func (h *ApplicationHandler) SilvermobiBookingDelete(w http.ResponseWriter, r *http.Request) {
fmt.Println("SilverBookingD")
}

View File

@ -138,10 +138,7 @@ func main() {
/*********************** CODE GROUP **************************/
//=================================silvermobi====================================
application.HandleFunc("/solidarity_service/createBooking", applicationHandler.SolidarityServiceBookingCreate)
application.HandleFunc("/solidarity_service/", applicationHandler.SolidarityServiceBookingList)
application.HandleFunc("/silvermobi/update/{memberid}/{bookingid}", applicationHandler.SilvermobiBookingUpdate)
application.HandleFunc("/silvermobi/delete/{memberid}/{bookingid}", applicationHandler.SilvermobiBookingDelete)
application.HandleFunc("/solidarity_service/", applicationHandler.DriversJourney)
appGroup := application.PathPrefix("/group_module").Subrouter()
appGroup.HandleFunc("/", applicationHandler.Groups)

View File

@ -5,7 +5,7 @@ import (
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"
//solidarityservice "git.coopgo.io/sbouaram/solidarity-service/grpcapi"
solidarityservice "git.coopgo.io/coopgo-apps/silvermobi/servers/grpcapi/proto"
"github.com/spf13/viper"
)
@ -18,7 +18,7 @@ type GRPCServices struct {
GroupsManagement groupsmanagement.GroupsManagementClient
Fleets fleets.FleetsClient
Agenda agenda.AgendaClient
//SolidarityService solidarityservice.SolidarityServiceClient
SolidarityService solidarityservice.SolidarityServiceClient
}
func NewServicesHandler(cfg *viper.Viper) (*ServicesHandler, error) {
@ -27,7 +27,7 @@ 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")
//solidarityDial = cfg.GetString("services.grpc.solidarityservice.dial")
solidarityDial = cfg.GetString("services.grpc.solidarityservice.dial")
)
mobilityAccounts, err := NewMobilityAccountService(mobilityAccountsDial)
if err != nil {
@ -49,10 +49,10 @@ func NewServicesHandler(cfg *viper.Viper) (*ServicesHandler, error) {
return nil, err
}
// solidarityService, err := NewSolidarityService(solidarityDial)
// if err != nil {
// return nil , err
// }
solidarityService, err := NewSolidarityService(solidarityDial)
if err != nil {
return nil , err
}
return &ServicesHandler{
@ -61,7 +61,7 @@ func NewServicesHandler(cfg *viper.Viper) (*ServicesHandler, error) {
GroupsManagement: groupsManagement,
Fleets: fleetsSvc,
Agenda: agendaSvc,
//SolidarityService: solidarityService,
SolidarityService: solidarityService,
},
}, nil
}

View File

@ -1,23 +1,23 @@
package services
import (
// solidarity_service "git.coopgo.io/coopgo-platform/solidarity-service/grpcapi"
// "google.golang.org/grpc"
solidarity_service "git.coopgo.io/coopgo-apps/silvermobi/servers/grpcapi/proto"
"google.golang.org/grpc"
)
// type SolidarityService struct {
// solidarity_service.SolidarityServiceClient
// }
type SolidarityService struct {
solidarity_service.SolidarityServiceClient
}
// func NewSolidarityService(silvermobiDial string) (*SolidarityService, error) {
// conn, err := grpc.Dial(silvermobiDial, grpc.WithInsecure())
func NewSolidarityService(silvermobiDial string) (*SolidarityService, error) {
conn, err := grpc.Dial(silvermobiDial, grpc.WithInsecure())
// client := solidarity_service.NewSolidarityServiceClient(conn)
// if err != nil {
// return nil, err
// }
client := solidarity_service.NewSolidarityServiceClient(conn)
if err != nil {
return nil, err
}
// return &SolidarityService{
// SolidarityServiceClient: client,
// }, nil
// }
return &SolidarityService{
SolidarityServiceClient: client,
}, nil
}