From cf6812e055ae0b48eb1b53b64751ca2b3598f633 Mon Sep 17 00:00:00 2001 From: Kleonikos Kyriakis Date: Thu, 18 Jan 2024 10:27:30 +0200 Subject: [PATCH] Bump camino-messenger-protocol dependency versions --- examples/rpc/client.go | 24 +++---- examples/rpc/partner-plugin/server.go | 87 +++++++++++++------------- go.mod | 4 +- go.sum | 10 +-- internal/messaging/service.go | 26 ++++---- internal/messaging/service_registry.go | 16 ++--- internal/messaging/types.go | 36 +++++------ internal/rpc/server/server.go | 62 +++++++++--------- 8 files changed, 133 insertions(+), 132 deletions(-) diff --git a/examples/rpc/client.go b/examples/rpc/client.go index e3866b4e..b64381ed 100644 --- a/examples/rpc/client.go +++ b/examples/rpc/client.go @@ -1,15 +1,15 @@ package main import ( - typesv1alpha1 "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/types/v1alpha1" + typesv1alpha "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/types/v1alpha" "context" "fmt" "log" "os" "time" - "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/accommodation/v1alpha1/accommodationv1alpha1grpc" - accommodationv1alpha1 "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/accommodation/v1alpha1" + "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/accommodation/v1alpha/accommodationv1alphagrpc" + accommodationv1alpha "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/accommodation/v1alpha" internalmetadata "github.com/chain4travel/camino-messenger-bot/internal/metadata" "go.uber.org/zap" "google.golang.org/grpc" @@ -42,18 +42,18 @@ func main() { if err != nil { panic(err) } - request := &accommodationv1alpha1.AccommodationSearchRequest{ + request := &accommodationv1alpha.AccommodationSearchRequest{ Header: nil, - SearchParametersGeneric: &typesv1alpha1.SearchParameters{ - Currency: typesv1alpha1.Currency_CURRENCY_EUR, - Language: typesv1alpha1.Language_LANGUAGE_UG, + SearchParametersGeneric: &typesv1alpha.SearchParameters{ + Currency: typesv1alpha.Currency_CURRENCY_EUR, + Language: typesv1alpha.Language_LANGUAGE_UG, Market: 1, MaxOptions: 2, }, - SearchParametersAccommodation: &accommodationv1alpha1.AccommodationSearchParameters{ - RatePlan: []*typesv1alpha1.RatePlan{ - { - RatePlan: "economy", + Queries: []*accommodationv1alpha.AccommodationSearchQuery{ + { + SearchParametersAccommodation: &accommodationv1alpha.AccommodationSearchParameters{ + RatePlan: []*typesv1alpha.RatePlan{{RatePlan: "economy"}}, }, }, }, @@ -68,7 +68,7 @@ func main() { }) ctx := metadata.NewOutgoingContext(context.Background(), md) - ass := accommodationv1alpha1grpc.NewAccommodationSearchServiceClient(c.ClientConn) + ass := accommodationv1alphagrpc.NewAccommodationSearchServiceClient(c.ClientConn) begin := time.Now() var header metadata.MD resp, err := ass.AccommodationSearch(ctx, request, grpc.Header(&header)) diff --git a/examples/rpc/partner-plugin/server.go b/examples/rpc/partner-plugin/server.go index c9335307..6e7b1d49 100644 --- a/examples/rpc/partner-plugin/server.go +++ b/examples/rpc/partner-plugin/server.go @@ -8,34 +8,35 @@ import ( "os" "strconv" - "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/activity/v1alpha1/activityv1alpha1grpc" - "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/network/v1alpha1/networkv1alpha1grpc" - "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/partner/v1alpha1/partnerv1alpha1grpc" - "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/ping/v1alpha1/pingv1alpha1grpc" - "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/transport/v1alpha1/transportv1alpha1grpc" - activityv1alpha1 "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/activity/v1alpha1" - networkv1alpha1 "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/network/v1alpha1" - partnerv1alpha1 "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/partner/v1alpha1" - pingv1alpha1 "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/ping/v1alpha1" - transportv1alpha1 "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/transport/v1alpha1" - typesv1alpha1 "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/types/v1alpha1" - - "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/accommodation/v1alpha1/accommodationv1alpha1grpc" - accommodationv1alpha1 "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/accommodation/v1alpha1" + "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/accommodation/v1alpha/accommodationv1alphagrpc" + "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/activity/v1alpha/activityv1alphagrpc" + "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/network/v1alpha/networkv1alphagrpc" + "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/partner/v1alpha/partnerv1alphagrpc" + "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/ping/v1alpha/pingv1alphagrpc" + "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/transport/v1alpha/transportv1alphagrpc" + + accommodationv1alpha "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/accommodation/v1alpha" + activityv1alpha "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/activity/v1alpha" + networkv1alpha "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/network/v1alpha" + partnerv1alpha "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/partner/v1alpha" + pingv1alpha "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/ping/v1alpha" + transportv1alpha "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/transport/v1alpha" + typesv1alpha "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/types/v1alpha" + "github.com/chain4travel/camino-messenger-bot/internal/metadata" "google.golang.org/grpc" ) type partnerPlugin struct { - activityv1alpha1grpc.ActivitySearchServiceServer - accommodationv1alpha1grpc.AccommodationSearchServiceServer - networkv1alpha1grpc.GetNetworkFeeServiceServer - partnerv1alpha1grpc.GetPartnerConfigurationServiceServer - pingv1alpha1grpc.PingServiceServer - transportv1alpha1grpc.TransportSearchServiceServer + activityv1alphagrpc.ActivitySearchServiceServer + accommodationv1alphagrpc.AccommodationSearchServiceServer + networkv1alphagrpc.GetNetworkFeeServiceServer + partnerv1alphagrpc.GetPartnerConfigurationServiceServer + pingv1alphagrpc.PingServiceServer + transportv1alphagrpc.TransportSearchServiceServer } -func (p *partnerPlugin) ActivitySearch(ctx context.Context, request *activityv1alpha1.ActivitySearchRequest) (*activityv1alpha1.ActivitySearchResponse, error) { +func (p *partnerPlugin) ActivitySearch(ctx context.Context, request *activityv1alpha.ActivitySearchRequest) (*activityv1alpha.ActivitySearchResponse, error) { md := metadata.Metadata{} err := md.ExtractMetadata(ctx) if err != nil { @@ -44,15 +45,15 @@ func (p *partnerPlugin) ActivitySearch(ctx context.Context, request *activityv1a md.Stamp(fmt.Sprintf("%s-%s", "ext-system", "response")) log.Printf("Responding to request: %s", md.RequestID) - response := activityv1alpha1.ActivitySearchResponse{ + response := activityv1alpha.ActivitySearchResponse{ Header: nil, - Metadata: &typesv1alpha1.SearchResponseMetadata{SearchId: &typesv1alpha1.UUID{Value: md.RequestID}}, + Metadata: &typesv1alpha.SearchResponseMetadata{SearchId: &typesv1alpha.UUID{Value: md.RequestID}}, } grpc.SendHeader(ctx, md.ToGrpcMD()) return &response, nil } -func (p *partnerPlugin) AccommodationSearch(ctx context.Context, request *accommodationv1alpha1.AccommodationSearchRequest) (*accommodationv1alpha1.AccommodationSearchResponse, error) { +func (p *partnerPlugin) AccommodationSearch(ctx context.Context, request *accommodationv1alpha.AccommodationSearchRequest) (*accommodationv1alpha.AccommodationSearchResponse, error) { md := metadata.Metadata{} err := md.ExtractMetadata(ctx) if err != nil { @@ -61,15 +62,15 @@ func (p *partnerPlugin) AccommodationSearch(ctx context.Context, request *accomm md.Stamp(fmt.Sprintf("%s-%s", "ext-system", "response")) log.Printf("Responding to request: %s", md.RequestID) - response := accommodationv1alpha1.AccommodationSearchResponse{ + response := accommodationv1alpha.AccommodationSearchResponse{ Header: nil, - Metadata: &typesv1alpha1.SearchResponseMetadata{SearchId: &typesv1alpha1.UUID{Value: md.RequestID}}, + Metadata: &typesv1alpha.SearchResponseMetadata{SearchId: &typesv1alpha.UUID{Value: md.RequestID}}, } grpc.SendHeader(ctx, md.ToGrpcMD()) return &response, nil } -func (p *partnerPlugin) GetNetworkFee(ctx context.Context, request *networkv1alpha1.GetNetworkFeeRequest) (*networkv1alpha1.GetNetworkFeeResponse, error) { +func (p *partnerPlugin) GetNetworkFee(ctx context.Context, request *networkv1alpha.GetNetworkFeeRequest) (*networkv1alpha.GetNetworkFeeResponse, error) { md := metadata.Metadata{} err := md.ExtractMetadata(ctx) if err != nil { @@ -78,8 +79,8 @@ func (p *partnerPlugin) GetNetworkFee(ctx context.Context, request *networkv1alp md.Stamp(fmt.Sprintf("%s-%s", "ext-system", "response")) log.Printf("Responding to request: %s", md.RequestID) - response := networkv1alpha1.GetNetworkFeeResponse{ - NetworkFee: &networkv1alpha1.NetworkFee{ + response := networkv1alpha.GetNetworkFeeResponse{ + NetworkFee: &networkv1alpha.NetworkFee{ Amount: 0, Asset: nil, }, @@ -88,7 +89,7 @@ func (p *partnerPlugin) GetNetworkFee(ctx context.Context, request *networkv1alp grpc.SendHeader(ctx, md.ToGrpcMD()) return &response, nil } -func (p *partnerPlugin) GetPartnerConfiguration(ctx context.Context, request *partnerv1alpha1.GetPartnerConfigurationRequest) (*partnerv1alpha1.GetPartnerConfigurationResponse, error) { +func (p *partnerPlugin) GetPartnerConfiguration(ctx context.Context, request *partnerv1alpha.GetPartnerConfigurationRequest) (*partnerv1alpha.GetPartnerConfigurationResponse, error) { md := metadata.Metadata{} err := md.ExtractMetadata(ctx) if err != nil { @@ -97,15 +98,15 @@ func (p *partnerPlugin) GetPartnerConfiguration(ctx context.Context, request *pa md.Stamp(fmt.Sprintf("%s-%s", "ext-system", "response")) log.Printf("Responding to request: %s", md.RequestID) - response := partnerv1alpha1.GetPartnerConfigurationResponse{ - PartnerConfiguration: &partnerv1alpha1.PartnerConfiguration{}, + response := partnerv1alpha.GetPartnerConfigurationResponse{ + PartnerConfiguration: &partnerv1alpha.PartnerConfiguration{}, CurrentBlockHeight: request.GetBlockHeight(), } grpc.SendHeader(ctx, md.ToGrpcMD()) return &response, nil } -func (p *partnerPlugin) Ping(ctx context.Context, request *pingv1alpha1.PingRequest) (*pingv1alpha1.PingResponse, error) { +func (p *partnerPlugin) Ping(ctx context.Context, request *pingv1alpha.PingRequest) (*pingv1alpha.PingResponse, error) { md := metadata.Metadata{} err := md.ExtractMetadata(ctx) if err != nil { @@ -114,12 +115,12 @@ func (p *partnerPlugin) Ping(ctx context.Context, request *pingv1alpha1.PingRequ md.Stamp(fmt.Sprintf("%s-%s", "ext-system", "response")) log.Printf("Responding to request: %s", md.RequestID) - return &pingv1alpha1.PingResponse{ + return &pingv1alpha.PingResponse{ Header: nil, PingMessage: fmt.Sprintf("Ping response to [%s] with request ID: %s", request.PingMessage, md.RequestID), }, nil } -func (p *partnerPlugin) TransportSearch(ctx context.Context, request *transportv1alpha1.TransportSearchRequest) (*transportv1alpha1.TransportSearchResponse, error) { +func (p *partnerPlugin) TransportSearch(ctx context.Context, request *transportv1alpha.TransportSearchRequest) (*transportv1alpha.TransportSearchResponse, error) { md := metadata.Metadata{} err := md.ExtractMetadata(ctx) if err != nil { @@ -128,9 +129,9 @@ func (p *partnerPlugin) TransportSearch(ctx context.Context, request *transportv md.Stamp(fmt.Sprintf("%s-%s", "ext-system", "response")) log.Printf("Responding to request: %s", md.RequestID) - response := transportv1alpha1.TransportSearchResponse{ + response := transportv1alpha.TransportSearchResponse{ Header: nil, - Metadata: &typesv1alpha1.SearchResponseMetadata{SearchId: &typesv1alpha1.UUID{Value: md.RequestID}}, + Metadata: &typesv1alpha.SearchResponseMetadata{SearchId: &typesv1alpha.UUID{Value: md.RequestID}}, } grpc.SendHeader(ctx, md.ToGrpcMD()) return &response, nil @@ -138,12 +139,12 @@ func (p *partnerPlugin) TransportSearch(ctx context.Context, request *transportv func main() { grpcServer := grpc.NewServer() - activityv1alpha1grpc.RegisterActivitySearchServiceServer(grpcServer, &partnerPlugin{}) - accommodationv1alpha1grpc.RegisterAccommodationSearchServiceServer(grpcServer, &partnerPlugin{}) - networkv1alpha1grpc.RegisterGetNetworkFeeServiceServer(grpcServer, &partnerPlugin{}) - partnerv1alpha1grpc.RegisterGetPartnerConfigurationServiceServer(grpcServer, &partnerPlugin{}) - pingv1alpha1grpc.RegisterPingServiceServer(grpcServer, &partnerPlugin{}) - transportv1alpha1grpc.RegisterTransportSearchServiceServer(grpcServer, &partnerPlugin{}) + activityv1alphagrpc.RegisterActivitySearchServiceServer(grpcServer, &partnerPlugin{}) + accommodationv1alphagrpc.RegisterAccommodationSearchServiceServer(grpcServer, &partnerPlugin{}) + networkv1alphagrpc.RegisterGetNetworkFeeServiceServer(grpcServer, &partnerPlugin{}) + partnerv1alphagrpc.RegisterGetPartnerConfigurationServiceServer(grpcServer, &partnerPlugin{}) + pingv1alphagrpc.RegisterPingServiceServer(grpcServer, &partnerPlugin{}) + transportv1alphagrpc.RegisterTransportSearchServiceServer(grpcServer, &partnerPlugin{}) port := 55555 var err error p, found := os.LookupEnv("PORT") diff --git a/go.mod b/go.mod index 1c75be5c..6edab518 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,8 @@ module github.com/chain4travel/camino-messenger-bot go 1.20 require ( - buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go v1.3.0-20240115123926-5ce123dca9ac.2 - buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go v1.32.0-20240115123926-5ce123dca9ac.1 + buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go v1.3.0-20240117225649-4aa411d2ec03.2 + buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go v1.32.0-20240117225649-4aa411d2ec03.1 github.com/ava-labs/avalanchego v1.9.16 github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e github.com/google/uuid v1.4.0 diff --git a/go.sum b/go.sum index 66587b2c..6c72b9f5 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ -buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go v1.3.0-20240115123926-5ce123dca9ac.2 h1:sBvZPI7a3okZJZ9HN/5msOcjFOyfNVR+o6qef+rFGGk= -buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go v1.3.0-20240115123926-5ce123dca9ac.2/go.mod h1:dEn+xPHLOuVGROYmM54/kZ3JXWte6BTKL2lEIUK0b/8= -buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go v1.28.1-20240115123926-5ce123dca9ac.4/go.mod h1:2viX8eSuMFjoDrr8x3FYytCp81PVYkdgfB68aIcGW6c= -buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go v1.32.0-20240115123926-5ce123dca9ac.1 h1:ID2VUj8oRbh+Bmv7nJiqw0ueWzMF7inR9ZhL07mgLBQ= -buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go v1.32.0-20240115123926-5ce123dca9ac.1/go.mod h1:XvDoE4EYgguzH74B9sx3BOh/Q8oaELUMxpAFfb2Xa6M= +buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go v1.3.0-20240117225649-4aa411d2ec03.2 h1:PE+d3NSOqWuXKRlZ4p+12mcv+Bz4hYqnv8ddaEzxYGQ= +buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go v1.3.0-20240117225649-4aa411d2ec03.2/go.mod h1:hiIrlTKrI0vYstMyE4r+jy5Tu5omO6gaPnGf4ORysZs= +buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go v1.28.1-20240117225649-4aa411d2ec03.4/go.mod h1:2viX8eSuMFjoDrr8x3FYytCp81PVYkdgfB68aIcGW6c= +buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go v1.32.0-20240117225649-4aa411d2ec03.1 h1:0gm3LbXtTIo/5PV31rOkr6u3EG3/47GCkWUpdXh6X2I= +buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go v1.32.0-20240117225649-4aa411d2ec03.1/go.mod h1:XvDoE4EYgguzH74B9sx3BOh/Q8oaELUMxpAFfb2Xa6M= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= diff --git a/internal/messaging/service.go b/internal/messaging/service.go index 18f8ded0..74cab9a5 100644 --- a/internal/messaging/service.go +++ b/internal/messaging/service.go @@ -6,15 +6,15 @@ package messaging import ( - "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/activity/v1alpha1/activityv1alpha1grpc" - "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/ping/v1alpha1/pingv1alpha1grpc" - "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/transport/v1alpha1/transportv1alpha1grpc" - networkv1alpha1 "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/network/v1alpha1" - partnerv1alpha1 "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/partner/v1alpha1" + "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/activity/v1alpha/activityv1alphagrpc" + "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/ping/v1alpha/pingv1alphagrpc" + "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/transport/v1alpha/transportv1alphagrpc" + networkv1alpha "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/network/v1alpha" + partnerv1alpha "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/partner/v1alpha" "context" "errors" - "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/accommodation/v1alpha1/accommodationv1alpha1grpc" + "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/accommodation/v1alpha/accommodationv1alphagrpc" "google.golang.org/grpc" ) @@ -33,20 +33,20 @@ type Service interface { } type activityService struct { - client *activityv1alpha1grpc.ActivitySearchServiceClient + client *activityv1alphagrpc.ActivitySearchServiceClient } type accommodationService struct { - client *accommodationv1alpha1grpc.AccommodationSearchServiceClient + client *accommodationv1alphagrpc.AccommodationSearchServiceClient } type networkService struct { } type partnerService struct { } type pingService struct { - client *pingv1alpha1grpc.PingServiceClient + client *pingv1alphagrpc.PingServiceClient } type transportService struct { - client *transportv1alpha1grpc.TransportSearchServiceClient + client *transportv1alphagrpc.TransportSearchServiceClient } func (s activityService) Call(ctx context.Context, request *RequestContent, opts ...grpc.CallOption) (ResponseContent, MessageType, error) { @@ -79,8 +79,8 @@ func (s networkService) Call(_ context.Context, request *RequestContent, _ ...gr } //TODO implement - response, err := &networkv1alpha1.GetNetworkFeeResponse{ - NetworkFee: &networkv1alpha1.NetworkFee{Amount: 100000}, + response, err := &networkv1alpha.GetNetworkFeeResponse{ + NetworkFee: &networkv1alpha.NetworkFee{Amount: 100000}, }, (error)(nil) responseContent := ResponseContent{} if err == nil { @@ -95,7 +95,7 @@ func (s partnerService) Call(_ context.Context, request *RequestContent, _ ...gr } //TODO implement - response, err := &partnerv1alpha1.GetPartnerConfigurationResponse{ + response, err := &partnerv1alpha.GetPartnerConfigurationResponse{ PartnerConfiguration: nil, CurrentBlockHeight: 0, }, (error)(nil) diff --git a/internal/messaging/service_registry.go b/internal/messaging/service_registry.go index f0f6edd5..04a28712 100644 --- a/internal/messaging/service_registry.go +++ b/internal/messaging/service_registry.go @@ -6,10 +6,10 @@ package messaging import ( - "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/accommodation/v1alpha1/accommodationv1alpha1grpc" - "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/activity/v1alpha1/activityv1alpha1grpc" - "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/ping/v1alpha1/pingv1alpha1grpc" - "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/transport/v1alpha1/transportv1alpha1grpc" + "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/accommodation/v1alpha/accommodationv1alphagrpc" + "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/activity/v1alpha/activityv1alphagrpc" + "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/ping/v1alpha/pingv1alphagrpc" + "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/transport/v1alpha/transportv1alphagrpc" "github.com/chain4travel/camino-messenger-bot/config" "github.com/chain4travel/camino-messenger-bot/internal/rpc/client" "go.uber.org/zap" @@ -34,20 +34,20 @@ func (s *ServiceRegistry) RegisterServices(requestTypes config.SupportedRequestT var service Service switch MessageType(requestType) { case ActivitySearchRequest: - c := activityv1alpha1grpc.NewActivitySearchServiceClient(s.rpcClient.ClientConn) + c := activityv1alphagrpc.NewActivitySearchServiceClient(s.rpcClient.ClientConn) service = activityService{client: &c} case AccommodationSearchRequest: - c := accommodationv1alpha1grpc.NewAccommodationSearchServiceClient(s.rpcClient.ClientConn) + c := accommodationv1alphagrpc.NewAccommodationSearchServiceClient(s.rpcClient.ClientConn) service = accommodationService{client: &c} case GetNetworkFeeRequest: service = networkService{} // this service does not talk to partner plugin case GetPartnerConfigurationRequest: service = partnerService{} // this service does not talk to partner plugin case PingRequest: - c := pingv1alpha1grpc.NewPingServiceClient(s.rpcClient.ClientConn) + c := pingv1alphagrpc.NewPingServiceClient(s.rpcClient.ClientConn) service = pingService{client: &c} case TransportSearchRequest: - c := transportv1alpha1grpc.NewTransportSearchServiceClient(s.rpcClient.ClientConn) + c := transportv1alphagrpc.NewTransportSearchServiceClient(s.rpcClient.ClientConn) service = transportService{client: &c} default: s.logger.Infof("Skipping registration of unknown request type: %s", requestType) diff --git a/internal/messaging/types.go b/internal/messaging/types.go index 19b42b83..ddca369d 100644 --- a/internal/messaging/types.go +++ b/internal/messaging/types.go @@ -1,31 +1,31 @@ package messaging import ( - accommodationv1alpha1 "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/accommodation/v1alpha1" - activityv1alpha1 "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/activity/v1alpha1" - networkv1alpha1 "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/network/v1alpha1" - partnerv1alpha1 "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/partner/v1alpha1" - pingv1alpha1 "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/ping/v1alpha1" - transportv1alpha1 "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/transport/v1alpha1" + accommodationv1alpha "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/accommodation/v1alpha" + activityv1alpha "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/activity/v1alpha" + networkv1alpha "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/network/v1alpha" + partnerv1alpha "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/partner/v1alpha" + pingv1alpha "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/ping/v1alpha" + transportv1alpha "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/transport/v1alpha" "github.com/chain4travel/camino-messenger-bot/internal/metadata" "github.com/golang/protobuf/proto" ) type RequestContent struct { - activityv1alpha1.ActivitySearchRequest - accommodationv1alpha1.AccommodationSearchRequest - networkv1alpha1.GetNetworkFeeRequest - partnerv1alpha1.GetPartnerConfigurationRequest - pingv1alpha1.PingRequest - transportv1alpha1.TransportSearchRequest + activityv1alpha.ActivitySearchRequest + accommodationv1alpha.AccommodationSearchRequest + networkv1alpha.GetNetworkFeeRequest + partnerv1alpha.GetPartnerConfigurationRequest + pingv1alpha.PingRequest + transportv1alpha.TransportSearchRequest } type ResponseContent struct { - activityv1alpha1.ActivitySearchResponse - accommodationv1alpha1.AccommodationSearchResponse - networkv1alpha1.GetNetworkFeeResponse - partnerv1alpha1.GetPartnerConfigurationResponse - pingv1alpha1.PingResponse - transportv1alpha1.TransportSearchResponse + activityv1alpha.ActivitySearchResponse + accommodationv1alpha.AccommodationSearchResponse + networkv1alpha.GetNetworkFeeResponse + partnerv1alpha.GetPartnerConfigurationResponse + pingv1alpha.PingResponse + transportv1alpha.TransportSearchResponse } type MessageContent struct { RequestContent diff --git a/internal/rpc/server/server.go b/internal/rpc/server/server.go index 9dbf23a3..2b46fcb8 100644 --- a/internal/rpc/server/server.go +++ b/internal/rpc/server/server.go @@ -1,25 +1,25 @@ package server import ( + "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/activity/v1alpha/activityv1alphagrpc" "context" "errors" "fmt" "log" "net" - "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/activity/v1alpha1/activityv1alpha1grpc" - "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/network/v1alpha1/networkv1alpha1grpc" - "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/partner/v1alpha1/partnerv1alpha1grpc" - "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/ping/v1alpha1/pingv1alpha1grpc" - "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/transport/v1alpha1/transportv1alpha1grpc" - activityv1alpha1 "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/activity/v1alpha1" - networkv1alpha1 "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/network/v1alpha1" - partnerv1alpha1 "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/partner/v1alpha1" - pingv1alpha1 "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/ping/v1alpha1" - transportv1alpha1 "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/transport/v1alpha1" - - "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/accommodation/v1alpha1/accommodationv1alpha1grpc" - accommodationv1alpha1 "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/accommodation/v1alpha1" + "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/network/v1alpha/networkv1alphagrpc" + "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/partner/v1alpha/partnerv1alphagrpc" + "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/ping/v1alpha/pingv1alphagrpc" + "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/transport/v1alpha/transportv1alphagrpc" + activityv1alpha "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/activity/v1alpha" + networkv1alpha "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/network/v1alpha" + partnerv1alpha "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/partner/v1alpha" + pingv1alpha "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/ping/v1alpha" + transportv1alpha "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/transport/v1alpha" + + "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/accommodation/v1alpha/accommodationv1alphagrpc" + accommodationv1alpha "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/accommodation/v1alpha" "github.com/chain4travel/camino-messenger-bot/config" "github.com/chain4travel/camino-messenger-bot/internal/messaging" "github.com/chain4travel/camino-messenger-bot/internal/metadata" @@ -32,12 +32,12 @@ import ( var ( _ Server = (*server)(nil) - _ accommodationv1alpha1grpc.AccommodationSearchServiceServer = (*server)(nil) - _ activityv1alpha1grpc.ActivitySearchServiceServer = (*server)(nil) - _ networkv1alpha1grpc.GetNetworkFeeServiceServer = (*server)(nil) - _ partnerv1alpha1grpc.GetPartnerConfigurationServiceServer = (*server)(nil) - _ pingv1alpha1grpc.PingServiceServer = (*server)(nil) - _ transportv1alpha1grpc.TransportSearchServiceServer = (*server)(nil) + _ accommodationv1alphagrpc.AccommodationSearchServiceServer = (*server)(nil) + _ activityv1alphagrpc.ActivitySearchServiceServer = (*server)(nil) + _ networkv1alphagrpc.GetNetworkFeeServiceServer = (*server)(nil) + _ partnerv1alphagrpc.GetPartnerConfigurationServiceServer = (*server)(nil) + _ pingv1alphagrpc.PingServiceServer = (*server)(nil) + _ transportv1alphagrpc.TransportSearchServiceServer = (*server)(nil) errMissingRecipient = errors.New("missing recipient") ) @@ -77,12 +77,12 @@ func NewServer(cfg *config.RPCServerConfig, logger *zap.SugaredLogger, processor func createGrpcServerAndRegisterServices(server *server, opts ...grpc.ServerOption) *grpc.Server { grpcServer := grpc.NewServer(opts...) - activityv1alpha1grpc.RegisterActivitySearchServiceServer(grpcServer, server) - accommodationv1alpha1grpc.RegisterAccommodationSearchServiceServer(grpcServer, server) - networkv1alpha1grpc.RegisterGetNetworkFeeServiceServer(grpcServer, server) - partnerv1alpha1grpc.RegisterGetPartnerConfigurationServiceServer(grpcServer, server) - pingv1alpha1grpc.RegisterPingServiceServer(grpcServer, server) - transportv1alpha1grpc.RegisterTransportSearchServiceServer(grpcServer, server) + activityv1alphagrpc.RegisterActivitySearchServiceServer(grpcServer, server) + accommodationv1alphagrpc.RegisterAccommodationSearchServiceServer(grpcServer, server) + networkv1alphagrpc.RegisterGetNetworkFeeServiceServer(grpcServer, server) + partnerv1alphagrpc.RegisterGetPartnerConfigurationServiceServer(grpcServer, server) + pingv1alphagrpc.RegisterPingServiceServer(grpcServer, server) + transportv1alphagrpc.RegisterTransportSearchServiceServer(grpcServer, server) return grpcServer } @@ -99,32 +99,32 @@ func (s *server) Stop() { s.grpcServer.Stop() } -func (s *server) AccommodationSearch(ctx context.Context, request *accommodationv1alpha1.AccommodationSearchRequest) (*accommodationv1alpha1.AccommodationSearchResponse, error) { +func (s *server) AccommodationSearch(ctx context.Context, request *accommodationv1alpha.AccommodationSearchRequest) (*accommodationv1alpha.AccommodationSearchResponse, error) { response, err := s.processExternalRequest(ctx, messaging.AccommodationSearchRequest, &messaging.RequestContent{AccommodationSearchRequest: *request}) return &response.AccommodationSearchResponse, err //TODO set specific errors according to https://grpc.github.io/grpc/core/md_doc_statuscodes.html ? } -func (s *server) Ping(ctx context.Context, request *pingv1alpha1.PingRequest) (*pingv1alpha1.PingResponse, error) { +func (s *server) Ping(ctx context.Context, request *pingv1alpha.PingRequest) (*pingv1alpha.PingResponse, error) { response, err := s.processExternalRequest(ctx, messaging.PingRequest, &messaging.RequestContent{PingRequest: *request}) return &response.PingResponse, err } -func (s *server) GetNetworkFee(ctx context.Context, request *networkv1alpha1.GetNetworkFeeRequest) (*networkv1alpha1.GetNetworkFeeResponse, error) { +func (s *server) GetNetworkFee(ctx context.Context, request *networkv1alpha.GetNetworkFeeRequest) (*networkv1alpha.GetNetworkFeeResponse, error) { response, err := s.processInternalRequest(ctx, messaging.GetNetworkFeeRequest, &messaging.RequestContent{GetNetworkFeeRequest: *request}) return &response.GetNetworkFeeResponse, err } -func (s *server) GetPartnerConfiguration(ctx context.Context, request *partnerv1alpha1.GetPartnerConfigurationRequest) (*partnerv1alpha1.GetPartnerConfigurationResponse, error) { +func (s *server) GetPartnerConfiguration(ctx context.Context, request *partnerv1alpha.GetPartnerConfigurationRequest) (*partnerv1alpha.GetPartnerConfigurationResponse, error) { response, err := s.processInternalRequest(ctx, messaging.GetPartnerConfigurationRequest, &messaging.RequestContent{GetPartnerConfigurationRequest: *request}) return &response.GetPartnerConfigurationResponse, err } -func (s *server) ActivitySearch(ctx context.Context, request *activityv1alpha1.ActivitySearchRequest) (*activityv1alpha1.ActivitySearchResponse, error) { +func (s *server) ActivitySearch(ctx context.Context, request *activityv1alpha.ActivitySearchRequest) (*activityv1alpha.ActivitySearchResponse, error) { response, err := s.processExternalRequest(ctx, messaging.ActivitySearchRequest, &messaging.RequestContent{ActivitySearchRequest: *request}) return &response.ActivitySearchResponse, err } -func (s *server) TransportSearch(ctx context.Context, request *transportv1alpha1.TransportSearchRequest) (*transportv1alpha1.TransportSearchResponse, error) { +func (s *server) TransportSearch(ctx context.Context, request *transportv1alpha.TransportSearchRequest) (*transportv1alpha.TransportSearchResponse, error) { response, err := s.processExternalRequest(ctx, messaging.TransportSearchRequest, &messaging.RequestContent{TransportSearchRequest: *request}) return &response.TransportSearchResponse, err }