From d7fc1bce5b1d1ca98ea7a4c4ee08404a364858b3 Mon Sep 17 00:00:00 2001 From: "ev.lekht" Date: Thu, 21 Nov 2024 21:04:48 +0400 Subject: [PATCH 01/20] wip --- internal/app/app.go | 4 +- internal/compression/compress.go | 3 +- internal/matrix/matrix_messenger.go | 20 +- internal/messaging/messenger.go | 2 +- internal/messaging/mint.go | 12 + internal/messaging/mint_v1.go | 96 +++---- internal/messaging/mint_v2.go | 96 +++---- internal/messaging/mock_messenger.go | 8 +- internal/messaging/noop_response_handler.go | 10 +- internal/messaging/processor.go | 269 ++++++++++---------- internal/messaging/processor_test.go | 59 ++--- internal/messaging/response_handler.go | 55 ++-- internal/messaging/types/types.go | 13 +- internal/rpc/rpc.go | 4 +- internal/rpc/server/server.go | 20 +- pkg/cm_accounts/cm_accounts.go | 28 ++ scripts/generate_grpc_service_handlers.sh | 6 +- scripts/mocks.mockgen.source.txt | 2 +- templates/server.go.tpl | 6 +- templates/server_method.go.tpl | 2 +- 20 files changed, 399 insertions(+), 316 deletions(-) diff --git a/internal/app/app.go b/internal/app/app.go index 505afdb9..bc2ab41d 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -145,7 +145,7 @@ func NewApp(ctx context.Context, cfg *config.Config, logger *zap.SugaredLogger) botAddress := crypto.PubkeyToAddress(cfg.BotKey.PublicKey) botUserID := messaging.UserIDFromAddress(botAddress, cfg.Matrix.Host) - messageProcessor := messaging.NewProcessor( + messageProcessor := messaging.NewMessageProcessor( matrixMessenger, logger, cfg.ResponseTimeout, @@ -208,7 +208,7 @@ type App struct { chequeHandler chequehandler.ChequeHandler rpcClient *client.RPCClient rpcServer server.Server - messageProcessor messaging.Processor + messageProcessor messaging.MessageProcessor messenger messaging.Messenger botUserID id.UserID } diff --git a/internal/compression/compress.go b/internal/compression/compress.go index 90e57966..365703fb 100644 --- a/internal/compression/compress.go +++ b/internal/compression/compress.go @@ -10,7 +10,8 @@ import ( ) const ( - + // TODO@ according to comment, this must be re-investigated! + // TODO@ Also, shouldn't be metadata (and etc if anything) size be taken into account? // MaxChunkSize a moderate/safe max chunk size is 48KB. This is because the maximum size of a matrix event is 64KB. // Megolm encryption adds an extra 33% overhead to the encrypted content due to base64 encryption. This means that // the maximum size of pre-encrypted chunk should be 48KB / 1.33 ~= 36KB. We round down to 35KB to be safe. diff --git a/internal/matrix/matrix_messenger.go b/internal/matrix/matrix_messenger.go index 9ddbba48..426ae123 100644 --- a/internal/matrix/matrix_messenger.go +++ b/internal/matrix/matrix_messenger.go @@ -78,6 +78,10 @@ func (m *messenger) StartReceiver() (id.UserID, error) { syncer := m.client.Syncer.(*mautrix.DefaultSyncer) syncer.OnEventType(matrix.EventTypeC4TMessage, func(ctx context.Context, evt *event.Event) { + if evt.Sender == m.client.UserID { // ignore own messages + return + } + msg := evt.Content.Parsed.(*matrix.CaminoMatrixMessage) traceID, err := trace.TraceIDFromHex(msg.Metadata.RequestID) if err != nil { @@ -169,7 +173,7 @@ func (m *messenger) StopReceiver() error { return m.client.cryptoHelper.Close() } -func (m *messenger) SendAsync(ctx context.Context, msg types.Message, content [][]byte, sendTo id.UserID) error { +func (m *messenger) SendAsync(ctx context.Context, msg *types.Message, sendTo id.UserID) error { m.logger.Info("Sending async message", zap.String("msg", msg.Metadata.RequestID)) ctx, span := m.tracer.Start(ctx, "messenger.SendAsync", trace.WithSpanKind(trace.SpanKindProducer), trace.WithAttributes(attribute.String("type", string(msg.Type)))) defer span.End() @@ -181,7 +185,7 @@ func (m *messenger) SendAsync(ctx context.Context, msg types.Message, content [] } roomSpan.End() - return m.sendMessageEvents(ctx, roomID, matrix.EventTypeC4TMessage, createMatrixMessages(&msg, content)) + return m.sendMessageEvents(ctx, roomID, matrix.EventTypeC4TMessage, createMatrixMessages(msg)) } func (m *messenger) sendMessageEvents(ctx context.Context, roomID id.RoomID, eventType event.Type, messages []matrix.CaminoMatrixMessage) error { @@ -243,24 +247,24 @@ func hexWithChecksum(bytes []byte) (string, error) { return fmt.Sprintf("0x%x", bytes), nil } -func createMatrixMessages(msg *types.Message, content [][]byte) []matrix.CaminoMatrixMessage { - messages := make([]matrix.CaminoMatrixMessage, 0, len(content)) +func createMatrixMessages(msg *types.Message) []matrix.CaminoMatrixMessage { + messages := make([]matrix.CaminoMatrixMessage, 0, len(msg.CompressedContent)) // add first chunk to messages slice caminoMatrixMsg := matrix.CaminoMatrixMessage{ MessageEventContent: event.MessageEventContent{MsgType: event.MessageType(msg.Type)}, Metadata: msg.Metadata, } - caminoMatrixMsg.Metadata.NumberOfChunks = uint64(len(content)) + caminoMatrixMsg.Metadata.NumberOfChunks = uint64(len(msg.CompressedContent)) caminoMatrixMsg.Metadata.ChunkIndex = 0 - caminoMatrixMsg.CompressedContent = content[0] + caminoMatrixMsg.CompressedContent = msg.CompressedContent[0] messages = append(messages, caminoMatrixMsg) // if multiple chunks were produced upon compression, add them to messages slice - for i, chunk := range content[1:] { + for i, chunk := range msg.CompressedContent[1:] { messages = append(messages, matrix.CaminoMatrixMessage{ MessageEventContent: event.MessageEventContent{MsgType: event.MessageType(msg.Type)}, - Metadata: metadata.Metadata{RequestID: msg.Metadata.RequestID, NumberOfChunks: uint64(len(content)), ChunkIndex: uint64(i + 1)}, + Metadata: metadata.Metadata{RequestID: msg.Metadata.RequestID, NumberOfChunks: uint64(len(msg.CompressedContent)), ChunkIndex: uint64(i + 1)}, CompressedContent: chunk, }) } diff --git a/internal/messaging/messenger.go b/internal/messaging/messenger.go index 960e957f..407c5bc0 100644 --- a/internal/messaging/messenger.go +++ b/internal/messaging/messenger.go @@ -27,7 +27,7 @@ type Messenger interface { StopReceiver() error // asynchronous call (fire and forget) - SendAsync(ctx context.Context, m types.Message, content [][]byte, sendTo id.UserID) error + SendAsync(ctx context.Context, m *types.Message, sendTo id.UserID) error // channel where incoming messages are written Inbound() chan types.Message diff --git a/internal/messaging/mint.go b/internal/messaging/mint.go index 8748d757..b9d94c85 100644 --- a/internal/messaging/mint.go +++ b/internal/messaging/mint.go @@ -4,6 +4,7 @@ import ( "context" "encoding/base64" "encoding/json" + "errors" "fmt" "math/big" "time" @@ -17,6 +18,10 @@ import ( "google.golang.org/protobuf/types/known/timestamppb" ) +var errMissingMintTxID = errors.New("missing mint transaction id") +var errUnexpectedRequestType = errors.New("unexpected request type") +var errUnexpectedResponseType = errors.New("unexpected response type") + // Mints a BookingToken with the supplier private key and reserves it for the buyer address // For testing you can use this uri: "data:application/json;base64,eyJuYW1lIjoiQ2FtaW5vIE1lc3NlbmdlciBCb29raW5nVG9rZW4gVGVzdCJ9Cg==" func (h *evmResponseHandler) mint( @@ -206,3 +211,10 @@ func verifyAndFixBuyableUntil(buyableUntil *timestamppb.Timestamp, currentTime t return buyableUntil, nil } + +// TODO@ test that its working, its not c++ after all +func ensureHeaderV1(response **typesv1.ResponseHeader) { + if *response == nil { + *response = &typesv1.ResponseHeader{} + } +} diff --git a/internal/messaging/mint_v1.go b/internal/messaging/mint_v1.go index e5fe46f5..1e7b0bd1 100644 --- a/internal/messaging/mint_v1.go +++ b/internal/messaging/mint_v1.go @@ -13,56 +13,58 @@ import ( "google.golang.org/protobuf/reflect/protoreflect" ) -func (h *evmResponseHandler) handleMintResponseV1(ctx context.Context, response protoreflect.ProtoMessage, request protoreflect.ProtoMessage) bool { - mintResp, ok := response.(*bookv1.MintResponse) +func (h *evmResponseHandler) prepareMintResponseV1( + ctx context.Context, + response *bookv1.MintResponse, + requestIntf protoreflect.ProtoMessage, +) { + request, ok := requestIntf.(*bookv1.MintRequest) if !ok { - return false - } - mintReq, ok := request.(*bookv1.MintRequest) - if !ok { - return false - } - if mintResp.Header == nil { - mintResp.Header = &typesv1.ResponseHeader{} + err := fmt.Errorf("%w: expected *bookv1.MintRequest, got %T", errUnexpectedRequestType, requestIntf) + h.logger.Error(err) + h.AddErrorToResponseHeader(response, err.Error()) + return } - if mintResp.Header.Status == typesv1.StatusType_STATUS_TYPE_FAILURE { - return false + ensureHeaderV1(&response.Header) + + if response.Header.Status == typesv1.StatusType_STATUS_TYPE_FAILURE { + return } // TODO @evlekht ensure that mintReq.BuyerAddress is c-chain address format, // TODO not x/p/t chain or anything else. Currently it will not error // TODO if address is invalid and will just get zero addr - buyerAddress := common.HexToAddress(mintReq.BuyerAddress) + buyerAddress := common.HexToAddress(request.BuyerAddress) // Get a Token URI for the token. jsonPlain, tokenURI, err := createTokenURIforMintResponse( - mintResp.MintId.Value, - mintReq.BookingReference, + response.MintId.Value, + request.BookingReference, ) if err != nil { errMsg := fmt.Sprintf("error creating token URI: %v", err) h.logger.Debugf(errMsg) // TODO: @VjeraTurk change to Error after we stop using mocked uri data - h.AddErrorToResponseHeader(response, errMsg) - return true + h.AddErrorToResponseHeader(request, errMsg) + return } h.logger.Debugf("Token URI JSON: %s\n", jsonPlain) - buyableUntil, err := verifyAndFixBuyableUntil(mintResp.BuyableUntil, time.Now()) + buyableUntil, err := verifyAndFixBuyableUntil(response.BuyableUntil, time.Now()) if err != nil { h.logger.Error(err) - h.AddErrorToResponseHeader(response, err.Error()) - return true + h.AddErrorToResponseHeader(request, err.Error()) + return } - mintResp.BuyableUntil = buyableUntil + response.BuyableUntil = buyableUntil - price, paymentToken, err := h.getPriceAndTokenV1(ctx, mintResp.Price) + price, paymentToken, err := h.getPriceAndTokenV1(ctx, response.Price) if err != nil { errMessage := fmt.Sprintf("error getting price and payment token: %v", err) h.logger.Errorf(errMessage) - h.AddErrorToResponseHeader(response, errMessage) - return true + h.AddErrorToResponseHeader(request, errMessage) + return } // MINT TOKEN @@ -70,41 +72,44 @@ func (h *evmResponseHandler) handleMintResponseV1(ctx context.Context, response ctx, buyerAddress, tokenURI, - big.NewInt(mintResp.BuyableUntil.Seconds), + big.NewInt(response.BuyableUntil.Seconds), price, paymentToken, ) if err != nil { errMessage := fmt.Sprintf("error minting NFT: %v", err) h.logger.Errorf(errMessage) - h.AddErrorToResponseHeader(response, errMessage) - return true + h.AddErrorToResponseHeader(request, errMessage) + return } h.logger.Infof("NFT minted with txID: %s\n", txID) - h.onBookingTokenMint(tokenID, mintResp.MintId, mintResp.BuyableUntil.AsTime()) + h.onBookingTokenMint(tokenID, response.MintId, response.BuyableUntil.AsTime()) - mintResp.Header.Status = typesv1.StatusType_STATUS_TYPE_SUCCESS - mintResp.BookingToken = &typesv1.BookingToken{TokenId: int32(tokenID.Int64())} //nolint:gosec - mintResp.MintTransactionId = txID - return false + response.Header.Status = typesv1.StatusType_STATUS_TYPE_SUCCESS + response.BookingToken = &typesv1.BookingToken{TokenId: int32(tokenID.Int64())} //nolint:gosec + response.MintTransactionId = txID } -func (h *evmResponseHandler) handleMintRequestV1(ctx context.Context, response protoreflect.ProtoMessage) bool { - mintResp, ok := response.(*bookv1.MintResponse) +func (h *evmResponseHandler) processMintResponseV1(ctx context.Context, responseIntf protoreflect.ProtoMessage) { + response, ok := responseIntf.(*bookv1.MintResponse) if !ok { - return false - } - if mintResp.Header == nil { - mintResp.Header = &typesv1.ResponseHeader{} + err := fmt.Errorf("%w: expected *bookv1.MintResponse, got %T", errUnexpectedResponseType, responseIntf) + h.logger.Error(err) + h.AddErrorToResponseHeader(response, err.Error()) + return } - if mintResp.MintTransactionId == "" { - h.AddErrorToResponseHeader(response, "missing mint transaction id") - return true + + ensureHeaderV1(&response.Header) + + if response.MintTransactionId == "" { + h.logger.Error(errMissingMintTxID) + h.AddErrorToResponseHeader(response, errMissingMintTxID.Error()) + return } - value64 := uint64(mintResp.BookingToken.TokenId) + value64 := uint64(response.BookingToken.TokenId) tokenID := new(big.Int).SetUint64(value64) receipt, err := h.bookingService.BuyBookingToken(ctx, tokenID) @@ -112,12 +117,11 @@ func (h *evmResponseHandler) handleMintRequestV1(ctx context.Context, response p errMessage := fmt.Sprintf("error buying NFT: %v", err) h.logger.Errorf(errMessage) h.AddErrorToResponseHeader(response, errMessage) - return true + return } - h.logger.Infof("Bought NFT (txID=%s) with ID: %s\n", receipt, mintResp.MintTransactionId) - mintResp.BuyTransactionId = receipt.TxHash.Hex() - return false + h.logger.Infof("Bought NFT (txID=%s) with ID: %s\n", receipt, response.MintTransactionId) + response.BuyTransactionId = receipt.TxHash.Hex() } func (h *evmResponseHandler) getPriceAndTokenV1(ctx context.Context, price *typesv1.Price) (*big.Int, common.Address, error) { diff --git a/internal/messaging/mint_v2.go b/internal/messaging/mint_v2.go index 84d8b0bb..994c192b 100644 --- a/internal/messaging/mint_v2.go +++ b/internal/messaging/mint_v2.go @@ -15,68 +15,70 @@ import ( "google.golang.org/protobuf/reflect/protoreflect" ) -func (h *evmResponseHandler) handleMintResponseV2(ctx context.Context, response protoreflect.ProtoMessage, request protoreflect.ProtoMessage) bool { - mintResp, ok := response.(*bookv2.MintResponse) +func (h *evmResponseHandler) prepareMintResponseV2( + ctx context.Context, + response *bookv2.MintResponse, + requestIntf protoreflect.ProtoMessage, +) { + request, ok := requestIntf.(*bookv2.MintRequest) if !ok { - return false - } - mintReq, ok := request.(*bookv2.MintRequest) - if !ok { - return false - } - if mintResp.Header == nil { - mintResp.Header = &typesv1.ResponseHeader{} + err := fmt.Errorf("%w: expected *bookv2.MintRequest, got %T", errUnexpectedRequestType, requestIntf) + h.logger.Error(err) + h.AddErrorToResponseHeader(response, err.Error()) + return } + ensureHeaderV1(&response.Header) + // Check if the response from plugin is successful before minting - if mintResp.Header.Status == typesv1.StatusType_STATUS_TYPE_FAILURE { - return false + if response.Header.Status == typesv1.StatusType_STATUS_TYPE_FAILURE { + return } // TODO: @VjeraTurk check if CMAccount exists // TODO @evlekht ensure that mintReq.BuyerAddress is c-chain address format, // TODO not x/p/t chain or anything else. Currently it will not error // TODO if address is invalid and will just get zero addr - buyerAddress := common.HexToAddress(mintReq.BuyerAddress) + buyerAddress := common.HexToAddress(request.BuyerAddress) - if mintResp.BookingTokenUri == "" { + if response.BookingTokenUri == "" { jsonPlain, tokenURI, err := createTokenURIforMintResponse( - mintResp.MintId.Value, - mintReq.BookingReference, + response.MintId.Value, + request.BookingReference, ) if err != nil { errMsg := fmt.Sprintf("Failed to mint token: failed to generate tokenURI: %s", err) h.logger.Error(errMsg) h.AddErrorToResponseHeader(response, errMsg) - return true + return } h.logger.Debugf("Token URI JSON: %s\n", jsonPlain) - mintResp.BookingTokenUri = tokenURI + response.BookingTokenUri = tokenURI } - h.logger.Debugf("Token URI: %s\n", mintResp.BookingTokenUri) + h.logger.Debugf("Token URI: %s\n", response.BookingTokenUri) - buyableUntil, err := verifyAndFixBuyableUntil(mintResp.BuyableUntil, time.Now()) + buyableUntil, err := verifyAndFixBuyableUntil(response.BuyableUntil, time.Now()) if err != nil { h.logger.Error(err) h.AddErrorToResponseHeader(response, err.Error()) - return true + return } - mintResp.BuyableUntil = buyableUntil + response.BuyableUntil = buyableUntil - price, paymentToken, err := h.getPriceAndTokenV2(ctx, mintResp.Price) + price, paymentToken, err := h.getPriceAndTokenV2(ctx, response.Price) if err != nil { errMessage := fmt.Sprintf("error getting price and payment token: %v", err) h.logger.Errorf(errMessage) h.AddErrorToResponseHeader(response, errMessage) - return true + return } // MINT TOKEN txID, tokenID, err := h.mint( ctx, buyerAddress, - mintResp.BookingTokenUri, - big.NewInt(mintResp.BuyableUntil.Seconds), + response.BookingTokenUri, + big.NewInt(response.BuyableUntil.Seconds), price, paymentToken, ) @@ -84,45 +86,47 @@ func (h *evmResponseHandler) handleMintResponseV2(ctx context.Context, response errMessage := fmt.Sprintf("error minting NFT: %v", err) h.logger.Errorf(errMessage) h.AddErrorToResponseHeader(response, errMessage) - return true + return } h.logger.Infof("NFT minted with txID: %s\n", txID) - h.onBookingTokenMint(tokenID, mintResp.MintId, mintResp.BuyableUntil.AsTime()) + h.onBookingTokenMint(tokenID, response.MintId, response.BuyableUntil.AsTime()) - mintResp.Header.Status = typesv1.StatusType_STATUS_TYPE_SUCCESS - mintResp.BookingTokenId = tokenID.Uint64() - mintResp.MintTransactionId = txID - return false + response.Header.Status = typesv1.StatusType_STATUS_TYPE_SUCCESS + response.BookingTokenId = tokenID.Uint64() + response.MintTransactionId = txID } -func (h *evmResponseHandler) handleMintRequestV2(ctx context.Context, response protoreflect.ProtoMessage) bool { - mintResp, ok := response.(*bookv2.MintResponse) +func (h *evmResponseHandler) processMintResponseV2(ctx context.Context, responseIntf protoreflect.ProtoMessage) { + response, ok := responseIntf.(*bookv2.MintResponse) if !ok { - return false - } - if mintResp.Header == nil { - mintResp.Header = &typesv1.ResponseHeader{} + err := fmt.Errorf("%w: expected *bookv2.MintResponse, got %T", errUnexpectedResponseType, responseIntf) + h.logger.Error(err) + h.AddErrorToResponseHeader(response, err.Error()) + return } - if mintResp.MintTransactionId == "" { - h.AddErrorToResponseHeader(response, "missing mint transaction id") - return true + + ensureHeaderV1(&response.Header) + + if response.MintTransactionId == "" { + h.logger.Error(errMissingMintTxID) + h.AddErrorToResponseHeader(response, errMissingMintTxID.Error()) + return } - tokenID := new(big.Int).SetUint64(mintResp.BookingTokenId) + tokenID := new(big.Int).SetUint64(response.BookingTokenId) receipt, err := h.bookingService.BuyBookingToken(ctx, tokenID) if err != nil { errMessage := fmt.Sprintf("error buying NFT: %v", err) h.logger.Errorf(errMessage) h.AddErrorToResponseHeader(response, errMessage) - return true + return } - h.logger.Infof("Bought NFT (txID=%s) with ID: %s\n", receipt, mintResp.MintTransactionId) - mintResp.BuyTransactionId = receipt.TxHash.Hex() - return false + h.logger.Infof("Bought NFT (txID=%s) with ID: %s\n", receipt, response.MintTransactionId) + response.BuyTransactionId = receipt.TxHash.Hex() } func (h *evmResponseHandler) getPriceAndTokenV2(ctx context.Context, price *typesv2.Price) (*big.Int, common.Address, error) { diff --git a/internal/messaging/mock_messenger.go b/internal/messaging/mock_messenger.go index 4829d164..50d84278 100644 --- a/internal/messaging/mock_messenger.go +++ b/internal/messaging/mock_messenger.go @@ -70,17 +70,17 @@ func (mr *MockMessengerMockRecorder) Inbound() *gomock.Call { } // SendAsync mocks base method. -func (m *MockMessenger) SendAsync(arg0 context.Context, arg1 types.Message, arg2 [][]byte, arg3 id.UserID) error { +func (m *MockMessenger) SendAsync(arg0 context.Context, arg1 *types.Message, arg2 id.UserID) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SendAsync", arg0, arg1, arg2, arg3) + ret := m.ctrl.Call(m, "SendAsync", arg0, arg1, arg2) ret0, _ := ret[0].(error) return ret0 } // SendAsync indicates an expected call of SendAsync. -func (mr *MockMessengerMockRecorder) SendAsync(arg0, arg1, arg2, arg3 any) *gomock.Call { +func (mr *MockMessengerMockRecorder) SendAsync(arg0, arg1, arg2 any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendAsync", reflect.TypeOf((*MockMessenger)(nil).SendAsync), arg0, arg1, arg2, arg3) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendAsync", reflect.TypeOf((*MockMessenger)(nil).SendAsync), arg0, arg1, arg2) } // StartReceiver mocks base method. diff --git a/internal/messaging/noop_response_handler.go b/internal/messaging/noop_response_handler.go index 017a1f9e..3ffdd275 100644 --- a/internal/messaging/noop_response_handler.go +++ b/internal/messaging/noop_response_handler.go @@ -16,12 +16,12 @@ var _ ResponseHandler = (*NoopResponseHandler)(nil) type NoopResponseHandler struct{} -func (NoopResponseHandler) HandleResponse(context.Context, types.MessageType, protoreflect.ProtoMessage, protoreflect.ProtoMessage) { -} +func (NoopResponseHandler) ProcessResponseMessage(context.Context, *types.Message, *types.Message) {} + +func (NoopResponseHandler) PrepareResponseMessage(context.Context, *types.Message, *types.Message) {} -func (NoopResponseHandler) HandleRequest(context.Context, types.MessageType, protoreflect.ProtoMessage) error { +func (NoopResponseHandler) PrepareRequest(types.MessageType, protoreflect.ProtoMessage) error { return nil } -func (NoopResponseHandler) AddErrorToResponseHeader(protoreflect.ProtoMessage, string) { -} +func (NoopResponseHandler) AddErrorToResponseHeader(protoreflect.ProtoMessage, string) {} diff --git a/internal/messaging/processor.go b/internal/messaging/processor.go index 59603258..f603edf7 100644 --- a/internal/messaging/processor.go +++ b/internal/messaging/processor.go @@ -27,7 +27,7 @@ import ( ) var ( - _ Processor = (*processor)(nil) + _ MessageProcessor = (*messageProcessor)(nil) ErrUnknownMessageCategory = errors.New("unknown message category") ErrOnlyRequestMessagesAllowed = errors.New("only request messages allowed") @@ -43,20 +43,15 @@ var ( networkFee = big.NewInt(300000000000000) // 0.00003 CAM ) -type MsgHandler interface { - Request(ctx context.Context, msg *types.Message) (*types.Message, error) - Respond(msg *types.Message) error - Forward(msg *types.Message) -} -type Processor interface { +type MessageProcessor interface { metadata.Checkpoint - MsgHandler + Start(ctx context.Context) - ProcessInbound(message *types.Message) error - ProcessOutbound(ctx context.Context, message *types.Message) (*types.Message, error) + ProcessIncomingMessage(message *types.Message) error + SendRequestMessage(ctx context.Context, message *types.Message) (*types.Message, error) } -func NewProcessor( +func NewMessageProcessor( messenger Messenger, logger *zap.SugaredLogger, responseTimeout time.Duration, @@ -69,8 +64,8 @@ func NewProcessor( chequeHandler chequehandler.ChequeHandler, compressor compression.Compressor[*types.Message, [][]byte], cmAccounts cmaccounts.Service, -) Processor { - return &processor{ +) MessageProcessor { + return &messageProcessor{ messenger: messenger, logger: logger, tracer: otel.GetTracerProvider().Tracer(""), @@ -90,7 +85,7 @@ func NewProcessor( } } -type processor struct { +type messageProcessor struct { messenger Messenger logger *zap.SugaredLogger tracer trace.Tracer @@ -102,27 +97,26 @@ type processor struct { networkFeeRecipientBotAddress common.Address networkFeeRecipientCMAccountAddress common.Address - mu sync.Mutex - responseChannels map[string]chan *types.Message - serviceRegistry ServiceRegistry - responseHandler ResponseHandler - chequeHandler chequehandler.ChequeHandler - compressor compression.Compressor[*types.Message, [][]byte] - cmAccounts cmaccounts.Service + responseChannelsLock sync.RWMutex + responseChannels map[string]chan *types.Message + serviceRegistry ServiceRegistry + responseHandler ResponseHandler + chequeHandler chequehandler.ChequeHandler + compressor compression.Compressor[*types.Message, [][]byte] + cmAccounts cmaccounts.Service } -func (*processor) Checkpoint() string { +func (*messageProcessor) Checkpoint() string { return "processor" } -func (p *processor) Start(ctx context.Context) { +func (p *messageProcessor) Start(ctx context.Context) { for { select { case msgEvent := <-p.messenger.Inbound(): p.logger.Debug("Processing msg event of type: ", msgEvent.Type) go func() { - err := p.ProcessInbound(&msgEvent) - if err != nil { + if err := p.ProcessIncomingMessage(&msgEvent); err != nil { p.logger.Warnf("could not process message: %v", err) } }() @@ -133,60 +127,50 @@ func (p *processor) Start(ctx context.Context) { } } -func (p *processor) ProcessInbound(msg *types.Message) error { - if msg.Sender != p.botUserID { // outbound messages = messages sent by own ext system - switch msg.Type.Category() { - case types.Request: - return p.Respond(msg) - case types.Response: - p.Forward(msg) - return nil - default: - return ErrUnknownMessageCategory - } - } else { - return nil // ignore own outbound messages +func (p *messageProcessor) ProcessIncomingMessage(msg *types.Message) error { + switch msg.Type.Category() { + case types.Request: + return p.respond(msg) + case types.Response: + p.forward(msg) + return nil + default: + return ErrUnknownMessageCategory } } -func (p *processor) ProcessOutbound(ctx context.Context, msg *types.Message) (*types.Message, error) { - msg.Sender = p.botUserID - if msg.Type.Category() == types.Request { // only request messages (received by are processed - return p.Request(ctx, msg) // forward request msg to matrix +func (p *messageProcessor) SendRequestMessage(ctx context.Context, requestMsg *types.Message) (*types.Message, error) { + if requestMsg.Type.Category() != types.Request { + return nil, ErrOnlyRequestMessagesAllowed } - p.logger.Debugf("Ignoring any non-request message from sender other than: %s ", p.botUserID) - return nil, ErrOnlyRequestMessagesAllowed // ignore msg -} -func (p *processor) Request(ctx context.Context, msg *types.Message) (*types.Message, error) { + requestMsg.Sender = p.botUserID + p.logger.Debug("Sending outbound request message") responseChan := make(chan *types.Message) - p.mu.Lock() - p.responseChannels[msg.Metadata.RequestID] = responseChan - p.mu.Unlock() - defer func() { - p.mu.Lock() - delete(p.responseChannels, msg.Metadata.RequestID) - p.mu.Unlock() - }() + p.setResponseChannel(requestMsg.Metadata.RequestID, responseChan) + defer p.deleteResponseChannel(requestMsg.Metadata.RequestID) ctx, cancel := context.WithTimeout(ctx, p.responseTimeout) defer cancel() - if msg.Metadata.Recipient == "" { // TODO: add address validation + if requestMsg.Metadata.Recipient == "" { // TODO: add address validation return nil, ErrMissingRecipient } - p.logger.Infof("Distributor: received a request to propagate to CMAccount %s", msg.Metadata.Recipient) + p.logger.Infof("Distributor: received a request to propagate to CMAccount %s", requestMsg.Metadata.Recipient) // lookup for CM Account -> bot - recipientCMAccAddr := common.HexToAddress(msg.Metadata.Recipient) - recipientBotAddr, err := p.getFirstBotFromCMAccount(ctx, recipientCMAccAddr) + recipientCMAccAddr := common.HexToAddress(requestMsg.Metadata.Recipient) + recipientBotAddr, err := p.cmAccounts.GetFirstChequeOperator(ctx, recipientCMAccAddr) if err != nil { return nil, err } - msg.Metadata.Cheques = []cheques.SignedCheque{} + requestMsg.Metadata.Cheques = []cheques.SignedCheque{} + // TODO@ do we want to check this every time? or just once at startup? + // TODO@ we can also listen chain for bot permission changes and shut down bot if it loses + // TODO@ or not shutdown, but set some bool that will block all incoming requests with noop isBotAllowed, err := p.cmAccounts.IsBotAllowed(ctx, p.cmAccountAddress, p.myBotAddress) if err != nil { return nil, err @@ -195,84 +179,60 @@ func (p *processor) Request(ctx context.Context, msg *types.Message) (*types.Mes return nil, ErrBotMissingChequeOperatorRole } - serviceFee, err := p.cmAccounts.GetServiceFee(ctx, recipientCMAccAddr, msg.Type.ToServiceName()) + serviceFee, err := p.cmAccounts.GetServiceFee(ctx, recipientCMAccAddr, requestMsg.Type.ToServiceName()) if err != nil { // TODO @evlekht explicitly say if service is not supported and its not just some network error return nil, err } - if err := p.responseHandler.HandleRequest(ctx, msg.Type, msg.Content); err != nil { + if err := p.responseHandler.PrepareRequest(requestMsg.Type, requestMsg.Content); err != nil { return nil, err } - // Compress and chunk message - - ctx, compressedContent, err := p.compress(ctx, msg) + ctx, err = p.compressMessage(ctx, requestMsg) if err != nil { return nil, err } - // Cheque Issuing start - numberOfChunks := big.NewInt(int64(len(compressedContent))) - totalNetworkFee := new(big.Int).Mul(networkFee, numberOfChunks) - - networkFeeCheque, err := p.chequeHandler.IssueCheque( - ctx, - p.cmAccountAddress, - p.networkFeeRecipientCMAccountAddress, - p.networkFeeRecipientBotAddress, - totalNetworkFee, - ) - if err != nil { - p.logger.Errorf("failed to issue network fee cheque: %v", err) - return nil, fmt.Errorf("failed to issue network fee cheque: %w", err) - } - - serviceFeeCheque, err := p.chequeHandler.IssueCheque( - ctx, - p.cmAccountAddress, - recipientCMAccAddr, - recipientBotAddr, - serviceFee, - ) - if err != nil { - p.logger.Errorf("failed to issue service fee cheque: %v", err) - return nil, fmt.Errorf("failed to issue service fee cheque: %w", err) + if err := p.issueCheques(ctx, requestMsg, serviceFee, recipientCMAccAddr, recipientBotAddr); err != nil { + return nil, err } - msg.Metadata.Cheques = append(msg.Metadata.Cheques, *networkFeeCheque, *serviceFeeCheque) - // Cheque Issuing end - - ctx, span := p.tracer.Start(ctx, "processor.Request", trace.WithAttributes(attribute.String("type", string(msg.Type)))) + ctx, span := p.tracer.Start(ctx, "processor.Request", trace.WithAttributes(attribute.String("type", string(requestMsg.Type)))) defer span.End() - p.logger.Infof("Distributor: Bot %s is contacting bot %s of the CMaccount %s", msg.Sender, recipientBotAddr, msg.Metadata.Recipient) + p.logger.Infof("Distributor: Bot %s is contacting bot %s of the CMaccount %s", requestMsg.Sender, recipientBotAddr, requestMsg.Metadata.Recipient) if err := p.messenger.SendAsync( ctx, - *msg, - compressedContent, + requestMsg, UserIDFromAddress(recipientBotAddr, p.matrixHost), ); err != nil { return nil, err } - ctx, responseSpan := p.tracer.Start(ctx, "processor.AwaitResponse", trace.WithSpanKind(trace.SpanKindConsumer), trace.WithAttributes(attribute.String("type", string(msg.Type)))) + ctx, responseSpan := p.tracer.Start(ctx, "processor.AwaitResponse", trace.WithSpanKind(trace.SpanKindConsumer), trace.WithAttributes(attribute.String("type", string(requestMsg.Type)))) defer responseSpan.End() - for { - select { - case response := <-responseChan: - if response.Metadata.RequestID == msg.Metadata.RequestID { - p.responseHandler.HandleResponse(ctx, msg.Type, msg.Content, response.Content) - return response, nil - } - case <-ctx.Done(): - return nil, fmt.Errorf("%w of %v seconds for request: %s", ErrExceededResponseTimeout, p.responseTimeout, msg.Metadata.RequestID) + + select { + case responseMsg := <-responseChan: + if responseMsg.Metadata.RequestID == requestMsg.Metadata.RequestID { + // TODO@ do we still care about context timeout here? if not, context must be freed of timeout + // TODO@ currently, timeout is described as its only for receiving response from matrix + // TODO@ but maybe it will make more sense to use timeout for whole bot request-response cycle? + // TODO@ like, its timeout meaningful for external requester + p.responseHandler.ProcessResponseMessage(ctx, requestMsg, responseMsg) + return responseMsg, nil } + case <-ctx.Done(): + return nil, fmt.Errorf("%w of %v seconds for request: %s", ErrExceededResponseTimeout, p.responseTimeout, requestMsg.Metadata.RequestID) } + + // TODO@ not correct, responseChan case has if block. if IF is bypassed, we won't return + panic("unreachable") // will never get there, but compiler doesn't know that, so we need to satisfy return } -func (p *processor) Respond(msg *types.Message) error { +func (p *messageProcessor) respond(msg *types.Message) error { traceID, err := trace.TraceIDFromHex(msg.Metadata.RequestID) if err != nil { p.logger.Warnf("failed to parse traceID from hex [requestID:%s]: %v", msg.Metadata.RequestID, err) @@ -287,9 +247,9 @@ func (p *processor) Respond(msg *types.Message) error { return fmt.Errorf("%w: %s", ErrUnsupportedService, msg.Type) } - cheque := p.getChequeForThisBot(msg.Metadata.Cheques) - if cheque == nil { - return ErrMissingCheques + cheque, err := p.getChequeForThisBot(msg.Metadata.Cheques) + if err != nil { + return err } serviceFee, err := p.cmAccounts.GetServiceFee(ctx, common.HexToAddress(msg.Metadata.Recipient), service.Name()) @@ -303,17 +263,17 @@ func (p *processor) Respond(msg *types.Message) error { ctx, responseMsg := p.callPartnerPluginAndGetResponse(ctx, msg, cheque, service) - ctx, compressedContent, err := p.compress(ctx, responseMsg) + ctx, err = p.compressMessage(ctx, responseMsg) if err != nil { errMessage := fmt.Sprintf("error compressing/chunking response: %v", err) p.logger.Errorf(errMessage) p.responseHandler.AddErrorToResponseHeader(responseMsg.Content, errMessage) } - return p.messenger.SendAsync(ctx, *responseMsg, compressedContent, msg.Sender) + return p.messenger.SendAsync(ctx, responseMsg, msg.Sender) } -func (p *processor) callPartnerPluginAndGetResponse( +func (p *messageProcessor) callPartnerPluginAndGetResponse( ctx context.Context, requestMsg *types.Message, cheque *cheques.SignedCheque, @@ -349,18 +309,16 @@ func (p *processor) callPartnerPluginAndGetResponse( } p.logger.Infof("Supplier: CMAccount %s is calling plugin of the CMAccount %s", responseMsg.Metadata.Sender, responseMsg.Metadata.Recipient) - p.responseHandler.HandleResponse(ctx, msgType, requestMsg.Content, response) + p.responseHandler.PrepareResponseMessage(ctx, requestMsg, responseMsg) p.logger.Infof("Supplier: Bot %s responding to BOT %s", p.botUserID, requestMsg.Sender) return ctx, responseMsg } -func (p *processor) Forward(msg *types.Message) { +func (p *messageProcessor) forward(msg *types.Message) { p.logger.Debugf("Forwarding outbound response message: %s", msg.Metadata.RequestID) - p.mu.Lock() - defer p.mu.Unlock() - responseChan, ok := p.responseChannels[msg.Metadata.RequestID] + responseChan, ok := p.getResponseChannel(msg.Metadata.RequestID) if ok { responseChan <- msg close(responseChan) @@ -369,32 +327,83 @@ func (p *processor) Forward(msg *types.Message) { p.logger.Warnf("Failed to forward message: no response channel for request (%s)", msg.Metadata.RequestID) } -func (p *processor) getChequeForThisBot(cheques []cheques.SignedCheque) *cheques.SignedCheque { +func (p *messageProcessor) getChequeForThisBot(cheques []cheques.SignedCheque) (*cheques.SignedCheque, error) { for _, cheque := range cheques { if cheque.ToBot == p.myBotAddress && cheque.ToCMAccount == p.cmAccountAddress { - return &cheque + return &cheque, nil } } - return nil + return nil, ErrMissingCheques } -func (p *processor) compress(ctx context.Context, msg *types.Message) (context.Context, [][]byte, error) { +func (p *messageProcessor) compressMessage(ctx context.Context, msg *types.Message) (context.Context, error) { ctx, compressSpan := p.tracer.Start(ctx, "messenger.Compress", trace.WithAttributes(attribute.String("type", string(msg.Type)))) defer compressSpan.End() compressedContent, err := p.compressor.Compress(msg) if err != nil { - return ctx, [][]byte{{}}, err + return ctx, err } - return ctx, compressedContent, nil + msg.CompressedContent = compressedContent + return ctx, nil } -func (p *processor) getFirstBotFromCMAccount(ctx context.Context, cmAccountAddress common.Address) (common.Address, error) { - bots, err := p.cmAccounts.GetChequeOperators(ctx, cmAccountAddress) +func (p *messageProcessor) issueCheques( + ctx context.Context, + msg *types.Message, + serviceFee *big.Int, + recipientCMAccAddr common.Address, + recipientBotAddr common.Address, +) error { + numberOfChunks := big.NewInt(int64(len(msg.CompressedContent))) + totalNetworkFee := new(big.Int).Mul(networkFee, numberOfChunks) + + networkFeeCheque, err := p.chequeHandler.IssueCheque( + ctx, + p.cmAccountAddress, + p.networkFeeRecipientCMAccountAddress, + p.networkFeeRecipientBotAddress, + totalNetworkFee, + ) + if err != nil { + err = fmt.Errorf("failed to issue network fee cheque: %w", err) + p.logger.Error(err) + return err + } + + serviceFeeCheque, err := p.chequeHandler.IssueCheque( + ctx, + p.cmAccountAddress, + recipientCMAccAddr, + recipientBotAddr, + serviceFee, + ) if err != nil { - p.logger.Errorf("failed to get bots from CMAccount: %v", err) - return common.Address{}, err + err = fmt.Errorf("failed to issue service fee cheque: %w", err) + p.logger.Error(err) + return err } - return bots[0], nil + + msg.Metadata.Cheques = append(msg.Metadata.Cheques, *networkFeeCheque, *serviceFeeCheque) + return nil +} + +func (p *messageProcessor) getResponseChannel(requestID string) (chan *types.Message, bool) { + p.responseChannelsLock.RLock() + defer p.responseChannelsLock.RUnlock() + ch, ok := p.responseChannels[requestID] + return ch, ok +} + +func (p *messageProcessor) setResponseChannel(requestID string, ch chan *types.Message) { + p.responseChannelsLock.Lock() + defer p.responseChannelsLock.Unlock() + p.responseChannels[requestID] = ch +} + +func (p *messageProcessor) deleteResponseChannel(requestID string) { + p.responseChannelsLock.Lock() + defer p.responseChannelsLock.Unlock() + delete(p.responseChannels, requestID) } func UserIDFromAddress(address common.Address, host string) id.UserID { diff --git a/internal/messaging/processor_test.go b/internal/messaging/processor_test.go index 2d0a2dd7..90400d28 100644 --- a/internal/messaging/processor_test.go +++ b/internal/messaging/processor_test.go @@ -84,9 +84,9 @@ func TestProcessInbound(t *testing.T) { tests := map[string]struct { fields fields args args - prepare func(*processor) + prepare func(*messageProcessor) err error - assert func(*testing.T, *processor) + assert func(*testing.T, *messageProcessor) }{ "err: invalid message type": { fields: fields{}, @@ -99,7 +99,7 @@ func TestProcessInbound(t *testing.T) { fields: fields{ serviceRegistry: mockServiceRegistry, }, - prepare: func(*processor) { + prepare: func(*messageProcessor) { mockServiceRegistry.EXPECT().GetService(gomock.Any()).Return(nil, false) }, args: args{ @@ -129,11 +129,11 @@ func TestProcessInbound(t *testing.T) { compressor: &noopCompressor{}, cmAccounts: mockCMAccounts, }, - prepare: func(*processor) { + prepare: func(*messageProcessor) { mockService.EXPECT().Name().Return("dummy") mockService.EXPECT().Call(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, generated.PingServiceV1Response, nil) mockServiceRegistry.EXPECT().GetService(gomock.Any()).Return(mockService, true) - mockMessenger.EXPECT().SendAsync(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(errSomeError) + mockMessenger.EXPECT().SendAsync(gomock.Any(), gomock.Any(), gomock.Any()).Return(errSomeError) mockChequeHandler.EXPECT().VerifyCheque(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockCMAccounts.EXPECT().GetServiceFee(gomock.Any(), gomock.Any(), gomock.Any()).Return(big.NewInt(1), nil) }, @@ -157,11 +157,11 @@ func TestProcessInbound(t *testing.T) { compressor: &noopCompressor{}, cmAccounts: mockCMAccounts, }, - prepare: func(*processor) { + prepare: func(*messageProcessor) { mockService.EXPECT().Name().Return("dummy") mockService.EXPECT().Call(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, generated.PingServiceV1Response, nil) mockServiceRegistry.EXPECT().GetService(gomock.Any()).Return(mockService, true) - mockMessenger.EXPECT().SendAsync(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) + mockMessenger.EXPECT().SendAsync(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockChequeHandler.EXPECT().VerifyCheque(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockCMAccounts.EXPECT().GetServiceFee(gomock.Any(), gomock.Any(), gomock.Any()).Return(big.NewInt(1), nil) }, @@ -184,21 +184,23 @@ func TestProcessInbound(t *testing.T) { compressor: &noopCompressor{}, cmAccounts: mockCMAccounts, }, - prepare: func(p *processor) { + prepare: func(p *messageProcessor) { p.responseChannels[requestID] = make(chan *types.Message, 1) }, args: args{ msg: &responseMessage, }, - assert: func(t *testing.T, p *processor) { - msgReceived := <-p.responseChannels[requestID] + assert: func(t *testing.T, p *messageProcessor) { + responseChan, ok := p.getResponseChannel(requestID) + require.True(t, ok) + msgReceived := <-responseChan require.Equal(t, responseMessage, *msgReceived) }, }, } for tc, tt := range tests { t.Run(tc, func(t *testing.T) { - p := NewProcessor( + p := NewMessageProcessor( tt.fields.messenger, zap.NewNop().Sugar(), time.Duration(0), @@ -213,19 +215,19 @@ func TestProcessInbound(t *testing.T) { tt.fields.cmAccounts, ) if tt.prepare != nil { - tt.prepare(p.(*processor)) + tt.prepare(p.(*messageProcessor)) } - err := p.ProcessInbound(tt.args.msg) + err := p.ProcessIncomingMessage(tt.args.msg) require.ErrorIs(t, err, tt.err) if tt.assert != nil { - tt.assert(t, p.(*processor)) + tt.assert(t, p.(*messageProcessor)) } }) } } -func TestProcessOutbound(t *testing.T) { +func TestSendRequestMessage(t *testing.T) { productListResponse := &types.Message{ Type: generated.PingServiceV1Response, Metadata: metadata.Metadata{RequestID: requestID}, @@ -255,7 +257,7 @@ func TestProcessOutbound(t *testing.T) { want *types.Message err error prepare func() - writeResponseToChannel func(*processor) + writeResponseToChannel func(*messageProcessor) }{ "err: non-request outbound message": { fields: fields{ @@ -306,7 +308,7 @@ func TestProcessOutbound(t *testing.T) { mockCMAccounts.EXPECT().GetServiceFee(gomock.Any(), gomock.Any(), gomock.Any()).Return(big.NewInt(1), nil) mockCMAccounts.EXPECT().IsBotAllowed(gomock.Any(), gomock.Any(), gomock.Any()).Return(true, nil) mockChequeHandler.EXPECT().IssueCheque(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Times(2).Return(&cheques.SignedCheque{}, nil) - mockMessenger.EXPECT().SendAsync(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) + mockMessenger.EXPECT().SendAsync(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) }, err: ErrExceededResponseTimeout, }, @@ -333,7 +335,7 @@ func TestProcessOutbound(t *testing.T) { Return(big.NewInt(1), nil) mockCMAccounts.EXPECT().IsBotAllowed(gomock.Any(), gomock.Any(), gomock.Any()).Return(true, nil) mockChequeHandler.EXPECT().IssueCheque(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Times(2).Return(&cheques.SignedCheque{}, nil) - mockMessenger.EXPECT().SendAsync(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()). + mockMessenger.EXPECT().SendAsync(gomock.Any(), gomock.Any(), gomock.Any()). Return(errSomeError) }, err: errSomeError, @@ -358,15 +360,14 @@ func TestProcessOutbound(t *testing.T) { mockCMAccounts.EXPECT().GetChequeOperators(gomock.Any(), gomock.Any()).Return([]common.Address{{}}, nil) mockCMAccounts.EXPECT().GetServiceFee(gomock.Any(), gomock.Any(), gomock.Any()).Return(big.NewInt(1), nil) mockCMAccounts.EXPECT().IsBotAllowed(gomock.Any(), gomock.Any(), gomock.Any()).Return(true, nil) - mockMessenger.EXPECT().SendAsync(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) + mockMessenger.EXPECT().SendAsync(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockChequeHandler.EXPECT().IssueCheque(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Times(2).Return(&cheques.SignedCheque{}, nil) }, - writeResponseToChannel: func(p *processor) { + writeResponseToChannel: func(p *messageProcessor) { done := func() bool { - p.mu.Lock() - defer p.mu.Unlock() - if _, ok := p.responseChannels[requestID]; ok { - p.responseChannels[requestID] <- productListResponse + responseChan, ok := p.getResponseChannel(requestID) + if ok { + responseChan <- productListResponse return true } return false @@ -384,7 +385,7 @@ func TestProcessOutbound(t *testing.T) { for tc, tt := range tests { t.Run(tc, func(t *testing.T) { - p := NewProcessor( + p := NewMessageProcessor( tt.fields.messenger, zap.NewNop().Sugar(), tt.fields.responseTimeout, @@ -402,9 +403,9 @@ func TestProcessOutbound(t *testing.T) { tt.prepare() } if tt.writeResponseToChannel != nil { - go tt.writeResponseToChannel(p.(*processor)) + go tt.writeResponseToChannel(p.(*messageProcessor)) } - got, err := p.ProcessOutbound(context.Background(), tt.args.msg) + got, err := p.SendRequestMessage(context.Background(), tt.args.msg) require.ErrorIs(t, err, tt.err) require.Equal(t, tt.want, got) @@ -428,7 +429,7 @@ func TestStart(t *testing.T) { mockCtrl := gomock.NewController(t) mockMessenger := NewMockMessenger(mockCtrl) - mockMessenger.EXPECT().SendAsync(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Times(2).Return(nil) + mockMessenger.EXPECT().SendAsync(gomock.Any(), gomock.Any(), gomock.Any()).Times(2).Return(nil) mockServiceRegistry := NewMockServiceRegistry(mockCtrl) mockServiceRegistry.EXPECT().GetService(gomock.Any()).AnyTimes().Return(dummyService{}, true) @@ -464,7 +465,7 @@ func TestStart(t *testing.T) { mockMessenger.EXPECT().Inbound().AnyTimes().Return(ch) ctx, cancel := context.WithCancel(context.Background()) - p := NewProcessor( + p := NewMessageProcessor( mockMessenger, zap.NewNop().Sugar(), time.Duration(0), diff --git a/internal/messaging/response_handler.go b/internal/messaging/response_handler.go index 2f0e19d4..4ce3d4db 100644 --- a/internal/messaging/response_handler.go +++ b/internal/messaging/response_handler.go @@ -40,9 +40,21 @@ var ( zeroAddress = common.HexToAddress("0x0000000000000000000000000000000000000000") ) +// TODO@ move this to processor? +// TODO@ two reason its there: +// TODO@ 1) to make processor not depend on protobuf types (but package depends regardless) +// TODO@ 2) to abstract all message-specific logic into response handler. But I'm not sure if it worth it. type ResponseHandler interface { - HandleResponse(ctx context.Context, msgType types.MessageType, request protoreflect.ProtoMessage, response protoreflect.ProtoMessage) - HandleRequest(ctx context.Context, msgType types.MessageType, request protoreflect.ProtoMessage) error + // Processes incoming response + ProcessResponseMessage(ctx context.Context, requestMsg *types.Message, responseMsg *types.Message) + + // Prepares response by performing any necessary modifications to it + PrepareResponseMessage(ctx context.Context, requestMsg *types.Message, responseMsg *types.Message) + + // Prepares request by performing any necessary modifications to it + PrepareRequest(msgType types.MessageType, request protoreflect.ProtoMessage) error + + // Adds an error message to the response header AddErrorToResponseHeader(response protoreflect.ProtoMessage, errMessage string) } @@ -98,28 +110,33 @@ type evmResponseHandler struct { erc20 erc20.Service } -func (h *evmResponseHandler) HandleResponse(ctx context.Context, msgType types.MessageType, request protoreflect.ProtoMessage, response protoreflect.ProtoMessage) { - switch msgType { +func (h *evmResponseHandler) ProcessResponseMessage( + ctx context.Context, + requestMsg *types.Message, + responseMsg *types.Message, +) { + switch requestMsg.Type { case generated.MintServiceV1Request: // distributor will post-process a mint request to buy the returned NFT - if h.handleMintRequestV1(ctx, response) { - return // TODO @evlekht we don't need this if true/false then do nothing - } - case generated.MintServiceV1Response: // supplier will act upon receiving a mint response by minting an NFT - if h.handleMintResponseV1(ctx, response, request) { - return // TODO @evlekht we don't need this if true/false then do nothing - } + h.processMintResponseV1(ctx, responseMsg.Content) case generated.MintServiceV2Request: // distributor will post-process a mint request to buy the returned NFT - if h.handleMintRequestV2(ctx, response) { - return // TODO @evlekht we don't need this if true/false then do nothing - } - case generated.MintServiceV2Response: // supplier will act upon receiving a mint response by minting an NFT - if h.handleMintResponseV2(ctx, response, request) { - return // TODO @evlekht we don't need this if true/false then do nothing - } + h.processMintResponseV2(ctx, responseMsg.Content) + } +} + +func (h *evmResponseHandler) PrepareResponseMessage( + ctx context.Context, + requestMsg *types.Message, + responseMsg *types.Message, +) { + switch response := responseMsg.Content.(type) { + case *bookv1.MintResponse: // supplier will act upon receiving a mint response by minting an NFT + h.prepareMintResponseV1(ctx, response, requestMsg.Content) + case *bookv2.MintResponse: // supplier will act upon receiving a mint response by minting an NFT + h.prepareMintResponseV2(ctx, response, requestMsg.Content) } } -func (h *evmResponseHandler) HandleRequest(_ context.Context, msgType types.MessageType, request protoreflect.ProtoMessage) error { +func (h *evmResponseHandler) PrepareRequest(msgType types.MessageType, request protoreflect.ProtoMessage) error { switch msgType { case generated.MintServiceV2Request: mintReq, ok := request.(*bookv2.MintRequest) diff --git a/internal/messaging/types/types.go b/internal/messaging/types/types.go index 9b8c01a9..66e3dc9d 100644 --- a/internal/messaging/types/types.go +++ b/internal/messaging/types/types.go @@ -15,9 +15,9 @@ var ErrUnknownMessageType = errors.New("unknown message type") type MessageCategory byte const ( - Request MessageCategory = iota + Unknown MessageCategory = iota + Request Response - Unknown ) // Always has to be in the format . @@ -47,10 +47,11 @@ func ServiceNameToRequestMessageType(serviceName string) MessageType { // Message is the message format used for communication between the messenger and the service type Message struct { - Type MessageType `json:"msgtype"` - Content protoreflect.ProtoMessage `json:"content"` - Metadata metadata.Metadata `json:"metadata"` - Sender id.UserID + Type MessageType `json:"msgtype"` + Content protoreflect.ProtoMessage `json:"content"` + Metadata metadata.Metadata `json:"metadata"` + Sender id.UserID // TODO@ ensure that its not marshalled + CompressedContent [][]byte // TODO@ ensure that its not marshalled } func (m *Message) MarshalContent() ([]byte, error) { diff --git a/internal/rpc/rpc.go b/internal/rpc/rpc.go index 7cca7961..827ca685 100644 --- a/internal/rpc/rpc.go +++ b/internal/rpc/rpc.go @@ -8,8 +8,8 @@ import ( "google.golang.org/protobuf/reflect/protoreflect" ) -type ExternalRequestProcessor interface { - ProcessExternalRequest(ctx context.Context, requestType types.MessageType, request protoreflect.ProtoMessage) (protoreflect.ProtoMessage, error) +type RequestHandler interface { + HandleRequest(ctx context.Context, requestType types.MessageType, request protoreflect.ProtoMessage) (protoreflect.ProtoMessage, error) } type Client interface { diff --git a/internal/rpc/server/server.go b/internal/rpc/server/server.go index 6224f19c..a3966bd3 100644 --- a/internal/rpc/server/server.go +++ b/internal/rpc/server/server.go @@ -21,8 +21,8 @@ import ( ) var ( - _ Server = (*server)(nil) - _ rpc.ExternalRequestProcessor = (*server)(nil) + _ Server = (*server)(nil) + _ rpc.RequestHandler = (*server)(nil) ) type Server interface { @@ -35,7 +35,7 @@ func NewServer( cfg config.RPCServerConfig, logger *zap.SugaredLogger, tracer tracing.Tracer, - processor messaging.Processor, + processor messaging.MessageProcessor, serviceRegistry messaging.ServiceRegistry, ) (Server, error) { if !cfg.Enabled { @@ -69,7 +69,7 @@ type server struct { cfg config.RPCServerConfig logger *zap.SugaredLogger tracer tracing.Tracer - processor messaging.Processor + processor messaging.MessageProcessor serviceRegistry messaging.ServiceRegistry } @@ -90,20 +90,22 @@ func (s *server) Stop() { s.grpcServer.Stop() } -func (s *server) ProcessExternalRequest(ctx context.Context, requestType types.MessageType, request protoreflect.ProtoMessage) (protoreflect.ProtoMessage, error) { - ctx, span := s.tracer.Start(ctx, "server.processExternalRequest", trace.WithSpanKind(trace.SpanKindServer)) +func (s *server) HandleRequest(ctx context.Context, requestType types.MessageType, request protoreflect.ProtoMessage) (protoreflect.ProtoMessage, error) { + ctx, span := s.tracer.Start(ctx, "server.HandleRequest", trace.WithSpanKind(trace.SpanKindServer)) defer span.End() + // TODO@ have our own requestID generation instead of using id generated by tracer? + // TODO@ if tracing is disabled, noop tracer is used and it generates random traceID with crypto.Rand + // TODO@ also, traceID is 16 bytes long, is it enough? md, err := s.processMetadata(ctx, s.tracer.TraceIDForSpan(span)) if err != nil { return nil, fmt.Errorf("error processing metadata: %w", err) } - m := &types.Message{ + response, err := s.processor.SendRequestMessage(ctx, &types.Message{ Type: requestType, Content: request, Metadata: md, - } - response, err := s.processor.ProcessOutbound(ctx, m) + }) if err != nil { return nil, fmt.Errorf("error processing outbound request: %w", err) } diff --git a/pkg/cm_accounts/cm_accounts.go b/pkg/cm_accounts/cm_accounts.go index 02031525..c1eece17 100644 --- a/pkg/cm_accounts/cm_accounts.go +++ b/pkg/cm_accounts/cm_accounts.go @@ -20,11 +20,13 @@ import ( var ( _ Service = &service{} + bigZero = big.NewInt(0) chequeOperatorRole = crypto.Keccak256Hash([]byte("CHEQUE_OPERATOR_ROLE")) ) type Service interface { GetChequeOperators(ctx context.Context, cmAccountAddress common.Address) ([]common.Address, error) + GetFirstChequeOperator(ctx context.Context, cmAccountAddress common.Address) (common.Address, error) VerifyCheque(ctx context.Context, cheque *cheques.SignedCheque) (bool, error) @@ -130,6 +132,32 @@ func (s *service) GetChequeOperators(ctx context.Context, cmAccountAddress commo return botsAddresses, nil } +func (s *service) GetFirstChequeOperator(ctx context.Context, cmAccountAddress common.Address) (common.Address, error) { + cmAccount, err := s.cmAccount(cmAccountAddress) + if err != nil { + s.logger.Errorf("Failed to get cm account: %v", err) + return common.Address{}, err + } + + countBig, err := cmAccount.GetRoleMemberCount(&bind.CallOpts{Context: ctx}, chequeOperatorRole) + if err != nil { + s.logger.Errorf("Failed to get role member count: %v", err) + return common.Address{}, err + } + + if countBig.Cmp(bigZero) <= 0 { // count <= 0 + s.logger.Error("No cheque operators found") + return common.Address{}, nil + } + + botsAddress, err := cmAccount.GetRoleMember(&bind.CallOpts{Context: ctx}, chequeOperatorRole, big.NewInt(0)) + if err != nil { + s.logger.Errorf("Failed to get role member: %v", err) + return common.Address{}, err + } + return botsAddress, nil +} + func (s *service) CashInCheque( ctx context.Context, cheque *cheques.SignedCheque, diff --git a/scripts/generate_grpc_service_handlers.sh b/scripts/generate_grpc_service_handlers.sh index a30782ca..0f90da72 100755 --- a/scripts/generate_grpc_service_handlers.sh +++ b/scripts/generate_grpc_service_handlers.sh @@ -13,7 +13,7 @@ UNMARSHALLING_FILE="${GEN_OUTPATH}/unmarshal.go" DEFAULT_BLACKLIST="notification" # we don't want to generate handlers for notifications - if we ever need more filters here the impl. need to change! -SCRIPT=$0 +SCRIPT=$(realpath --relative-to="${PWD}" "$0") FILTER=$1 #optional filter for files -- used for testing function generate_with_templates() { @@ -106,9 +106,9 @@ function generate_register_services_server() { echo " \"google.golang.org/grpc\"" >> $OUTFILE echo ")" >> $OUTFILE echo >> $OUTFILE - echo "func RegisterServerServices(grpcServer *grpc.Server, reqProcessor rpc.ExternalRequestProcessor) {" >> $OUTFILE + echo "func RegisterServerServices(grpcServer *grpc.Server, reqHandler rpc.RequestHandler) {" >> $OUTFILE for service in "${_SERVICES[@]}" ; do - echo " register${service}Server(grpcServer, reqProcessor)" >> $OUTFILE + echo " register${service}Server(grpcServer, reqHandler)" >> $OUTFILE done echo "}" >> $OUTFILE } diff --git a/scripts/mocks.mockgen.source.txt b/scripts/mocks.mockgen.source.txt index f7458543..a60c4734 100644 --- a/scripts/mocks.mockgen.source.txt +++ b/scripts/mocks.mockgen.source.txt @@ -1 +1 @@ -internal/rpc/rpc.go=ExternalRequestProcessor,Client,ServiceRegistry=internal/rpc/mock_service.go +internal/rpc/rpc.go=RequestHandler,Client,ServiceRegistry=internal/rpc/mock_service.go diff --git a/templates/server.go.tpl b/templates/server.go.tpl index 1cc01ceb..549d5b49 100644 --- a/templates/server.go.tpl +++ b/templates/server.go.tpl @@ -13,9 +13,9 @@ import ( var _ {{GRPC_PACKAGE}}.{{SERVICE}}Server = (*{{TYPE_PACKAGE}}{{SERVICE}}Server)(nil) type {{TYPE_PACKAGE}}{{SERVICE}}Server struct { - reqProcessor rpc.ExternalRequestProcessor + reqHandler rpc.RequestHandler } -func register{{SERVICE}}V{{VERSION}}Server(grpcServer *grpc.Server, reqProcessor rpc.ExternalRequestProcessor) { - {{GRPC_PACKAGE}}.Register{{SERVICE}}Server(grpcServer, &{{TYPE_PACKAGE}}{{SERVICE}}Server{reqProcessor}) +func register{{SERVICE}}V{{VERSION}}Server(grpcServer *grpc.Server, reqHandler rpc.RequestHandler) { + {{GRPC_PACKAGE}}.Register{{SERVICE}}Server(grpcServer, &{{TYPE_PACKAGE}}{{SERVICE}}Server{reqHandler}) } diff --git a/templates/server_method.go.tpl b/templates/server_method.go.tpl index a40c5d44..5cbd1ca0 100644 --- a/templates/server_method.go.tpl +++ b/templates/server_method.go.tpl @@ -11,7 +11,7 @@ import ( ) func (s *{{TYPE_PACKAGE}}{{SERVICE}}Server) {{METHOD}}(ctx context.Context, request *{{TYPE_PACKAGE}}.{{REQUEST}}) (*{{TYPE_PACKAGE}}.{{RESPONSE}}, error) { - response, err := s.reqProcessor.ProcessExternalRequest(ctx, {{SERVICE}}V{{VERSION}}Request, request) + response, err := s.reqHandler.HandleRequest(ctx, {{SERVICE}}V{{VERSION}}Request, request) if err != nil { return nil, fmt.Errorf("failed to process %s request: %w", {{SERVICE}}V{{VERSION}}Request, err) } From 84a549e1c696a1da21128501942a9433f2d37d59 Mon Sep 17 00:00:00 2001 From: "ev.lekht" Date: Thu, 21 Nov 2024 21:04:28 +0400 Subject: [PATCH 02/20] mocks --- internal/rpc/mock_service.go | 2 +- pkg/cm_accounts/mock_cm_accounts.go | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/internal/rpc/mock_service.go b/internal/rpc/mock_service.go index cf914c05..333a9a6a 100644 --- a/internal/rpc/mock_service.go +++ b/internal/rpc/mock_service.go @@ -3,7 +3,7 @@ // // Generated by this command: // -// mockgen -source=internal/rpc/rpc.go -destination=internal/rpc/mock_service.go -package=rpc -exclude_interfaces=ExternalRequestProcessor,Client,ServiceRegistry +// mockgen -source=internal/rpc/rpc.go -destination=internal/rpc/mock_service.go -package=rpc -exclude_interfaces=RequestHandler,Client,ServiceRegistry // // Package rpc is a generated GoMock package. diff --git a/pkg/cm_accounts/mock_cm_accounts.go b/pkg/cm_accounts/mock_cm_accounts.go index eb7c5080..f6a5c680 100644 --- a/pkg/cm_accounts/mock_cm_accounts.go +++ b/pkg/cm_accounts/mock_cm_accounts.go @@ -55,9 +55,9 @@ func (m *MockService) BuyBookingToken(arg0 context.Context, arg1 *bind.TransactO } // BuyBookingToken indicates an expected call of BuyBookingToken. -func (mr *MockServiceMockRecorder) BuyBookingToken(arg0, arg1, arg2, args3 any) *gomock.Call { +func (mr *MockServiceMockRecorder) BuyBookingToken(arg0, arg1, arg2, arg3 any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BuyBookingToken", reflect.TypeOf((*MockService)(nil).BuyBookingToken), arg0, arg1, arg2, args3) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BuyBookingToken", reflect.TypeOf((*MockService)(nil).BuyBookingToken), arg0, arg1, arg2, arg3) } // CashInCheque mocks base method. @@ -90,6 +90,21 @@ func (mr *MockServiceMockRecorder) GetChequeOperators(arg0, arg1 any) *gomock.Ca return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetChequeOperators", reflect.TypeOf((*MockService)(nil).GetChequeOperators), arg0, arg1) } +// GetFirstChequeOperator mocks base method. +func (m *MockService) GetFirstChequeOperator(arg0 context.Context, arg1 common.Address) (common.Address, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetFirstChequeOperator", arg0, arg1) + ret0, _ := ret[0].(common.Address) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetFirstChequeOperator indicates an expected call of GetFirstChequeOperator. +func (mr *MockServiceMockRecorder) GetFirstChequeOperator(arg0, arg1 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetFirstChequeOperator", reflect.TypeOf((*MockService)(nil).GetFirstChequeOperator), arg0, arg1) +} + // GetLastCashIn mocks base method. func (m *MockService) GetLastCashIn(arg0 context.Context, arg1, arg2, arg3 common.Address) (*big.Int, *big.Int, error) { m.ctrl.T.Helper() From b52a7925c46b24a90c85110c4195852625812f9e Mon Sep 17 00:00:00 2001 From: "ev.lekht" Date: Thu, 21 Nov 2024 21:04:46 +0400 Subject: [PATCH 03/20] generated --- ..._AccommodationProductInfo_server_method.go | 2 +- ..._AccommodationProductInfoService_server.go | 6 +- ..._AccommodationProductList_server_method.go | 2 +- ..._AccommodationProductListService_server.go | 6 +- ...rvice_AccommodationSearch_server_method.go | 2 +- ...ionv1_AccommodationSearchService_server.go | 6 +- ..._AccommodationProductInfo_server_method.go | 2 +- ..._AccommodationProductInfoService_server.go | 6 +- ..._AccommodationProductList_server_method.go | 2 +- ..._AccommodationProductListService_server.go | 6 +- ...rvice_AccommodationSearch_server_method.go | 2 +- ...ionv2_AccommodationSearchService_server.go | 6 +- ...rvice_ActivityProductInfo_server_method.go | 2 +- ...ityv1_ActivityProductInfoService_server.go | 6 +- ...rvice_ActivityProductList_server_method.go | 2 +- ...ityv1_ActivityProductListService_server.go | 6 +- ...rchService_ActivitySearch_server_method.go | 2 +- ...activityv1_ActivitySearchService_server.go | 6 +- ...rvice_ActivityProductInfo_server_method.go | 2 +- ...ityv2_ActivityProductInfoService_server.go | 6 +- ...rvice_ActivityProductList_server_method.go | 2 +- ...ityv2_ActivityProductListService_server.go | 6 +- ...rchService_ActivitySearch_server_method.go | 2 +- ...activityv2_ActivitySearchService_server.go | 6 +- .../bookv1_MintService_Mint_server_method.go | 2 +- .../generated/bookv1_MintService_server.go | 6 +- ...idationService_Validation_server_method.go | 2 +- .../bookv1_ValidationService_server.go | 6 +- .../bookv2_MintService_Mint_server_method.go | 2 +- .../generated/bookv2_MintService_server.go | 6 +- ...idationService_Validation_server_method.go | 2 +- .../bookv2_ValidationService_server.go | 6 +- ..._CountryEntryRequirements_server_method.go | 2 +- ..._CountryEntryRequirementsService_server.go | 6 +- ..._CountryEntryRequirements_server_method.go | 2 +- ..._CountryEntryRequirementsService_server.go | 6 +- ...vice_InsuranceProductInfo_server_method.go | 2 +- ...cev1_InsuranceProductInfoService_server.go | 6 +- ...vice_InsuranceProductList_server_method.go | 2 +- ...cev1_InsuranceProductListService_server.go | 6 +- ...chService_InsuranceSearch_server_method.go | 2 +- ...surancev1_InsuranceSearchService_server.go | 6 +- ...kFeeService_GetNetworkFee_server_method.go | 2 +- .../networkv1_GetNetworkFeeService_server.go | 6 +- ...e_GetPartnerConfiguration_server_method.go | 2 +- ...1_GetPartnerConfigurationService_server.go | 6 +- ...e_GetPartnerConfiguration_server_method.go | 2 +- ...2_GetPartnerConfigurationService_server.go | 6 +- .../pingv1_PingService_Ping_server_method.go | 2 +- .../generated/pingv1_PingService_server.go | 6 +- .../rpc/generated/register_server_services.go | 64 +++++++++---------- ...rvice_SeatMapAvailability_server_method.go | 2 +- ...mapv1_SeatMapAvailabilityService_server.go | 6 +- ...v1_SeatMapService_SeatMap_server_method.go | 2 +- .../seat_mapv1_SeatMapService_server.go | 6 +- ...rvice_SeatMapAvailability_server_method.go | 2 +- ...mapv2_SeatMapAvailabilityService_server.go | 6 +- ...v2_SeatMapService_SeatMap_server_method.go | 2 +- .../seat_mapv2_SeatMapService_server.go | 6 +- ...chService_TransportSearch_server_method.go | 2 +- ...ansportv1_TransportSearchService_server.go | 6 +- ...chService_TransportSearch_server_method.go | 2 +- ...ansportv2_TransportSearchService_server.go | 6 +- 63 files changed, 156 insertions(+), 156 deletions(-) diff --git a/internal/rpc/generated/accommodationv1_AccommodationProductInfoService_AccommodationProductInfo_server_method.go b/internal/rpc/generated/accommodationv1_AccommodationProductInfoService_AccommodationProductInfo_server_method.go index 0e74f224..1e487f17 100644 --- a/internal/rpc/generated/accommodationv1_AccommodationProductInfoService_AccommodationProductInfo_server_method.go +++ b/internal/rpc/generated/accommodationv1_AccommodationProductInfoService_AccommodationProductInfo_server_method.go @@ -11,7 +11,7 @@ import ( ) func (s *accommodationv1AccommodationProductInfoServiceServer) AccommodationProductInfo(ctx context.Context, request *accommodationv1.AccommodationProductInfoRequest) (*accommodationv1.AccommodationProductInfoResponse, error) { - response, err := s.reqProcessor.ProcessExternalRequest(ctx, AccommodationProductInfoServiceV1Request, request) + response, err := s.reqHandler.HandleRequest(ctx, AccommodationProductInfoServiceV1Request, request) if err != nil { return nil, fmt.Errorf("failed to process %s request: %w", AccommodationProductInfoServiceV1Request, err) } diff --git a/internal/rpc/generated/accommodationv1_AccommodationProductInfoService_server.go b/internal/rpc/generated/accommodationv1_AccommodationProductInfoService_server.go index 736cdca7..0d97fc1d 100644 --- a/internal/rpc/generated/accommodationv1_AccommodationProductInfoService_server.go +++ b/internal/rpc/generated/accommodationv1_AccommodationProductInfoService_server.go @@ -13,9 +13,9 @@ import ( var _ accommodationv1grpc.AccommodationProductInfoServiceServer = (*accommodationv1AccommodationProductInfoServiceServer)(nil) type accommodationv1AccommodationProductInfoServiceServer struct { - reqProcessor rpc.ExternalRequestProcessor + reqHandler rpc.RequestHandler } -func registerAccommodationProductInfoServiceV1Server(grpcServer *grpc.Server, reqProcessor rpc.ExternalRequestProcessor) { - accommodationv1grpc.RegisterAccommodationProductInfoServiceServer(grpcServer, &accommodationv1AccommodationProductInfoServiceServer{reqProcessor}) +func registerAccommodationProductInfoServiceV1Server(grpcServer *grpc.Server, reqHandler rpc.RequestHandler) { + accommodationv1grpc.RegisterAccommodationProductInfoServiceServer(grpcServer, &accommodationv1AccommodationProductInfoServiceServer{reqHandler}) } diff --git a/internal/rpc/generated/accommodationv1_AccommodationProductListService_AccommodationProductList_server_method.go b/internal/rpc/generated/accommodationv1_AccommodationProductListService_AccommodationProductList_server_method.go index 7cb97b4e..66ff8d59 100644 --- a/internal/rpc/generated/accommodationv1_AccommodationProductListService_AccommodationProductList_server_method.go +++ b/internal/rpc/generated/accommodationv1_AccommodationProductListService_AccommodationProductList_server_method.go @@ -11,7 +11,7 @@ import ( ) func (s *accommodationv1AccommodationProductListServiceServer) AccommodationProductList(ctx context.Context, request *accommodationv1.AccommodationProductListRequest) (*accommodationv1.AccommodationProductListResponse, error) { - response, err := s.reqProcessor.ProcessExternalRequest(ctx, AccommodationProductListServiceV1Request, request) + response, err := s.reqHandler.HandleRequest(ctx, AccommodationProductListServiceV1Request, request) if err != nil { return nil, fmt.Errorf("failed to process %s request: %w", AccommodationProductListServiceV1Request, err) } diff --git a/internal/rpc/generated/accommodationv1_AccommodationProductListService_server.go b/internal/rpc/generated/accommodationv1_AccommodationProductListService_server.go index 6a593dcb..d877d454 100644 --- a/internal/rpc/generated/accommodationv1_AccommodationProductListService_server.go +++ b/internal/rpc/generated/accommodationv1_AccommodationProductListService_server.go @@ -13,9 +13,9 @@ import ( var _ accommodationv1grpc.AccommodationProductListServiceServer = (*accommodationv1AccommodationProductListServiceServer)(nil) type accommodationv1AccommodationProductListServiceServer struct { - reqProcessor rpc.ExternalRequestProcessor + reqHandler rpc.RequestHandler } -func registerAccommodationProductListServiceV1Server(grpcServer *grpc.Server, reqProcessor rpc.ExternalRequestProcessor) { - accommodationv1grpc.RegisterAccommodationProductListServiceServer(grpcServer, &accommodationv1AccommodationProductListServiceServer{reqProcessor}) +func registerAccommodationProductListServiceV1Server(grpcServer *grpc.Server, reqHandler rpc.RequestHandler) { + accommodationv1grpc.RegisterAccommodationProductListServiceServer(grpcServer, &accommodationv1AccommodationProductListServiceServer{reqHandler}) } diff --git a/internal/rpc/generated/accommodationv1_AccommodationSearchService_AccommodationSearch_server_method.go b/internal/rpc/generated/accommodationv1_AccommodationSearchService_AccommodationSearch_server_method.go index 219bda74..6cd60984 100644 --- a/internal/rpc/generated/accommodationv1_AccommodationSearchService_AccommodationSearch_server_method.go +++ b/internal/rpc/generated/accommodationv1_AccommodationSearchService_AccommodationSearch_server_method.go @@ -11,7 +11,7 @@ import ( ) func (s *accommodationv1AccommodationSearchServiceServer) AccommodationSearch(ctx context.Context, request *accommodationv1.AccommodationSearchRequest) (*accommodationv1.AccommodationSearchResponse, error) { - response, err := s.reqProcessor.ProcessExternalRequest(ctx, AccommodationSearchServiceV1Request, request) + response, err := s.reqHandler.HandleRequest(ctx, AccommodationSearchServiceV1Request, request) if err != nil { return nil, fmt.Errorf("failed to process %s request: %w", AccommodationSearchServiceV1Request, err) } diff --git a/internal/rpc/generated/accommodationv1_AccommodationSearchService_server.go b/internal/rpc/generated/accommodationv1_AccommodationSearchService_server.go index e5e6c0e7..d8e03c01 100644 --- a/internal/rpc/generated/accommodationv1_AccommodationSearchService_server.go +++ b/internal/rpc/generated/accommodationv1_AccommodationSearchService_server.go @@ -13,9 +13,9 @@ import ( var _ accommodationv1grpc.AccommodationSearchServiceServer = (*accommodationv1AccommodationSearchServiceServer)(nil) type accommodationv1AccommodationSearchServiceServer struct { - reqProcessor rpc.ExternalRequestProcessor + reqHandler rpc.RequestHandler } -func registerAccommodationSearchServiceV1Server(grpcServer *grpc.Server, reqProcessor rpc.ExternalRequestProcessor) { - accommodationv1grpc.RegisterAccommodationSearchServiceServer(grpcServer, &accommodationv1AccommodationSearchServiceServer{reqProcessor}) +func registerAccommodationSearchServiceV1Server(grpcServer *grpc.Server, reqHandler rpc.RequestHandler) { + accommodationv1grpc.RegisterAccommodationSearchServiceServer(grpcServer, &accommodationv1AccommodationSearchServiceServer{reqHandler}) } diff --git a/internal/rpc/generated/accommodationv2_AccommodationProductInfoService_AccommodationProductInfo_server_method.go b/internal/rpc/generated/accommodationv2_AccommodationProductInfoService_AccommodationProductInfo_server_method.go index 00920afb..b325e1da 100644 --- a/internal/rpc/generated/accommodationv2_AccommodationProductInfoService_AccommodationProductInfo_server_method.go +++ b/internal/rpc/generated/accommodationv2_AccommodationProductInfoService_AccommodationProductInfo_server_method.go @@ -11,7 +11,7 @@ import ( ) func (s *accommodationv2AccommodationProductInfoServiceServer) AccommodationProductInfo(ctx context.Context, request *accommodationv2.AccommodationProductInfoRequest) (*accommodationv2.AccommodationProductInfoResponse, error) { - response, err := s.reqProcessor.ProcessExternalRequest(ctx, AccommodationProductInfoServiceV2Request, request) + response, err := s.reqHandler.HandleRequest(ctx, AccommodationProductInfoServiceV2Request, request) if err != nil { return nil, fmt.Errorf("failed to process %s request: %w", AccommodationProductInfoServiceV2Request, err) } diff --git a/internal/rpc/generated/accommodationv2_AccommodationProductInfoService_server.go b/internal/rpc/generated/accommodationv2_AccommodationProductInfoService_server.go index 87cc92ab..fc6c99e9 100644 --- a/internal/rpc/generated/accommodationv2_AccommodationProductInfoService_server.go +++ b/internal/rpc/generated/accommodationv2_AccommodationProductInfoService_server.go @@ -13,9 +13,9 @@ import ( var _ accommodationv2grpc.AccommodationProductInfoServiceServer = (*accommodationv2AccommodationProductInfoServiceServer)(nil) type accommodationv2AccommodationProductInfoServiceServer struct { - reqProcessor rpc.ExternalRequestProcessor + reqHandler rpc.RequestHandler } -func registerAccommodationProductInfoServiceV2Server(grpcServer *grpc.Server, reqProcessor rpc.ExternalRequestProcessor) { - accommodationv2grpc.RegisterAccommodationProductInfoServiceServer(grpcServer, &accommodationv2AccommodationProductInfoServiceServer{reqProcessor}) +func registerAccommodationProductInfoServiceV2Server(grpcServer *grpc.Server, reqHandler rpc.RequestHandler) { + accommodationv2grpc.RegisterAccommodationProductInfoServiceServer(grpcServer, &accommodationv2AccommodationProductInfoServiceServer{reqHandler}) } diff --git a/internal/rpc/generated/accommodationv2_AccommodationProductListService_AccommodationProductList_server_method.go b/internal/rpc/generated/accommodationv2_AccommodationProductListService_AccommodationProductList_server_method.go index f9cbd032..4b3a235b 100644 --- a/internal/rpc/generated/accommodationv2_AccommodationProductListService_AccommodationProductList_server_method.go +++ b/internal/rpc/generated/accommodationv2_AccommodationProductListService_AccommodationProductList_server_method.go @@ -11,7 +11,7 @@ import ( ) func (s *accommodationv2AccommodationProductListServiceServer) AccommodationProductList(ctx context.Context, request *accommodationv2.AccommodationProductListRequest) (*accommodationv2.AccommodationProductListResponse, error) { - response, err := s.reqProcessor.ProcessExternalRequest(ctx, AccommodationProductListServiceV2Request, request) + response, err := s.reqHandler.HandleRequest(ctx, AccommodationProductListServiceV2Request, request) if err != nil { return nil, fmt.Errorf("failed to process %s request: %w", AccommodationProductListServiceV2Request, err) } diff --git a/internal/rpc/generated/accommodationv2_AccommodationProductListService_server.go b/internal/rpc/generated/accommodationv2_AccommodationProductListService_server.go index f8c8ade3..bfd71fe1 100644 --- a/internal/rpc/generated/accommodationv2_AccommodationProductListService_server.go +++ b/internal/rpc/generated/accommodationv2_AccommodationProductListService_server.go @@ -13,9 +13,9 @@ import ( var _ accommodationv2grpc.AccommodationProductListServiceServer = (*accommodationv2AccommodationProductListServiceServer)(nil) type accommodationv2AccommodationProductListServiceServer struct { - reqProcessor rpc.ExternalRequestProcessor + reqHandler rpc.RequestHandler } -func registerAccommodationProductListServiceV2Server(grpcServer *grpc.Server, reqProcessor rpc.ExternalRequestProcessor) { - accommodationv2grpc.RegisterAccommodationProductListServiceServer(grpcServer, &accommodationv2AccommodationProductListServiceServer{reqProcessor}) +func registerAccommodationProductListServiceV2Server(grpcServer *grpc.Server, reqHandler rpc.RequestHandler) { + accommodationv2grpc.RegisterAccommodationProductListServiceServer(grpcServer, &accommodationv2AccommodationProductListServiceServer{reqHandler}) } diff --git a/internal/rpc/generated/accommodationv2_AccommodationSearchService_AccommodationSearch_server_method.go b/internal/rpc/generated/accommodationv2_AccommodationSearchService_AccommodationSearch_server_method.go index f67f9362..444ce480 100644 --- a/internal/rpc/generated/accommodationv2_AccommodationSearchService_AccommodationSearch_server_method.go +++ b/internal/rpc/generated/accommodationv2_AccommodationSearchService_AccommodationSearch_server_method.go @@ -11,7 +11,7 @@ import ( ) func (s *accommodationv2AccommodationSearchServiceServer) AccommodationSearch(ctx context.Context, request *accommodationv2.AccommodationSearchRequest) (*accommodationv2.AccommodationSearchResponse, error) { - response, err := s.reqProcessor.ProcessExternalRequest(ctx, AccommodationSearchServiceV2Request, request) + response, err := s.reqHandler.HandleRequest(ctx, AccommodationSearchServiceV2Request, request) if err != nil { return nil, fmt.Errorf("failed to process %s request: %w", AccommodationSearchServiceV2Request, err) } diff --git a/internal/rpc/generated/accommodationv2_AccommodationSearchService_server.go b/internal/rpc/generated/accommodationv2_AccommodationSearchService_server.go index 98d798e3..58962c97 100644 --- a/internal/rpc/generated/accommodationv2_AccommodationSearchService_server.go +++ b/internal/rpc/generated/accommodationv2_AccommodationSearchService_server.go @@ -13,9 +13,9 @@ import ( var _ accommodationv2grpc.AccommodationSearchServiceServer = (*accommodationv2AccommodationSearchServiceServer)(nil) type accommodationv2AccommodationSearchServiceServer struct { - reqProcessor rpc.ExternalRequestProcessor + reqHandler rpc.RequestHandler } -func registerAccommodationSearchServiceV2Server(grpcServer *grpc.Server, reqProcessor rpc.ExternalRequestProcessor) { - accommodationv2grpc.RegisterAccommodationSearchServiceServer(grpcServer, &accommodationv2AccommodationSearchServiceServer{reqProcessor}) +func registerAccommodationSearchServiceV2Server(grpcServer *grpc.Server, reqHandler rpc.RequestHandler) { + accommodationv2grpc.RegisterAccommodationSearchServiceServer(grpcServer, &accommodationv2AccommodationSearchServiceServer{reqHandler}) } diff --git a/internal/rpc/generated/activityv1_ActivityProductInfoService_ActivityProductInfo_server_method.go b/internal/rpc/generated/activityv1_ActivityProductInfoService_ActivityProductInfo_server_method.go index 82e8ed47..90294503 100644 --- a/internal/rpc/generated/activityv1_ActivityProductInfoService_ActivityProductInfo_server_method.go +++ b/internal/rpc/generated/activityv1_ActivityProductInfoService_ActivityProductInfo_server_method.go @@ -11,7 +11,7 @@ import ( ) func (s *activityv1ActivityProductInfoServiceServer) ActivityProductInfo(ctx context.Context, request *activityv1.ActivityProductInfoRequest) (*activityv1.ActivityProductInfoResponse, error) { - response, err := s.reqProcessor.ProcessExternalRequest(ctx, ActivityProductInfoServiceV1Request, request) + response, err := s.reqHandler.HandleRequest(ctx, ActivityProductInfoServiceV1Request, request) if err != nil { return nil, fmt.Errorf("failed to process %s request: %w", ActivityProductInfoServiceV1Request, err) } diff --git a/internal/rpc/generated/activityv1_ActivityProductInfoService_server.go b/internal/rpc/generated/activityv1_ActivityProductInfoService_server.go index 530dfcad..73c8df74 100644 --- a/internal/rpc/generated/activityv1_ActivityProductInfoService_server.go +++ b/internal/rpc/generated/activityv1_ActivityProductInfoService_server.go @@ -13,9 +13,9 @@ import ( var _ activityv1grpc.ActivityProductInfoServiceServer = (*activityv1ActivityProductInfoServiceServer)(nil) type activityv1ActivityProductInfoServiceServer struct { - reqProcessor rpc.ExternalRequestProcessor + reqHandler rpc.RequestHandler } -func registerActivityProductInfoServiceV1Server(grpcServer *grpc.Server, reqProcessor rpc.ExternalRequestProcessor) { - activityv1grpc.RegisterActivityProductInfoServiceServer(grpcServer, &activityv1ActivityProductInfoServiceServer{reqProcessor}) +func registerActivityProductInfoServiceV1Server(grpcServer *grpc.Server, reqHandler rpc.RequestHandler) { + activityv1grpc.RegisterActivityProductInfoServiceServer(grpcServer, &activityv1ActivityProductInfoServiceServer{reqHandler}) } diff --git a/internal/rpc/generated/activityv1_ActivityProductListService_ActivityProductList_server_method.go b/internal/rpc/generated/activityv1_ActivityProductListService_ActivityProductList_server_method.go index 4097dda3..facad8dd 100644 --- a/internal/rpc/generated/activityv1_ActivityProductListService_ActivityProductList_server_method.go +++ b/internal/rpc/generated/activityv1_ActivityProductListService_ActivityProductList_server_method.go @@ -11,7 +11,7 @@ import ( ) func (s *activityv1ActivityProductListServiceServer) ActivityProductList(ctx context.Context, request *activityv1.ActivityProductListRequest) (*activityv1.ActivityProductListResponse, error) { - response, err := s.reqProcessor.ProcessExternalRequest(ctx, ActivityProductListServiceV1Request, request) + response, err := s.reqHandler.HandleRequest(ctx, ActivityProductListServiceV1Request, request) if err != nil { return nil, fmt.Errorf("failed to process %s request: %w", ActivityProductListServiceV1Request, err) } diff --git a/internal/rpc/generated/activityv1_ActivityProductListService_server.go b/internal/rpc/generated/activityv1_ActivityProductListService_server.go index 9baf6237..8b5a04cc 100644 --- a/internal/rpc/generated/activityv1_ActivityProductListService_server.go +++ b/internal/rpc/generated/activityv1_ActivityProductListService_server.go @@ -13,9 +13,9 @@ import ( var _ activityv1grpc.ActivityProductListServiceServer = (*activityv1ActivityProductListServiceServer)(nil) type activityv1ActivityProductListServiceServer struct { - reqProcessor rpc.ExternalRequestProcessor + reqHandler rpc.RequestHandler } -func registerActivityProductListServiceV1Server(grpcServer *grpc.Server, reqProcessor rpc.ExternalRequestProcessor) { - activityv1grpc.RegisterActivityProductListServiceServer(grpcServer, &activityv1ActivityProductListServiceServer{reqProcessor}) +func registerActivityProductListServiceV1Server(grpcServer *grpc.Server, reqHandler rpc.RequestHandler) { + activityv1grpc.RegisterActivityProductListServiceServer(grpcServer, &activityv1ActivityProductListServiceServer{reqHandler}) } diff --git a/internal/rpc/generated/activityv1_ActivitySearchService_ActivitySearch_server_method.go b/internal/rpc/generated/activityv1_ActivitySearchService_ActivitySearch_server_method.go index 327772cd..b3691610 100644 --- a/internal/rpc/generated/activityv1_ActivitySearchService_ActivitySearch_server_method.go +++ b/internal/rpc/generated/activityv1_ActivitySearchService_ActivitySearch_server_method.go @@ -11,7 +11,7 @@ import ( ) func (s *activityv1ActivitySearchServiceServer) ActivitySearch(ctx context.Context, request *activityv1.ActivitySearchRequest) (*activityv1.ActivitySearchResponse, error) { - response, err := s.reqProcessor.ProcessExternalRequest(ctx, ActivitySearchServiceV1Request, request) + response, err := s.reqHandler.HandleRequest(ctx, ActivitySearchServiceV1Request, request) if err != nil { return nil, fmt.Errorf("failed to process %s request: %w", ActivitySearchServiceV1Request, err) } diff --git a/internal/rpc/generated/activityv1_ActivitySearchService_server.go b/internal/rpc/generated/activityv1_ActivitySearchService_server.go index d417785e..2bf5296f 100644 --- a/internal/rpc/generated/activityv1_ActivitySearchService_server.go +++ b/internal/rpc/generated/activityv1_ActivitySearchService_server.go @@ -13,9 +13,9 @@ import ( var _ activityv1grpc.ActivitySearchServiceServer = (*activityv1ActivitySearchServiceServer)(nil) type activityv1ActivitySearchServiceServer struct { - reqProcessor rpc.ExternalRequestProcessor + reqHandler rpc.RequestHandler } -func registerActivitySearchServiceV1Server(grpcServer *grpc.Server, reqProcessor rpc.ExternalRequestProcessor) { - activityv1grpc.RegisterActivitySearchServiceServer(grpcServer, &activityv1ActivitySearchServiceServer{reqProcessor}) +func registerActivitySearchServiceV1Server(grpcServer *grpc.Server, reqHandler rpc.RequestHandler) { + activityv1grpc.RegisterActivitySearchServiceServer(grpcServer, &activityv1ActivitySearchServiceServer{reqHandler}) } diff --git a/internal/rpc/generated/activityv2_ActivityProductInfoService_ActivityProductInfo_server_method.go b/internal/rpc/generated/activityv2_ActivityProductInfoService_ActivityProductInfo_server_method.go index 73cc14b9..806d4f72 100644 --- a/internal/rpc/generated/activityv2_ActivityProductInfoService_ActivityProductInfo_server_method.go +++ b/internal/rpc/generated/activityv2_ActivityProductInfoService_ActivityProductInfo_server_method.go @@ -11,7 +11,7 @@ import ( ) func (s *activityv2ActivityProductInfoServiceServer) ActivityProductInfo(ctx context.Context, request *activityv2.ActivityProductInfoRequest) (*activityv2.ActivityProductInfoResponse, error) { - response, err := s.reqProcessor.ProcessExternalRequest(ctx, ActivityProductInfoServiceV2Request, request) + response, err := s.reqHandler.HandleRequest(ctx, ActivityProductInfoServiceV2Request, request) if err != nil { return nil, fmt.Errorf("failed to process %s request: %w", ActivityProductInfoServiceV2Request, err) } diff --git a/internal/rpc/generated/activityv2_ActivityProductInfoService_server.go b/internal/rpc/generated/activityv2_ActivityProductInfoService_server.go index a66d4d44..1f712c0b 100644 --- a/internal/rpc/generated/activityv2_ActivityProductInfoService_server.go +++ b/internal/rpc/generated/activityv2_ActivityProductInfoService_server.go @@ -13,9 +13,9 @@ import ( var _ activityv2grpc.ActivityProductInfoServiceServer = (*activityv2ActivityProductInfoServiceServer)(nil) type activityv2ActivityProductInfoServiceServer struct { - reqProcessor rpc.ExternalRequestProcessor + reqHandler rpc.RequestHandler } -func registerActivityProductInfoServiceV2Server(grpcServer *grpc.Server, reqProcessor rpc.ExternalRequestProcessor) { - activityv2grpc.RegisterActivityProductInfoServiceServer(grpcServer, &activityv2ActivityProductInfoServiceServer{reqProcessor}) +func registerActivityProductInfoServiceV2Server(grpcServer *grpc.Server, reqHandler rpc.RequestHandler) { + activityv2grpc.RegisterActivityProductInfoServiceServer(grpcServer, &activityv2ActivityProductInfoServiceServer{reqHandler}) } diff --git a/internal/rpc/generated/activityv2_ActivityProductListService_ActivityProductList_server_method.go b/internal/rpc/generated/activityv2_ActivityProductListService_ActivityProductList_server_method.go index 79b0627b..d2de6b2e 100644 --- a/internal/rpc/generated/activityv2_ActivityProductListService_ActivityProductList_server_method.go +++ b/internal/rpc/generated/activityv2_ActivityProductListService_ActivityProductList_server_method.go @@ -11,7 +11,7 @@ import ( ) func (s *activityv2ActivityProductListServiceServer) ActivityProductList(ctx context.Context, request *activityv2.ActivityProductListRequest) (*activityv2.ActivityProductListResponse, error) { - response, err := s.reqProcessor.ProcessExternalRequest(ctx, ActivityProductListServiceV2Request, request) + response, err := s.reqHandler.HandleRequest(ctx, ActivityProductListServiceV2Request, request) if err != nil { return nil, fmt.Errorf("failed to process %s request: %w", ActivityProductListServiceV2Request, err) } diff --git a/internal/rpc/generated/activityv2_ActivityProductListService_server.go b/internal/rpc/generated/activityv2_ActivityProductListService_server.go index c62d69d1..63779139 100644 --- a/internal/rpc/generated/activityv2_ActivityProductListService_server.go +++ b/internal/rpc/generated/activityv2_ActivityProductListService_server.go @@ -13,9 +13,9 @@ import ( var _ activityv2grpc.ActivityProductListServiceServer = (*activityv2ActivityProductListServiceServer)(nil) type activityv2ActivityProductListServiceServer struct { - reqProcessor rpc.ExternalRequestProcessor + reqHandler rpc.RequestHandler } -func registerActivityProductListServiceV2Server(grpcServer *grpc.Server, reqProcessor rpc.ExternalRequestProcessor) { - activityv2grpc.RegisterActivityProductListServiceServer(grpcServer, &activityv2ActivityProductListServiceServer{reqProcessor}) +func registerActivityProductListServiceV2Server(grpcServer *grpc.Server, reqHandler rpc.RequestHandler) { + activityv2grpc.RegisterActivityProductListServiceServer(grpcServer, &activityv2ActivityProductListServiceServer{reqHandler}) } diff --git a/internal/rpc/generated/activityv2_ActivitySearchService_ActivitySearch_server_method.go b/internal/rpc/generated/activityv2_ActivitySearchService_ActivitySearch_server_method.go index fb506536..2b35c283 100644 --- a/internal/rpc/generated/activityv2_ActivitySearchService_ActivitySearch_server_method.go +++ b/internal/rpc/generated/activityv2_ActivitySearchService_ActivitySearch_server_method.go @@ -11,7 +11,7 @@ import ( ) func (s *activityv2ActivitySearchServiceServer) ActivitySearch(ctx context.Context, request *activityv2.ActivitySearchRequest) (*activityv2.ActivitySearchResponse, error) { - response, err := s.reqProcessor.ProcessExternalRequest(ctx, ActivitySearchServiceV2Request, request) + response, err := s.reqHandler.HandleRequest(ctx, ActivitySearchServiceV2Request, request) if err != nil { return nil, fmt.Errorf("failed to process %s request: %w", ActivitySearchServiceV2Request, err) } diff --git a/internal/rpc/generated/activityv2_ActivitySearchService_server.go b/internal/rpc/generated/activityv2_ActivitySearchService_server.go index 5cec3b42..6ed5abc1 100644 --- a/internal/rpc/generated/activityv2_ActivitySearchService_server.go +++ b/internal/rpc/generated/activityv2_ActivitySearchService_server.go @@ -13,9 +13,9 @@ import ( var _ activityv2grpc.ActivitySearchServiceServer = (*activityv2ActivitySearchServiceServer)(nil) type activityv2ActivitySearchServiceServer struct { - reqProcessor rpc.ExternalRequestProcessor + reqHandler rpc.RequestHandler } -func registerActivitySearchServiceV2Server(grpcServer *grpc.Server, reqProcessor rpc.ExternalRequestProcessor) { - activityv2grpc.RegisterActivitySearchServiceServer(grpcServer, &activityv2ActivitySearchServiceServer{reqProcessor}) +func registerActivitySearchServiceV2Server(grpcServer *grpc.Server, reqHandler rpc.RequestHandler) { + activityv2grpc.RegisterActivitySearchServiceServer(grpcServer, &activityv2ActivitySearchServiceServer{reqHandler}) } diff --git a/internal/rpc/generated/bookv1_MintService_Mint_server_method.go b/internal/rpc/generated/bookv1_MintService_Mint_server_method.go index 3dbc05ba..1bd5de5b 100644 --- a/internal/rpc/generated/bookv1_MintService_Mint_server_method.go +++ b/internal/rpc/generated/bookv1_MintService_Mint_server_method.go @@ -11,7 +11,7 @@ import ( ) func (s *bookv1MintServiceServer) Mint(ctx context.Context, request *bookv1.MintRequest) (*bookv1.MintResponse, error) { - response, err := s.reqProcessor.ProcessExternalRequest(ctx, MintServiceV1Request, request) + response, err := s.reqHandler.HandleRequest(ctx, MintServiceV1Request, request) if err != nil { return nil, fmt.Errorf("failed to process %s request: %w", MintServiceV1Request, err) } diff --git a/internal/rpc/generated/bookv1_MintService_server.go b/internal/rpc/generated/bookv1_MintService_server.go index 67542953..42d490d0 100644 --- a/internal/rpc/generated/bookv1_MintService_server.go +++ b/internal/rpc/generated/bookv1_MintService_server.go @@ -13,9 +13,9 @@ import ( var _ bookv1grpc.MintServiceServer = (*bookv1MintServiceServer)(nil) type bookv1MintServiceServer struct { - reqProcessor rpc.ExternalRequestProcessor + reqHandler rpc.RequestHandler } -func registerMintServiceV1Server(grpcServer *grpc.Server, reqProcessor rpc.ExternalRequestProcessor) { - bookv1grpc.RegisterMintServiceServer(grpcServer, &bookv1MintServiceServer{reqProcessor}) +func registerMintServiceV1Server(grpcServer *grpc.Server, reqHandler rpc.RequestHandler) { + bookv1grpc.RegisterMintServiceServer(grpcServer, &bookv1MintServiceServer{reqHandler}) } diff --git a/internal/rpc/generated/bookv1_ValidationService_Validation_server_method.go b/internal/rpc/generated/bookv1_ValidationService_Validation_server_method.go index b4e356f9..f032daba 100644 --- a/internal/rpc/generated/bookv1_ValidationService_Validation_server_method.go +++ b/internal/rpc/generated/bookv1_ValidationService_Validation_server_method.go @@ -11,7 +11,7 @@ import ( ) func (s *bookv1ValidationServiceServer) Validation(ctx context.Context, request *bookv1.ValidationRequest) (*bookv1.ValidationResponse, error) { - response, err := s.reqProcessor.ProcessExternalRequest(ctx, ValidationServiceV1Request, request) + response, err := s.reqHandler.HandleRequest(ctx, ValidationServiceV1Request, request) if err != nil { return nil, fmt.Errorf("failed to process %s request: %w", ValidationServiceV1Request, err) } diff --git a/internal/rpc/generated/bookv1_ValidationService_server.go b/internal/rpc/generated/bookv1_ValidationService_server.go index 0af063e8..cde07bf0 100644 --- a/internal/rpc/generated/bookv1_ValidationService_server.go +++ b/internal/rpc/generated/bookv1_ValidationService_server.go @@ -13,9 +13,9 @@ import ( var _ bookv1grpc.ValidationServiceServer = (*bookv1ValidationServiceServer)(nil) type bookv1ValidationServiceServer struct { - reqProcessor rpc.ExternalRequestProcessor + reqHandler rpc.RequestHandler } -func registerValidationServiceV1Server(grpcServer *grpc.Server, reqProcessor rpc.ExternalRequestProcessor) { - bookv1grpc.RegisterValidationServiceServer(grpcServer, &bookv1ValidationServiceServer{reqProcessor}) +func registerValidationServiceV1Server(grpcServer *grpc.Server, reqHandler rpc.RequestHandler) { + bookv1grpc.RegisterValidationServiceServer(grpcServer, &bookv1ValidationServiceServer{reqHandler}) } diff --git a/internal/rpc/generated/bookv2_MintService_Mint_server_method.go b/internal/rpc/generated/bookv2_MintService_Mint_server_method.go index 122b43d6..aca14a9f 100644 --- a/internal/rpc/generated/bookv2_MintService_Mint_server_method.go +++ b/internal/rpc/generated/bookv2_MintService_Mint_server_method.go @@ -11,7 +11,7 @@ import ( ) func (s *bookv2MintServiceServer) Mint(ctx context.Context, request *bookv2.MintRequest) (*bookv2.MintResponse, error) { - response, err := s.reqProcessor.ProcessExternalRequest(ctx, MintServiceV2Request, request) + response, err := s.reqHandler.HandleRequest(ctx, MintServiceV2Request, request) if err != nil { return nil, fmt.Errorf("failed to process %s request: %w", MintServiceV2Request, err) } diff --git a/internal/rpc/generated/bookv2_MintService_server.go b/internal/rpc/generated/bookv2_MintService_server.go index 158e76b0..8760d507 100644 --- a/internal/rpc/generated/bookv2_MintService_server.go +++ b/internal/rpc/generated/bookv2_MintService_server.go @@ -13,9 +13,9 @@ import ( var _ bookv2grpc.MintServiceServer = (*bookv2MintServiceServer)(nil) type bookv2MintServiceServer struct { - reqProcessor rpc.ExternalRequestProcessor + reqHandler rpc.RequestHandler } -func registerMintServiceV2Server(grpcServer *grpc.Server, reqProcessor rpc.ExternalRequestProcessor) { - bookv2grpc.RegisterMintServiceServer(grpcServer, &bookv2MintServiceServer{reqProcessor}) +func registerMintServiceV2Server(grpcServer *grpc.Server, reqHandler rpc.RequestHandler) { + bookv2grpc.RegisterMintServiceServer(grpcServer, &bookv2MintServiceServer{reqHandler}) } diff --git a/internal/rpc/generated/bookv2_ValidationService_Validation_server_method.go b/internal/rpc/generated/bookv2_ValidationService_Validation_server_method.go index 388c5a0e..5b47c7a0 100644 --- a/internal/rpc/generated/bookv2_ValidationService_Validation_server_method.go +++ b/internal/rpc/generated/bookv2_ValidationService_Validation_server_method.go @@ -11,7 +11,7 @@ import ( ) func (s *bookv2ValidationServiceServer) Validation(ctx context.Context, request *bookv2.ValidationRequest) (*bookv2.ValidationResponse, error) { - response, err := s.reqProcessor.ProcessExternalRequest(ctx, ValidationServiceV2Request, request) + response, err := s.reqHandler.HandleRequest(ctx, ValidationServiceV2Request, request) if err != nil { return nil, fmt.Errorf("failed to process %s request: %w", ValidationServiceV2Request, err) } diff --git a/internal/rpc/generated/bookv2_ValidationService_server.go b/internal/rpc/generated/bookv2_ValidationService_server.go index 3ce59232..df1fd424 100644 --- a/internal/rpc/generated/bookv2_ValidationService_server.go +++ b/internal/rpc/generated/bookv2_ValidationService_server.go @@ -13,9 +13,9 @@ import ( var _ bookv2grpc.ValidationServiceServer = (*bookv2ValidationServiceServer)(nil) type bookv2ValidationServiceServer struct { - reqProcessor rpc.ExternalRequestProcessor + reqHandler rpc.RequestHandler } -func registerValidationServiceV2Server(grpcServer *grpc.Server, reqProcessor rpc.ExternalRequestProcessor) { - bookv2grpc.RegisterValidationServiceServer(grpcServer, &bookv2ValidationServiceServer{reqProcessor}) +func registerValidationServiceV2Server(grpcServer *grpc.Server, reqHandler rpc.RequestHandler) { + bookv2grpc.RegisterValidationServiceServer(grpcServer, &bookv2ValidationServiceServer{reqHandler}) } diff --git a/internal/rpc/generated/infov1_CountryEntryRequirementsService_CountryEntryRequirements_server_method.go b/internal/rpc/generated/infov1_CountryEntryRequirementsService_CountryEntryRequirements_server_method.go index e1e14677..d98ae52f 100644 --- a/internal/rpc/generated/infov1_CountryEntryRequirementsService_CountryEntryRequirements_server_method.go +++ b/internal/rpc/generated/infov1_CountryEntryRequirementsService_CountryEntryRequirements_server_method.go @@ -11,7 +11,7 @@ import ( ) func (s *infov1CountryEntryRequirementsServiceServer) CountryEntryRequirements(ctx context.Context, request *infov1.CountryEntryRequirementsRequest) (*infov1.CountryEntryRequirementsResponse, error) { - response, err := s.reqProcessor.ProcessExternalRequest(ctx, CountryEntryRequirementsServiceV1Request, request) + response, err := s.reqHandler.HandleRequest(ctx, CountryEntryRequirementsServiceV1Request, request) if err != nil { return nil, fmt.Errorf("failed to process %s request: %w", CountryEntryRequirementsServiceV1Request, err) } diff --git a/internal/rpc/generated/infov1_CountryEntryRequirementsService_server.go b/internal/rpc/generated/infov1_CountryEntryRequirementsService_server.go index f7d53006..0fc0cce8 100644 --- a/internal/rpc/generated/infov1_CountryEntryRequirementsService_server.go +++ b/internal/rpc/generated/infov1_CountryEntryRequirementsService_server.go @@ -13,9 +13,9 @@ import ( var _ infov1grpc.CountryEntryRequirementsServiceServer = (*infov1CountryEntryRequirementsServiceServer)(nil) type infov1CountryEntryRequirementsServiceServer struct { - reqProcessor rpc.ExternalRequestProcessor + reqHandler rpc.RequestHandler } -func registerCountryEntryRequirementsServiceV1Server(grpcServer *grpc.Server, reqProcessor rpc.ExternalRequestProcessor) { - infov1grpc.RegisterCountryEntryRequirementsServiceServer(grpcServer, &infov1CountryEntryRequirementsServiceServer{reqProcessor}) +func registerCountryEntryRequirementsServiceV1Server(grpcServer *grpc.Server, reqHandler rpc.RequestHandler) { + infov1grpc.RegisterCountryEntryRequirementsServiceServer(grpcServer, &infov1CountryEntryRequirementsServiceServer{reqHandler}) } diff --git a/internal/rpc/generated/infov2_CountryEntryRequirementsService_CountryEntryRequirements_server_method.go b/internal/rpc/generated/infov2_CountryEntryRequirementsService_CountryEntryRequirements_server_method.go index 685ae017..952f2c80 100644 --- a/internal/rpc/generated/infov2_CountryEntryRequirementsService_CountryEntryRequirements_server_method.go +++ b/internal/rpc/generated/infov2_CountryEntryRequirementsService_CountryEntryRequirements_server_method.go @@ -11,7 +11,7 @@ import ( ) func (s *infov2CountryEntryRequirementsServiceServer) CountryEntryRequirements(ctx context.Context, request *infov2.CountryEntryRequirementsRequest) (*infov2.CountryEntryRequirementsResponse, error) { - response, err := s.reqProcessor.ProcessExternalRequest(ctx, CountryEntryRequirementsServiceV2Request, request) + response, err := s.reqHandler.HandleRequest(ctx, CountryEntryRequirementsServiceV2Request, request) if err != nil { return nil, fmt.Errorf("failed to process %s request: %w", CountryEntryRequirementsServiceV2Request, err) } diff --git a/internal/rpc/generated/infov2_CountryEntryRequirementsService_server.go b/internal/rpc/generated/infov2_CountryEntryRequirementsService_server.go index 0204a3ae..695ff552 100644 --- a/internal/rpc/generated/infov2_CountryEntryRequirementsService_server.go +++ b/internal/rpc/generated/infov2_CountryEntryRequirementsService_server.go @@ -13,9 +13,9 @@ import ( var _ infov2grpc.CountryEntryRequirementsServiceServer = (*infov2CountryEntryRequirementsServiceServer)(nil) type infov2CountryEntryRequirementsServiceServer struct { - reqProcessor rpc.ExternalRequestProcessor + reqHandler rpc.RequestHandler } -func registerCountryEntryRequirementsServiceV2Server(grpcServer *grpc.Server, reqProcessor rpc.ExternalRequestProcessor) { - infov2grpc.RegisterCountryEntryRequirementsServiceServer(grpcServer, &infov2CountryEntryRequirementsServiceServer{reqProcessor}) +func registerCountryEntryRequirementsServiceV2Server(grpcServer *grpc.Server, reqHandler rpc.RequestHandler) { + infov2grpc.RegisterCountryEntryRequirementsServiceServer(grpcServer, &infov2CountryEntryRequirementsServiceServer{reqHandler}) } diff --git a/internal/rpc/generated/insurancev1_InsuranceProductInfoService_InsuranceProductInfo_server_method.go b/internal/rpc/generated/insurancev1_InsuranceProductInfoService_InsuranceProductInfo_server_method.go index e7b82d96..e6884f4a 100644 --- a/internal/rpc/generated/insurancev1_InsuranceProductInfoService_InsuranceProductInfo_server_method.go +++ b/internal/rpc/generated/insurancev1_InsuranceProductInfoService_InsuranceProductInfo_server_method.go @@ -11,7 +11,7 @@ import ( ) func (s *insurancev1InsuranceProductInfoServiceServer) InsuranceProductInfo(ctx context.Context, request *insurancev1.InsuranceProductInfoRequest) (*insurancev1.InsuranceProductInfoResponse, error) { - response, err := s.reqProcessor.ProcessExternalRequest(ctx, InsuranceProductInfoServiceV1Request, request) + response, err := s.reqHandler.HandleRequest(ctx, InsuranceProductInfoServiceV1Request, request) if err != nil { return nil, fmt.Errorf("failed to process %s request: %w", InsuranceProductInfoServiceV1Request, err) } diff --git a/internal/rpc/generated/insurancev1_InsuranceProductInfoService_server.go b/internal/rpc/generated/insurancev1_InsuranceProductInfoService_server.go index 31e7bd1b..db7824da 100644 --- a/internal/rpc/generated/insurancev1_InsuranceProductInfoService_server.go +++ b/internal/rpc/generated/insurancev1_InsuranceProductInfoService_server.go @@ -13,9 +13,9 @@ import ( var _ insurancev1grpc.InsuranceProductInfoServiceServer = (*insurancev1InsuranceProductInfoServiceServer)(nil) type insurancev1InsuranceProductInfoServiceServer struct { - reqProcessor rpc.ExternalRequestProcessor + reqHandler rpc.RequestHandler } -func registerInsuranceProductInfoServiceV1Server(grpcServer *grpc.Server, reqProcessor rpc.ExternalRequestProcessor) { - insurancev1grpc.RegisterInsuranceProductInfoServiceServer(grpcServer, &insurancev1InsuranceProductInfoServiceServer{reqProcessor}) +func registerInsuranceProductInfoServiceV1Server(grpcServer *grpc.Server, reqHandler rpc.RequestHandler) { + insurancev1grpc.RegisterInsuranceProductInfoServiceServer(grpcServer, &insurancev1InsuranceProductInfoServiceServer{reqHandler}) } diff --git a/internal/rpc/generated/insurancev1_InsuranceProductListService_InsuranceProductList_server_method.go b/internal/rpc/generated/insurancev1_InsuranceProductListService_InsuranceProductList_server_method.go index 7b62eaef..14a18f22 100644 --- a/internal/rpc/generated/insurancev1_InsuranceProductListService_InsuranceProductList_server_method.go +++ b/internal/rpc/generated/insurancev1_InsuranceProductListService_InsuranceProductList_server_method.go @@ -11,7 +11,7 @@ import ( ) func (s *insurancev1InsuranceProductListServiceServer) InsuranceProductList(ctx context.Context, request *insurancev1.InsuranceProductListRequest) (*insurancev1.InsuranceProductListResponse, error) { - response, err := s.reqProcessor.ProcessExternalRequest(ctx, InsuranceProductListServiceV1Request, request) + response, err := s.reqHandler.HandleRequest(ctx, InsuranceProductListServiceV1Request, request) if err != nil { return nil, fmt.Errorf("failed to process %s request: %w", InsuranceProductListServiceV1Request, err) } diff --git a/internal/rpc/generated/insurancev1_InsuranceProductListService_server.go b/internal/rpc/generated/insurancev1_InsuranceProductListService_server.go index 1f35610e..a3654e2a 100644 --- a/internal/rpc/generated/insurancev1_InsuranceProductListService_server.go +++ b/internal/rpc/generated/insurancev1_InsuranceProductListService_server.go @@ -13,9 +13,9 @@ import ( var _ insurancev1grpc.InsuranceProductListServiceServer = (*insurancev1InsuranceProductListServiceServer)(nil) type insurancev1InsuranceProductListServiceServer struct { - reqProcessor rpc.ExternalRequestProcessor + reqHandler rpc.RequestHandler } -func registerInsuranceProductListServiceV1Server(grpcServer *grpc.Server, reqProcessor rpc.ExternalRequestProcessor) { - insurancev1grpc.RegisterInsuranceProductListServiceServer(grpcServer, &insurancev1InsuranceProductListServiceServer{reqProcessor}) +func registerInsuranceProductListServiceV1Server(grpcServer *grpc.Server, reqHandler rpc.RequestHandler) { + insurancev1grpc.RegisterInsuranceProductListServiceServer(grpcServer, &insurancev1InsuranceProductListServiceServer{reqHandler}) } diff --git a/internal/rpc/generated/insurancev1_InsuranceSearchService_InsuranceSearch_server_method.go b/internal/rpc/generated/insurancev1_InsuranceSearchService_InsuranceSearch_server_method.go index 0d6a9fea..b2cc5984 100644 --- a/internal/rpc/generated/insurancev1_InsuranceSearchService_InsuranceSearch_server_method.go +++ b/internal/rpc/generated/insurancev1_InsuranceSearchService_InsuranceSearch_server_method.go @@ -11,7 +11,7 @@ import ( ) func (s *insurancev1InsuranceSearchServiceServer) InsuranceSearch(ctx context.Context, request *insurancev1.InsuranceSearchRequest) (*insurancev1.InsuranceSearchResponse, error) { - response, err := s.reqProcessor.ProcessExternalRequest(ctx, InsuranceSearchServiceV1Request, request) + response, err := s.reqHandler.HandleRequest(ctx, InsuranceSearchServiceV1Request, request) if err != nil { return nil, fmt.Errorf("failed to process %s request: %w", InsuranceSearchServiceV1Request, err) } diff --git a/internal/rpc/generated/insurancev1_InsuranceSearchService_server.go b/internal/rpc/generated/insurancev1_InsuranceSearchService_server.go index 9e871761..18fc3e72 100644 --- a/internal/rpc/generated/insurancev1_InsuranceSearchService_server.go +++ b/internal/rpc/generated/insurancev1_InsuranceSearchService_server.go @@ -13,9 +13,9 @@ import ( var _ insurancev1grpc.InsuranceSearchServiceServer = (*insurancev1InsuranceSearchServiceServer)(nil) type insurancev1InsuranceSearchServiceServer struct { - reqProcessor rpc.ExternalRequestProcessor + reqHandler rpc.RequestHandler } -func registerInsuranceSearchServiceV1Server(grpcServer *grpc.Server, reqProcessor rpc.ExternalRequestProcessor) { - insurancev1grpc.RegisterInsuranceSearchServiceServer(grpcServer, &insurancev1InsuranceSearchServiceServer{reqProcessor}) +func registerInsuranceSearchServiceV1Server(grpcServer *grpc.Server, reqHandler rpc.RequestHandler) { + insurancev1grpc.RegisterInsuranceSearchServiceServer(grpcServer, &insurancev1InsuranceSearchServiceServer{reqHandler}) } diff --git a/internal/rpc/generated/networkv1_GetNetworkFeeService_GetNetworkFee_server_method.go b/internal/rpc/generated/networkv1_GetNetworkFeeService_GetNetworkFee_server_method.go index c47afe5c..87d9c857 100644 --- a/internal/rpc/generated/networkv1_GetNetworkFeeService_GetNetworkFee_server_method.go +++ b/internal/rpc/generated/networkv1_GetNetworkFeeService_GetNetworkFee_server_method.go @@ -11,7 +11,7 @@ import ( ) func (s *networkv1GetNetworkFeeServiceServer) GetNetworkFee(ctx context.Context, request *networkv1.GetNetworkFeeRequest) (*networkv1.GetNetworkFeeResponse, error) { - response, err := s.reqProcessor.ProcessExternalRequest(ctx, GetNetworkFeeServiceV1Request, request) + response, err := s.reqHandler.HandleRequest(ctx, GetNetworkFeeServiceV1Request, request) if err != nil { return nil, fmt.Errorf("failed to process %s request: %w", GetNetworkFeeServiceV1Request, err) } diff --git a/internal/rpc/generated/networkv1_GetNetworkFeeService_server.go b/internal/rpc/generated/networkv1_GetNetworkFeeService_server.go index e145f90c..d254251f 100644 --- a/internal/rpc/generated/networkv1_GetNetworkFeeService_server.go +++ b/internal/rpc/generated/networkv1_GetNetworkFeeService_server.go @@ -13,9 +13,9 @@ import ( var _ networkv1grpc.GetNetworkFeeServiceServer = (*networkv1GetNetworkFeeServiceServer)(nil) type networkv1GetNetworkFeeServiceServer struct { - reqProcessor rpc.ExternalRequestProcessor + reqHandler rpc.RequestHandler } -func registerGetNetworkFeeServiceV1Server(grpcServer *grpc.Server, reqProcessor rpc.ExternalRequestProcessor) { - networkv1grpc.RegisterGetNetworkFeeServiceServer(grpcServer, &networkv1GetNetworkFeeServiceServer{reqProcessor}) +func registerGetNetworkFeeServiceV1Server(grpcServer *grpc.Server, reqHandler rpc.RequestHandler) { + networkv1grpc.RegisterGetNetworkFeeServiceServer(grpcServer, &networkv1GetNetworkFeeServiceServer{reqHandler}) } diff --git a/internal/rpc/generated/partnerv1_GetPartnerConfigurationService_GetPartnerConfiguration_server_method.go b/internal/rpc/generated/partnerv1_GetPartnerConfigurationService_GetPartnerConfiguration_server_method.go index cc729c47..8e75fa11 100644 --- a/internal/rpc/generated/partnerv1_GetPartnerConfigurationService_GetPartnerConfiguration_server_method.go +++ b/internal/rpc/generated/partnerv1_GetPartnerConfigurationService_GetPartnerConfiguration_server_method.go @@ -11,7 +11,7 @@ import ( ) func (s *partnerv1GetPartnerConfigurationServiceServer) GetPartnerConfiguration(ctx context.Context, request *partnerv1.GetPartnerConfigurationRequest) (*partnerv1.GetPartnerConfigurationResponse, error) { - response, err := s.reqProcessor.ProcessExternalRequest(ctx, GetPartnerConfigurationServiceV1Request, request) + response, err := s.reqHandler.HandleRequest(ctx, GetPartnerConfigurationServiceV1Request, request) if err != nil { return nil, fmt.Errorf("failed to process %s request: %w", GetPartnerConfigurationServiceV1Request, err) } diff --git a/internal/rpc/generated/partnerv1_GetPartnerConfigurationService_server.go b/internal/rpc/generated/partnerv1_GetPartnerConfigurationService_server.go index 9484bb3d..16ba9f5c 100644 --- a/internal/rpc/generated/partnerv1_GetPartnerConfigurationService_server.go +++ b/internal/rpc/generated/partnerv1_GetPartnerConfigurationService_server.go @@ -13,9 +13,9 @@ import ( var _ partnerv1grpc.GetPartnerConfigurationServiceServer = (*partnerv1GetPartnerConfigurationServiceServer)(nil) type partnerv1GetPartnerConfigurationServiceServer struct { - reqProcessor rpc.ExternalRequestProcessor + reqHandler rpc.RequestHandler } -func registerGetPartnerConfigurationServiceV1Server(grpcServer *grpc.Server, reqProcessor rpc.ExternalRequestProcessor) { - partnerv1grpc.RegisterGetPartnerConfigurationServiceServer(grpcServer, &partnerv1GetPartnerConfigurationServiceServer{reqProcessor}) +func registerGetPartnerConfigurationServiceV1Server(grpcServer *grpc.Server, reqHandler rpc.RequestHandler) { + partnerv1grpc.RegisterGetPartnerConfigurationServiceServer(grpcServer, &partnerv1GetPartnerConfigurationServiceServer{reqHandler}) } diff --git a/internal/rpc/generated/partnerv2_GetPartnerConfigurationService_GetPartnerConfiguration_server_method.go b/internal/rpc/generated/partnerv2_GetPartnerConfigurationService_GetPartnerConfiguration_server_method.go index 537dbdf8..fe7f1549 100644 --- a/internal/rpc/generated/partnerv2_GetPartnerConfigurationService_GetPartnerConfiguration_server_method.go +++ b/internal/rpc/generated/partnerv2_GetPartnerConfigurationService_GetPartnerConfiguration_server_method.go @@ -11,7 +11,7 @@ import ( ) func (s *partnerv2GetPartnerConfigurationServiceServer) GetPartnerConfiguration(ctx context.Context, request *partnerv2.GetPartnerConfigurationRequest) (*partnerv2.GetPartnerConfigurationResponse, error) { - response, err := s.reqProcessor.ProcessExternalRequest(ctx, GetPartnerConfigurationServiceV2Request, request) + response, err := s.reqHandler.HandleRequest(ctx, GetPartnerConfigurationServiceV2Request, request) if err != nil { return nil, fmt.Errorf("failed to process %s request: %w", GetPartnerConfigurationServiceV2Request, err) } diff --git a/internal/rpc/generated/partnerv2_GetPartnerConfigurationService_server.go b/internal/rpc/generated/partnerv2_GetPartnerConfigurationService_server.go index fdfc94ed..0d49c48c 100644 --- a/internal/rpc/generated/partnerv2_GetPartnerConfigurationService_server.go +++ b/internal/rpc/generated/partnerv2_GetPartnerConfigurationService_server.go @@ -13,9 +13,9 @@ import ( var _ partnerv2grpc.GetPartnerConfigurationServiceServer = (*partnerv2GetPartnerConfigurationServiceServer)(nil) type partnerv2GetPartnerConfigurationServiceServer struct { - reqProcessor rpc.ExternalRequestProcessor + reqHandler rpc.RequestHandler } -func registerGetPartnerConfigurationServiceV2Server(grpcServer *grpc.Server, reqProcessor rpc.ExternalRequestProcessor) { - partnerv2grpc.RegisterGetPartnerConfigurationServiceServer(grpcServer, &partnerv2GetPartnerConfigurationServiceServer{reqProcessor}) +func registerGetPartnerConfigurationServiceV2Server(grpcServer *grpc.Server, reqHandler rpc.RequestHandler) { + partnerv2grpc.RegisterGetPartnerConfigurationServiceServer(grpcServer, &partnerv2GetPartnerConfigurationServiceServer{reqHandler}) } diff --git a/internal/rpc/generated/pingv1_PingService_Ping_server_method.go b/internal/rpc/generated/pingv1_PingService_Ping_server_method.go index d5ccabc0..d38d6761 100644 --- a/internal/rpc/generated/pingv1_PingService_Ping_server_method.go +++ b/internal/rpc/generated/pingv1_PingService_Ping_server_method.go @@ -11,7 +11,7 @@ import ( ) func (s *pingv1PingServiceServer) Ping(ctx context.Context, request *pingv1.PingRequest) (*pingv1.PingResponse, error) { - response, err := s.reqProcessor.ProcessExternalRequest(ctx, PingServiceV1Request, request) + response, err := s.reqHandler.HandleRequest(ctx, PingServiceV1Request, request) if err != nil { return nil, fmt.Errorf("failed to process %s request: %w", PingServiceV1Request, err) } diff --git a/internal/rpc/generated/pingv1_PingService_server.go b/internal/rpc/generated/pingv1_PingService_server.go index b7eda0e6..3f1dee81 100644 --- a/internal/rpc/generated/pingv1_PingService_server.go +++ b/internal/rpc/generated/pingv1_PingService_server.go @@ -13,9 +13,9 @@ import ( var _ pingv1grpc.PingServiceServer = (*pingv1PingServiceServer)(nil) type pingv1PingServiceServer struct { - reqProcessor rpc.ExternalRequestProcessor + reqHandler rpc.RequestHandler } -func registerPingServiceV1Server(grpcServer *grpc.Server, reqProcessor rpc.ExternalRequestProcessor) { - pingv1grpc.RegisterPingServiceServer(grpcServer, &pingv1PingServiceServer{reqProcessor}) +func registerPingServiceV1Server(grpcServer *grpc.Server, reqHandler rpc.RequestHandler) { + pingv1grpc.RegisterPingServiceServer(grpcServer, &pingv1PingServiceServer{reqHandler}) } diff --git a/internal/rpc/generated/register_server_services.go b/internal/rpc/generated/register_server_services.go index a83de0f3..2bb31c6e 100644 --- a/internal/rpc/generated/register_server_services.go +++ b/internal/rpc/generated/register_server_services.go @@ -7,36 +7,36 @@ import ( "google.golang.org/grpc" ) -func RegisterServerServices(grpcServer *grpc.Server, reqProcessor rpc.ExternalRequestProcessor) { - registerAccommodationProductInfoServiceV1Server(grpcServer, reqProcessor) - registerAccommodationProductListServiceV1Server(grpcServer, reqProcessor) - registerAccommodationSearchServiceV1Server(grpcServer, reqProcessor) - registerAccommodationProductInfoServiceV2Server(grpcServer, reqProcessor) - registerAccommodationProductListServiceV2Server(grpcServer, reqProcessor) - registerAccommodationSearchServiceV2Server(grpcServer, reqProcessor) - registerActivityProductInfoServiceV1Server(grpcServer, reqProcessor) - registerActivityProductListServiceV1Server(grpcServer, reqProcessor) - registerActivitySearchServiceV1Server(grpcServer, reqProcessor) - registerActivityProductInfoServiceV2Server(grpcServer, reqProcessor) - registerActivityProductListServiceV2Server(grpcServer, reqProcessor) - registerActivitySearchServiceV2Server(grpcServer, reqProcessor) - registerMintServiceV1Server(grpcServer, reqProcessor) - registerValidationServiceV1Server(grpcServer, reqProcessor) - registerMintServiceV2Server(grpcServer, reqProcessor) - registerValidationServiceV2Server(grpcServer, reqProcessor) - registerCountryEntryRequirementsServiceV1Server(grpcServer, reqProcessor) - registerCountryEntryRequirementsServiceV2Server(grpcServer, reqProcessor) - registerInsuranceProductInfoServiceV1Server(grpcServer, reqProcessor) - registerInsuranceProductListServiceV1Server(grpcServer, reqProcessor) - registerInsuranceSearchServiceV1Server(grpcServer, reqProcessor) - registerGetNetworkFeeServiceV1Server(grpcServer, reqProcessor) - registerGetPartnerConfigurationServiceV1Server(grpcServer, reqProcessor) - registerGetPartnerConfigurationServiceV2Server(grpcServer, reqProcessor) - registerPingServiceV1Server(grpcServer, reqProcessor) - registerSeatMapAvailabilityServiceV1Server(grpcServer, reqProcessor) - registerSeatMapServiceV1Server(grpcServer, reqProcessor) - registerSeatMapAvailabilityServiceV2Server(grpcServer, reqProcessor) - registerSeatMapServiceV2Server(grpcServer, reqProcessor) - registerTransportSearchServiceV1Server(grpcServer, reqProcessor) - registerTransportSearchServiceV2Server(grpcServer, reqProcessor) +func RegisterServerServices(grpcServer *grpc.Server, reqHandler rpc.RequestHandler) { + registerAccommodationProductInfoServiceV1Server(grpcServer, reqHandler) + registerAccommodationProductListServiceV1Server(grpcServer, reqHandler) + registerAccommodationSearchServiceV1Server(grpcServer, reqHandler) + registerAccommodationProductInfoServiceV2Server(grpcServer, reqHandler) + registerAccommodationProductListServiceV2Server(grpcServer, reqHandler) + registerAccommodationSearchServiceV2Server(grpcServer, reqHandler) + registerActivityProductInfoServiceV1Server(grpcServer, reqHandler) + registerActivityProductListServiceV1Server(grpcServer, reqHandler) + registerActivitySearchServiceV1Server(grpcServer, reqHandler) + registerActivityProductInfoServiceV2Server(grpcServer, reqHandler) + registerActivityProductListServiceV2Server(grpcServer, reqHandler) + registerActivitySearchServiceV2Server(grpcServer, reqHandler) + registerMintServiceV1Server(grpcServer, reqHandler) + registerValidationServiceV1Server(grpcServer, reqHandler) + registerMintServiceV2Server(grpcServer, reqHandler) + registerValidationServiceV2Server(grpcServer, reqHandler) + registerCountryEntryRequirementsServiceV1Server(grpcServer, reqHandler) + registerCountryEntryRequirementsServiceV2Server(grpcServer, reqHandler) + registerInsuranceProductInfoServiceV1Server(grpcServer, reqHandler) + registerInsuranceProductListServiceV1Server(grpcServer, reqHandler) + registerInsuranceSearchServiceV1Server(grpcServer, reqHandler) + registerGetNetworkFeeServiceV1Server(grpcServer, reqHandler) + registerGetPartnerConfigurationServiceV1Server(grpcServer, reqHandler) + registerGetPartnerConfigurationServiceV2Server(grpcServer, reqHandler) + registerPingServiceV1Server(grpcServer, reqHandler) + registerSeatMapAvailabilityServiceV1Server(grpcServer, reqHandler) + registerSeatMapServiceV1Server(grpcServer, reqHandler) + registerSeatMapAvailabilityServiceV2Server(grpcServer, reqHandler) + registerSeatMapServiceV2Server(grpcServer, reqHandler) + registerTransportSearchServiceV1Server(grpcServer, reqHandler) + registerTransportSearchServiceV2Server(grpcServer, reqHandler) } diff --git a/internal/rpc/generated/seat_mapv1_SeatMapAvailabilityService_SeatMapAvailability_server_method.go b/internal/rpc/generated/seat_mapv1_SeatMapAvailabilityService_SeatMapAvailability_server_method.go index f6635ec8..887814a9 100644 --- a/internal/rpc/generated/seat_mapv1_SeatMapAvailabilityService_SeatMapAvailability_server_method.go +++ b/internal/rpc/generated/seat_mapv1_SeatMapAvailabilityService_SeatMapAvailability_server_method.go @@ -11,7 +11,7 @@ import ( ) func (s *seat_mapv1SeatMapAvailabilityServiceServer) SeatMapAvailability(ctx context.Context, request *seat_mapv1.SeatMapAvailabilityRequest) (*seat_mapv1.SeatMapAvailabilityResponse, error) { - response, err := s.reqProcessor.ProcessExternalRequest(ctx, SeatMapAvailabilityServiceV1Request, request) + response, err := s.reqHandler.HandleRequest(ctx, SeatMapAvailabilityServiceV1Request, request) if err != nil { return nil, fmt.Errorf("failed to process %s request: %w", SeatMapAvailabilityServiceV1Request, err) } diff --git a/internal/rpc/generated/seat_mapv1_SeatMapAvailabilityService_server.go b/internal/rpc/generated/seat_mapv1_SeatMapAvailabilityService_server.go index 647d48f0..36db17e1 100644 --- a/internal/rpc/generated/seat_mapv1_SeatMapAvailabilityService_server.go +++ b/internal/rpc/generated/seat_mapv1_SeatMapAvailabilityService_server.go @@ -13,9 +13,9 @@ import ( var _ seat_mapv1grpc.SeatMapAvailabilityServiceServer = (*seat_mapv1SeatMapAvailabilityServiceServer)(nil) type seat_mapv1SeatMapAvailabilityServiceServer struct { - reqProcessor rpc.ExternalRequestProcessor + reqHandler rpc.RequestHandler } -func registerSeatMapAvailabilityServiceV1Server(grpcServer *grpc.Server, reqProcessor rpc.ExternalRequestProcessor) { - seat_mapv1grpc.RegisterSeatMapAvailabilityServiceServer(grpcServer, &seat_mapv1SeatMapAvailabilityServiceServer{reqProcessor}) +func registerSeatMapAvailabilityServiceV1Server(grpcServer *grpc.Server, reqHandler rpc.RequestHandler) { + seat_mapv1grpc.RegisterSeatMapAvailabilityServiceServer(grpcServer, &seat_mapv1SeatMapAvailabilityServiceServer{reqHandler}) } diff --git a/internal/rpc/generated/seat_mapv1_SeatMapService_SeatMap_server_method.go b/internal/rpc/generated/seat_mapv1_SeatMapService_SeatMap_server_method.go index ffe7528d..15b7955d 100644 --- a/internal/rpc/generated/seat_mapv1_SeatMapService_SeatMap_server_method.go +++ b/internal/rpc/generated/seat_mapv1_SeatMapService_SeatMap_server_method.go @@ -11,7 +11,7 @@ import ( ) func (s *seat_mapv1SeatMapServiceServer) SeatMap(ctx context.Context, request *seat_mapv1.SeatMapRequest) (*seat_mapv1.SeatMapResponse, error) { - response, err := s.reqProcessor.ProcessExternalRequest(ctx, SeatMapServiceV1Request, request) + response, err := s.reqHandler.HandleRequest(ctx, SeatMapServiceV1Request, request) if err != nil { return nil, fmt.Errorf("failed to process %s request: %w", SeatMapServiceV1Request, err) } diff --git a/internal/rpc/generated/seat_mapv1_SeatMapService_server.go b/internal/rpc/generated/seat_mapv1_SeatMapService_server.go index b4dba634..90921480 100644 --- a/internal/rpc/generated/seat_mapv1_SeatMapService_server.go +++ b/internal/rpc/generated/seat_mapv1_SeatMapService_server.go @@ -13,9 +13,9 @@ import ( var _ seat_mapv1grpc.SeatMapServiceServer = (*seat_mapv1SeatMapServiceServer)(nil) type seat_mapv1SeatMapServiceServer struct { - reqProcessor rpc.ExternalRequestProcessor + reqHandler rpc.RequestHandler } -func registerSeatMapServiceV1Server(grpcServer *grpc.Server, reqProcessor rpc.ExternalRequestProcessor) { - seat_mapv1grpc.RegisterSeatMapServiceServer(grpcServer, &seat_mapv1SeatMapServiceServer{reqProcessor}) +func registerSeatMapServiceV1Server(grpcServer *grpc.Server, reqHandler rpc.RequestHandler) { + seat_mapv1grpc.RegisterSeatMapServiceServer(grpcServer, &seat_mapv1SeatMapServiceServer{reqHandler}) } diff --git a/internal/rpc/generated/seat_mapv2_SeatMapAvailabilityService_SeatMapAvailability_server_method.go b/internal/rpc/generated/seat_mapv2_SeatMapAvailabilityService_SeatMapAvailability_server_method.go index fe2e8909..135018a0 100644 --- a/internal/rpc/generated/seat_mapv2_SeatMapAvailabilityService_SeatMapAvailability_server_method.go +++ b/internal/rpc/generated/seat_mapv2_SeatMapAvailabilityService_SeatMapAvailability_server_method.go @@ -11,7 +11,7 @@ import ( ) func (s *seat_mapv2SeatMapAvailabilityServiceServer) SeatMapAvailability(ctx context.Context, request *seat_mapv2.SeatMapAvailabilityRequest) (*seat_mapv2.SeatMapAvailabilityResponse, error) { - response, err := s.reqProcessor.ProcessExternalRequest(ctx, SeatMapAvailabilityServiceV2Request, request) + response, err := s.reqHandler.HandleRequest(ctx, SeatMapAvailabilityServiceV2Request, request) if err != nil { return nil, fmt.Errorf("failed to process %s request: %w", SeatMapAvailabilityServiceV2Request, err) } diff --git a/internal/rpc/generated/seat_mapv2_SeatMapAvailabilityService_server.go b/internal/rpc/generated/seat_mapv2_SeatMapAvailabilityService_server.go index 35cf4f20..5237280a 100644 --- a/internal/rpc/generated/seat_mapv2_SeatMapAvailabilityService_server.go +++ b/internal/rpc/generated/seat_mapv2_SeatMapAvailabilityService_server.go @@ -13,9 +13,9 @@ import ( var _ seat_mapv2grpc.SeatMapAvailabilityServiceServer = (*seat_mapv2SeatMapAvailabilityServiceServer)(nil) type seat_mapv2SeatMapAvailabilityServiceServer struct { - reqProcessor rpc.ExternalRequestProcessor + reqHandler rpc.RequestHandler } -func registerSeatMapAvailabilityServiceV2Server(grpcServer *grpc.Server, reqProcessor rpc.ExternalRequestProcessor) { - seat_mapv2grpc.RegisterSeatMapAvailabilityServiceServer(grpcServer, &seat_mapv2SeatMapAvailabilityServiceServer{reqProcessor}) +func registerSeatMapAvailabilityServiceV2Server(grpcServer *grpc.Server, reqHandler rpc.RequestHandler) { + seat_mapv2grpc.RegisterSeatMapAvailabilityServiceServer(grpcServer, &seat_mapv2SeatMapAvailabilityServiceServer{reqHandler}) } diff --git a/internal/rpc/generated/seat_mapv2_SeatMapService_SeatMap_server_method.go b/internal/rpc/generated/seat_mapv2_SeatMapService_SeatMap_server_method.go index 80da20b6..0b5850a3 100644 --- a/internal/rpc/generated/seat_mapv2_SeatMapService_SeatMap_server_method.go +++ b/internal/rpc/generated/seat_mapv2_SeatMapService_SeatMap_server_method.go @@ -11,7 +11,7 @@ import ( ) func (s *seat_mapv2SeatMapServiceServer) SeatMap(ctx context.Context, request *seat_mapv2.SeatMapRequest) (*seat_mapv2.SeatMapResponse, error) { - response, err := s.reqProcessor.ProcessExternalRequest(ctx, SeatMapServiceV2Request, request) + response, err := s.reqHandler.HandleRequest(ctx, SeatMapServiceV2Request, request) if err != nil { return nil, fmt.Errorf("failed to process %s request: %w", SeatMapServiceV2Request, err) } diff --git a/internal/rpc/generated/seat_mapv2_SeatMapService_server.go b/internal/rpc/generated/seat_mapv2_SeatMapService_server.go index 682d47b2..c3a23480 100644 --- a/internal/rpc/generated/seat_mapv2_SeatMapService_server.go +++ b/internal/rpc/generated/seat_mapv2_SeatMapService_server.go @@ -13,9 +13,9 @@ import ( var _ seat_mapv2grpc.SeatMapServiceServer = (*seat_mapv2SeatMapServiceServer)(nil) type seat_mapv2SeatMapServiceServer struct { - reqProcessor rpc.ExternalRequestProcessor + reqHandler rpc.RequestHandler } -func registerSeatMapServiceV2Server(grpcServer *grpc.Server, reqProcessor rpc.ExternalRequestProcessor) { - seat_mapv2grpc.RegisterSeatMapServiceServer(grpcServer, &seat_mapv2SeatMapServiceServer{reqProcessor}) +func registerSeatMapServiceV2Server(grpcServer *grpc.Server, reqHandler rpc.RequestHandler) { + seat_mapv2grpc.RegisterSeatMapServiceServer(grpcServer, &seat_mapv2SeatMapServiceServer{reqHandler}) } diff --git a/internal/rpc/generated/transportv1_TransportSearchService_TransportSearch_server_method.go b/internal/rpc/generated/transportv1_TransportSearchService_TransportSearch_server_method.go index b2b699a6..e9ca250a 100644 --- a/internal/rpc/generated/transportv1_TransportSearchService_TransportSearch_server_method.go +++ b/internal/rpc/generated/transportv1_TransportSearchService_TransportSearch_server_method.go @@ -11,7 +11,7 @@ import ( ) func (s *transportv1TransportSearchServiceServer) TransportSearch(ctx context.Context, request *transportv1.TransportSearchRequest) (*transportv1.TransportSearchResponse, error) { - response, err := s.reqProcessor.ProcessExternalRequest(ctx, TransportSearchServiceV1Request, request) + response, err := s.reqHandler.HandleRequest(ctx, TransportSearchServiceV1Request, request) if err != nil { return nil, fmt.Errorf("failed to process %s request: %w", TransportSearchServiceV1Request, err) } diff --git a/internal/rpc/generated/transportv1_TransportSearchService_server.go b/internal/rpc/generated/transportv1_TransportSearchService_server.go index 2fbd684b..433ac7f8 100644 --- a/internal/rpc/generated/transportv1_TransportSearchService_server.go +++ b/internal/rpc/generated/transportv1_TransportSearchService_server.go @@ -13,9 +13,9 @@ import ( var _ transportv1grpc.TransportSearchServiceServer = (*transportv1TransportSearchServiceServer)(nil) type transportv1TransportSearchServiceServer struct { - reqProcessor rpc.ExternalRequestProcessor + reqHandler rpc.RequestHandler } -func registerTransportSearchServiceV1Server(grpcServer *grpc.Server, reqProcessor rpc.ExternalRequestProcessor) { - transportv1grpc.RegisterTransportSearchServiceServer(grpcServer, &transportv1TransportSearchServiceServer{reqProcessor}) +func registerTransportSearchServiceV1Server(grpcServer *grpc.Server, reqHandler rpc.RequestHandler) { + transportv1grpc.RegisterTransportSearchServiceServer(grpcServer, &transportv1TransportSearchServiceServer{reqHandler}) } diff --git a/internal/rpc/generated/transportv2_TransportSearchService_TransportSearch_server_method.go b/internal/rpc/generated/transportv2_TransportSearchService_TransportSearch_server_method.go index d8d439ad..4342dfc6 100644 --- a/internal/rpc/generated/transportv2_TransportSearchService_TransportSearch_server_method.go +++ b/internal/rpc/generated/transportv2_TransportSearchService_TransportSearch_server_method.go @@ -11,7 +11,7 @@ import ( ) func (s *transportv2TransportSearchServiceServer) TransportSearch(ctx context.Context, request *transportv2.TransportSearchRequest) (*transportv2.TransportSearchResponse, error) { - response, err := s.reqProcessor.ProcessExternalRequest(ctx, TransportSearchServiceV2Request, request) + response, err := s.reqHandler.HandleRequest(ctx, TransportSearchServiceV2Request, request) if err != nil { return nil, fmt.Errorf("failed to process %s request: %w", TransportSearchServiceV2Request, err) } diff --git a/internal/rpc/generated/transportv2_TransportSearchService_server.go b/internal/rpc/generated/transportv2_TransportSearchService_server.go index 046b9db3..2896a230 100644 --- a/internal/rpc/generated/transportv2_TransportSearchService_server.go +++ b/internal/rpc/generated/transportv2_TransportSearchService_server.go @@ -13,9 +13,9 @@ import ( var _ transportv2grpc.TransportSearchServiceServer = (*transportv2TransportSearchServiceServer)(nil) type transportv2TransportSearchServiceServer struct { - reqProcessor rpc.ExternalRequestProcessor + reqHandler rpc.RequestHandler } -func registerTransportSearchServiceV2Server(grpcServer *grpc.Server, reqProcessor rpc.ExternalRequestProcessor) { - transportv2grpc.RegisterTransportSearchServiceServer(grpcServer, &transportv2TransportSearchServiceServer{reqProcessor}) +func registerTransportSearchServiceV2Server(grpcServer *grpc.Server, reqHandler rpc.RequestHandler) { + transportv2grpc.RegisterTransportSearchServiceServer(grpcServer, &transportv2TransportSearchServiceServer{reqHandler}) } From f178987c2228c351969cfb9c8dbfb11cfd1f8f0e Mon Sep 17 00:00:00 2001 From: "ev.lekht" Date: Thu, 21 Nov 2024 21:42:05 +0400 Subject: [PATCH 04/20] wip --- internal/compression/compress.go | 2 -- internal/messaging/processor.go | 7 ------- internal/messaging/response_handler.go | 4 ---- internal/rpc/server/server.go | 3 --- 4 files changed, 16 deletions(-) diff --git a/internal/compression/compress.go b/internal/compression/compress.go index 365703fb..3219349e 100644 --- a/internal/compression/compress.go +++ b/internal/compression/compress.go @@ -10,8 +10,6 @@ import ( ) const ( - // TODO@ according to comment, this must be re-investigated! - // TODO@ Also, shouldn't be metadata (and etc if anything) size be taken into account? // MaxChunkSize a moderate/safe max chunk size is 48KB. This is because the maximum size of a matrix event is 64KB. // Megolm encryption adds an extra 33% overhead to the encrypted content due to base64 encryption. This means that // the maximum size of pre-encrypted chunk should be 48KB / 1.33 ~= 36KB. We round down to 35KB to be safe. diff --git a/internal/messaging/processor.go b/internal/messaging/processor.go index f603edf7..24488f96 100644 --- a/internal/messaging/processor.go +++ b/internal/messaging/processor.go @@ -168,9 +168,6 @@ func (p *messageProcessor) SendRequestMessage(ctx context.Context, requestMsg *t requestMsg.Metadata.Cheques = []cheques.SignedCheque{} - // TODO@ do we want to check this every time? or just once at startup? - // TODO@ we can also listen chain for bot permission changes and shut down bot if it loses - // TODO@ or not shutdown, but set some bool that will block all incoming requests with noop isBotAllowed, err := p.cmAccounts.IsBotAllowed(ctx, p.cmAccountAddress, p.myBotAddress) if err != nil { return nil, err @@ -217,10 +214,6 @@ func (p *messageProcessor) SendRequestMessage(ctx context.Context, requestMsg *t select { case responseMsg := <-responseChan: if responseMsg.Metadata.RequestID == requestMsg.Metadata.RequestID { - // TODO@ do we still care about context timeout here? if not, context must be freed of timeout - // TODO@ currently, timeout is described as its only for receiving response from matrix - // TODO@ but maybe it will make more sense to use timeout for whole bot request-response cycle? - // TODO@ like, its timeout meaningful for external requester p.responseHandler.ProcessResponseMessage(ctx, requestMsg, responseMsg) return responseMsg, nil } diff --git a/internal/messaging/response_handler.go b/internal/messaging/response_handler.go index 4ce3d4db..2c928aff 100644 --- a/internal/messaging/response_handler.go +++ b/internal/messaging/response_handler.go @@ -40,10 +40,6 @@ var ( zeroAddress = common.HexToAddress("0x0000000000000000000000000000000000000000") ) -// TODO@ move this to processor? -// TODO@ two reason its there: -// TODO@ 1) to make processor not depend on protobuf types (but package depends regardless) -// TODO@ 2) to abstract all message-specific logic into response handler. But I'm not sure if it worth it. type ResponseHandler interface { // Processes incoming response ProcessResponseMessage(ctx context.Context, requestMsg *types.Message, responseMsg *types.Message) diff --git a/internal/rpc/server/server.go b/internal/rpc/server/server.go index a3966bd3..e2495743 100644 --- a/internal/rpc/server/server.go +++ b/internal/rpc/server/server.go @@ -93,9 +93,6 @@ func (s *server) Stop() { func (s *server) HandleRequest(ctx context.Context, requestType types.MessageType, request protoreflect.ProtoMessage) (protoreflect.ProtoMessage, error) { ctx, span := s.tracer.Start(ctx, "server.HandleRequest", trace.WithSpanKind(trace.SpanKindServer)) defer span.End() - // TODO@ have our own requestID generation instead of using id generated by tracer? - // TODO@ if tracing is disabled, noop tracer is used and it generates random traceID with crypto.Rand - // TODO@ also, traceID is 16 bytes long, is it enough? md, err := s.processMetadata(ctx, s.tracer.TraceIDForSpan(span)) if err != nil { return nil, fmt.Errorf("error processing metadata: %w", err) From f4f0877389dbb0489c1d6c9deb87223b0325ade8 Mon Sep 17 00:00:00 2001 From: "ev.lekht" Date: Fri, 22 Nov 2024 13:31:20 +0400 Subject: [PATCH 05/20] wip --- internal/messaging/processor.go | 6 ++++-- internal/messaging/types/types.go | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/internal/messaging/processor.go b/internal/messaging/processor.go index 24488f96..9ded4c48 100644 --- a/internal/messaging/processor.go +++ b/internal/messaging/processor.go @@ -216,13 +216,15 @@ func (p *messageProcessor) SendRequestMessage(ctx context.Context, requestMsg *t if responseMsg.Metadata.RequestID == requestMsg.Metadata.RequestID { p.responseHandler.ProcessResponseMessage(ctx, requestMsg, responseMsg) return responseMsg, nil + } else { + err := fmt.Errorf("unexpected response (%s) for request (%s)", responseMsg.Metadata.RequestID, requestMsg.Metadata.RequestID) + p.logger.Error(err) + return nil, err } case <-ctx.Done(): return nil, fmt.Errorf("%w of %v seconds for request: %s", ErrExceededResponseTimeout, p.responseTimeout, requestMsg.Metadata.RequestID) } - // TODO@ not correct, responseChan case has if block. if IF is bypassed, we won't return - panic("unreachable") // will never get there, but compiler doesn't know that, so we need to satisfy return } func (p *messageProcessor) respond(msg *types.Message) error { diff --git a/internal/messaging/types/types.go b/internal/messaging/types/types.go index 66e3dc9d..ba6149cb 100644 --- a/internal/messaging/types/types.go +++ b/internal/messaging/types/types.go @@ -46,12 +46,13 @@ func ServiceNameToRequestMessageType(serviceName string) MessageType { } // Message is the message format used for communication between the messenger and the service +// TODO @evlekht why json tags? where is this shown? Its not passed into matrix message type Message struct { Type MessageType `json:"msgtype"` Content protoreflect.ProtoMessage `json:"content"` Metadata metadata.Metadata `json:"metadata"` - Sender id.UserID // TODO@ ensure that its not marshalled - CompressedContent [][]byte // TODO@ ensure that its not marshalled + Sender id.UserID + CompressedContent [][]byte } func (m *Message) MarshalContent() ([]byte, error) { From 4db01554a9e8ca46509ab8c821ad41238d671f1c Mon Sep 17 00:00:00 2001 From: "ev.lekht" Date: Fri, 22 Nov 2024 15:29:10 +0400 Subject: [PATCH 06/20] wip --- internal/messaging/mint_v1.go | 3 +++ internal/messaging/mint_v2.go | 3 +++ internal/messaging/processor.go | 2 ++ internal/messaging/response_handler.go | 1 + templates/client.go.tpl | 4 ++-- templates/client_method.go.tpl | 2 +- 6 files changed, 12 insertions(+), 3 deletions(-) diff --git a/internal/messaging/mint_v1.go b/internal/messaging/mint_v1.go index 1e7b0bd1..175f28bb 100644 --- a/internal/messaging/mint_v1.go +++ b/internal/messaging/mint_v1.go @@ -95,6 +95,9 @@ func (h *evmResponseHandler) prepareMintResponseV1( func (h *evmResponseHandler) processMintResponseV1(ctx context.Context, responseIntf protoreflect.ProtoMessage) { response, ok := responseIntf.(*bookv1.MintResponse) if !ok { + // TODO@ we might not have header here, especially since response type is unexpected + // TODO@ should we create dummy error response of correct type here and pass it? + // TODO@ how this could even happen? err := fmt.Errorf("%w: expected *bookv1.MintResponse, got %T", errUnexpectedResponseType, responseIntf) h.logger.Error(err) h.AddErrorToResponseHeader(response, err.Error()) diff --git a/internal/messaging/mint_v2.go b/internal/messaging/mint_v2.go index 994c192b..860b4a2c 100644 --- a/internal/messaging/mint_v2.go +++ b/internal/messaging/mint_v2.go @@ -101,6 +101,9 @@ func (h *evmResponseHandler) prepareMintResponseV2( func (h *evmResponseHandler) processMintResponseV2(ctx context.Context, responseIntf protoreflect.ProtoMessage) { response, ok := responseIntf.(*bookv2.MintResponse) if !ok { + // TODO@ we might not have header here, especially since response type is unexpected + // TODO@ should we create dummy error response of correct type here and pass it? + // TODO@ how this could even happen? err := fmt.Errorf("%w: expected *bookv2.MintResponse, got %T", errUnexpectedResponseType, responseIntf) h.logger.Error(err) h.AddErrorToResponseHeader(response, err.Error()) diff --git a/internal/messaging/processor.go b/internal/messaging/processor.go index 9ded4c48..ef761573 100644 --- a/internal/messaging/processor.go +++ b/internal/messaging/processor.go @@ -292,6 +292,8 @@ func (p *messageProcessor) callPartnerPluginAndGetResponse( responseMsg.Content = response } + // TODO@ ensure response header, ensure that response has correct type ? + if err != nil { errMessage := fmt.Sprintf("error calling partner plugin service: %v", err) p.logger.Errorf(errMessage) diff --git a/internal/messaging/response_handler.go b/internal/messaging/response_handler.go index 2c928aff..c489445a 100644 --- a/internal/messaging/response_handler.go +++ b/internal/messaging/response_handler.go @@ -40,6 +40,7 @@ var ( zeroAddress = common.HexToAddress("0x0000000000000000000000000000000000000000") ) +// TODO@ rename ? type ResponseHandler interface { // Processes incoming response ProcessResponseMessage(ctx context.Context, requestMsg *types.Message, responseMsg *types.Message) diff --git a/templates/client.go.tpl b/templates/client.go.tpl index 4b7fd370..34d979bb 100644 --- a/templates/client.go.tpl +++ b/templates/client.go.tpl @@ -21,9 +21,9 @@ var _ rpc.Client = (*{{SERVICE}}V{{VERSION}}Client)(nil) func New{{SERVICE}}V{{VERSION}}(grpcCon *grpc.ClientConn) *{{SERVICE}}V{{VERSION}}Client { client := {{GRPC_PACKAGE}}.New{{SERVICE}}Client(grpcCon) - return &{{SERVICE}}V{{VERSION}}Client{client: &client} + return &{{SERVICE}}V{{VERSION}}Client{client: client} } type {{SERVICE}}V{{VERSION}}Client struct { - client *{{GRPC_PACKAGE}}.{{SERVICE}}Client + client {{GRPC_PACKAGE}}.{{SERVICE}}Client } diff --git a/templates/client_method.go.tpl b/templates/client_method.go.tpl index 3bd38fe0..d1de441b 100644 --- a/templates/client_method.go.tpl +++ b/templates/client_method.go.tpl @@ -19,6 +19,6 @@ func (s {{SERVICE}}V{{VERSION}}Client) Call(ctx context.Context, requestIntf pro if !ok { return nil, {{SERVICE}}V{{VERSION}}Response, fmt.Errorf("invalid request type") } - response, err := (*s.client).{{METHOD}}(ctx, request, opts...) + response, err := s.client.{{METHOD}}(ctx, request, opts...) return response, {{SERVICE}}V{{VERSION}}Response, err } From 9c11999ff9996e172886a23cef1bc104f8591307 Mon Sep 17 00:00:00 2001 From: "ev.lekht" Date: Fri, 22 Nov 2024 15:29:18 +0400 Subject: [PATCH 07/20] generated --- ...oductInfoService_AccommodationProductInfo_client_method.go | 2 +- .../accommodationv1_AccommodationProductInfoService_client.go | 4 ++-- ...oductListService_AccommodationProductList_client_method.go | 2 +- .../accommodationv1_AccommodationProductListService_client.go | 4 ++-- ...modationSearchService_AccommodationSearch_client_method.go | 2 +- .../accommodationv1_AccommodationSearchService_client.go | 4 ++-- ...oductInfoService_AccommodationProductInfo_client_method.go | 2 +- .../accommodationv2_AccommodationProductInfoService_client.go | 4 ++-- ...oductListService_AccommodationProductList_client_method.go | 2 +- .../accommodationv2_AccommodationProductListService_client.go | 4 ++-- ...modationSearchService_AccommodationSearch_client_method.go | 2 +- .../accommodationv2_AccommodationSearchService_client.go | 4 ++-- ...ityProductInfoService_ActivityProductInfo_client_method.go | 2 +- .../generated/activityv1_ActivityProductInfoService_client.go | 4 ++-- ...ityProductListService_ActivityProductList_client_method.go | 2 +- .../generated/activityv1_ActivityProductListService_client.go | 4 ++-- ...tyv1_ActivitySearchService_ActivitySearch_client_method.go | 2 +- .../rpc/generated/activityv1_ActivitySearchService_client.go | 4 ++-- ...ityProductInfoService_ActivityProductInfo_client_method.go | 2 +- .../generated/activityv2_ActivityProductInfoService_client.go | 4 ++-- ...ityProductListService_ActivityProductList_client_method.go | 2 +- .../generated/activityv2_ActivityProductListService_client.go | 4 ++-- ...tyv2_ActivitySearchService_ActivitySearch_client_method.go | 2 +- .../rpc/generated/activityv2_ActivitySearchService_client.go | 4 ++-- .../rpc/generated/bookv1_MintService_Mint_client_method.go | 2 +- internal/rpc/generated/bookv1_MintService_client.go | 4 ++-- .../bookv1_ValidationService_Validation_client_method.go | 2 +- internal/rpc/generated/bookv1_ValidationService_client.go | 4 ++-- .../rpc/generated/bookv2_MintService_Mint_client_method.go | 2 +- internal/rpc/generated/bookv2_MintService_client.go | 4 ++-- .../bookv2_ValidationService_Validation_client_method.go | 2 +- internal/rpc/generated/bookv2_ValidationService_client.go | 4 ++-- ...uirementsService_CountryEntryRequirements_client_method.go | 2 +- .../infov1_CountryEntryRequirementsService_client.go | 4 ++-- ...uirementsService_CountryEntryRequirements_client_method.go | 2 +- .../infov2_CountryEntryRequirementsService_client.go | 4 ++-- ...ceProductInfoService_InsuranceProductInfo_client_method.go | 2 +- .../insurancev1_InsuranceProductInfoService_client.go | 4 ++-- ...ceProductListService_InsuranceProductList_client_method.go | 2 +- .../insurancev1_InsuranceProductListService_client.go | 4 ++-- ...v1_InsuranceSearchService_InsuranceSearch_client_method.go | 2 +- .../generated/insurancev1_InsuranceSearchService_client.go | 4 ++-- ...workv1_GetNetworkFeeService_GetNetworkFee_client_method.go | 2 +- .../rpc/generated/networkv1_GetNetworkFeeService_client.go | 4 ++-- ...figurationService_GetPartnerConfiguration_client_method.go | 2 +- .../partnerv1_GetPartnerConfigurationService_client.go | 4 ++-- ...figurationService_GetPartnerConfiguration_client_method.go | 2 +- .../partnerv2_GetPartnerConfigurationService_client.go | 4 ++-- .../rpc/generated/pingv1_PingService_Ping_client_method.go | 2 +- internal/rpc/generated/pingv1_PingService_client.go | 4 ++-- ...apAvailabilityService_SeatMapAvailability_client_method.go | 2 +- .../generated/seat_mapv1_SeatMapAvailabilityService_client.go | 4 ++-- .../seat_mapv1_SeatMapService_SeatMap_client_method.go | 2 +- internal/rpc/generated/seat_mapv1_SeatMapService_client.go | 4 ++-- ...apAvailabilityService_SeatMapAvailability_client_method.go | 2 +- .../generated/seat_mapv2_SeatMapAvailabilityService_client.go | 4 ++-- .../seat_mapv2_SeatMapService_SeatMap_client_method.go | 2 +- internal/rpc/generated/seat_mapv2_SeatMapService_client.go | 4 ++-- ...v1_TransportSearchService_TransportSearch_client_method.go | 2 +- .../generated/transportv1_TransportSearchService_client.go | 4 ++-- ...v2_TransportSearchService_TransportSearch_client_method.go | 2 +- .../generated/transportv2_TransportSearchService_client.go | 4 ++-- 62 files changed, 93 insertions(+), 93 deletions(-) diff --git a/internal/rpc/generated/accommodationv1_AccommodationProductInfoService_AccommodationProductInfo_client_method.go b/internal/rpc/generated/accommodationv1_AccommodationProductInfoService_AccommodationProductInfo_client_method.go index 317137b9..c7ccbe32 100644 --- a/internal/rpc/generated/accommodationv1_AccommodationProductInfoService_AccommodationProductInfo_client_method.go +++ b/internal/rpc/generated/accommodationv1_AccommodationProductInfoService_AccommodationProductInfo_client_method.go @@ -19,6 +19,6 @@ func (s AccommodationProductInfoServiceV1Client) Call(ctx context.Context, reque if !ok { return nil, AccommodationProductInfoServiceV1Response, fmt.Errorf("invalid request type") } - response, err := (*s.client).AccommodationProductInfo(ctx, request, opts...) + response, err := s.client.AccommodationProductInfo(ctx, request, opts...) return response, AccommodationProductInfoServiceV1Response, err } diff --git a/internal/rpc/generated/accommodationv1_AccommodationProductInfoService_client.go b/internal/rpc/generated/accommodationv1_AccommodationProductInfoService_client.go index 571edb2d..f2c0b6bc 100644 --- a/internal/rpc/generated/accommodationv1_AccommodationProductInfoService_client.go +++ b/internal/rpc/generated/accommodationv1_AccommodationProductInfoService_client.go @@ -21,9 +21,9 @@ var _ rpc.Client = (*AccommodationProductInfoServiceV1Client)(nil) func NewAccommodationProductInfoServiceV1(grpcCon *grpc.ClientConn) *AccommodationProductInfoServiceV1Client { client := accommodationv1grpc.NewAccommodationProductInfoServiceClient(grpcCon) - return &AccommodationProductInfoServiceV1Client{client: &client} + return &AccommodationProductInfoServiceV1Client{client: client} } type AccommodationProductInfoServiceV1Client struct { - client *accommodationv1grpc.AccommodationProductInfoServiceClient + client accommodationv1grpc.AccommodationProductInfoServiceClient } diff --git a/internal/rpc/generated/accommodationv1_AccommodationProductListService_AccommodationProductList_client_method.go b/internal/rpc/generated/accommodationv1_AccommodationProductListService_AccommodationProductList_client_method.go index d8276212..a96faa52 100644 --- a/internal/rpc/generated/accommodationv1_AccommodationProductListService_AccommodationProductList_client_method.go +++ b/internal/rpc/generated/accommodationv1_AccommodationProductListService_AccommodationProductList_client_method.go @@ -19,6 +19,6 @@ func (s AccommodationProductListServiceV1Client) Call(ctx context.Context, reque if !ok { return nil, AccommodationProductListServiceV1Response, fmt.Errorf("invalid request type") } - response, err := (*s.client).AccommodationProductList(ctx, request, opts...) + response, err := s.client.AccommodationProductList(ctx, request, opts...) return response, AccommodationProductListServiceV1Response, err } diff --git a/internal/rpc/generated/accommodationv1_AccommodationProductListService_client.go b/internal/rpc/generated/accommodationv1_AccommodationProductListService_client.go index 65228209..2c188d26 100644 --- a/internal/rpc/generated/accommodationv1_AccommodationProductListService_client.go +++ b/internal/rpc/generated/accommodationv1_AccommodationProductListService_client.go @@ -21,9 +21,9 @@ var _ rpc.Client = (*AccommodationProductListServiceV1Client)(nil) func NewAccommodationProductListServiceV1(grpcCon *grpc.ClientConn) *AccommodationProductListServiceV1Client { client := accommodationv1grpc.NewAccommodationProductListServiceClient(grpcCon) - return &AccommodationProductListServiceV1Client{client: &client} + return &AccommodationProductListServiceV1Client{client: client} } type AccommodationProductListServiceV1Client struct { - client *accommodationv1grpc.AccommodationProductListServiceClient + client accommodationv1grpc.AccommodationProductListServiceClient } diff --git a/internal/rpc/generated/accommodationv1_AccommodationSearchService_AccommodationSearch_client_method.go b/internal/rpc/generated/accommodationv1_AccommodationSearchService_AccommodationSearch_client_method.go index 4a7d1a95..9c48510f 100644 --- a/internal/rpc/generated/accommodationv1_AccommodationSearchService_AccommodationSearch_client_method.go +++ b/internal/rpc/generated/accommodationv1_AccommodationSearchService_AccommodationSearch_client_method.go @@ -19,6 +19,6 @@ func (s AccommodationSearchServiceV1Client) Call(ctx context.Context, requestInt if !ok { return nil, AccommodationSearchServiceV1Response, fmt.Errorf("invalid request type") } - response, err := (*s.client).AccommodationSearch(ctx, request, opts...) + response, err := s.client.AccommodationSearch(ctx, request, opts...) return response, AccommodationSearchServiceV1Response, err } diff --git a/internal/rpc/generated/accommodationv1_AccommodationSearchService_client.go b/internal/rpc/generated/accommodationv1_AccommodationSearchService_client.go index 7c0a4c3b..871b529d 100644 --- a/internal/rpc/generated/accommodationv1_AccommodationSearchService_client.go +++ b/internal/rpc/generated/accommodationv1_AccommodationSearchService_client.go @@ -21,9 +21,9 @@ var _ rpc.Client = (*AccommodationSearchServiceV1Client)(nil) func NewAccommodationSearchServiceV1(grpcCon *grpc.ClientConn) *AccommodationSearchServiceV1Client { client := accommodationv1grpc.NewAccommodationSearchServiceClient(grpcCon) - return &AccommodationSearchServiceV1Client{client: &client} + return &AccommodationSearchServiceV1Client{client: client} } type AccommodationSearchServiceV1Client struct { - client *accommodationv1grpc.AccommodationSearchServiceClient + client accommodationv1grpc.AccommodationSearchServiceClient } diff --git a/internal/rpc/generated/accommodationv2_AccommodationProductInfoService_AccommodationProductInfo_client_method.go b/internal/rpc/generated/accommodationv2_AccommodationProductInfoService_AccommodationProductInfo_client_method.go index c8c3f4d1..12fc6cfd 100644 --- a/internal/rpc/generated/accommodationv2_AccommodationProductInfoService_AccommodationProductInfo_client_method.go +++ b/internal/rpc/generated/accommodationv2_AccommodationProductInfoService_AccommodationProductInfo_client_method.go @@ -19,6 +19,6 @@ func (s AccommodationProductInfoServiceV2Client) Call(ctx context.Context, reque if !ok { return nil, AccommodationProductInfoServiceV2Response, fmt.Errorf("invalid request type") } - response, err := (*s.client).AccommodationProductInfo(ctx, request, opts...) + response, err := s.client.AccommodationProductInfo(ctx, request, opts...) return response, AccommodationProductInfoServiceV2Response, err } diff --git a/internal/rpc/generated/accommodationv2_AccommodationProductInfoService_client.go b/internal/rpc/generated/accommodationv2_AccommodationProductInfoService_client.go index ef8117da..f9b0b9d5 100644 --- a/internal/rpc/generated/accommodationv2_AccommodationProductInfoService_client.go +++ b/internal/rpc/generated/accommodationv2_AccommodationProductInfoService_client.go @@ -21,9 +21,9 @@ var _ rpc.Client = (*AccommodationProductInfoServiceV2Client)(nil) func NewAccommodationProductInfoServiceV2(grpcCon *grpc.ClientConn) *AccommodationProductInfoServiceV2Client { client := accommodationv2grpc.NewAccommodationProductInfoServiceClient(grpcCon) - return &AccommodationProductInfoServiceV2Client{client: &client} + return &AccommodationProductInfoServiceV2Client{client: client} } type AccommodationProductInfoServiceV2Client struct { - client *accommodationv2grpc.AccommodationProductInfoServiceClient + client accommodationv2grpc.AccommodationProductInfoServiceClient } diff --git a/internal/rpc/generated/accommodationv2_AccommodationProductListService_AccommodationProductList_client_method.go b/internal/rpc/generated/accommodationv2_AccommodationProductListService_AccommodationProductList_client_method.go index 4464e5a3..dfb632a5 100644 --- a/internal/rpc/generated/accommodationv2_AccommodationProductListService_AccommodationProductList_client_method.go +++ b/internal/rpc/generated/accommodationv2_AccommodationProductListService_AccommodationProductList_client_method.go @@ -19,6 +19,6 @@ func (s AccommodationProductListServiceV2Client) Call(ctx context.Context, reque if !ok { return nil, AccommodationProductListServiceV2Response, fmt.Errorf("invalid request type") } - response, err := (*s.client).AccommodationProductList(ctx, request, opts...) + response, err := s.client.AccommodationProductList(ctx, request, opts...) return response, AccommodationProductListServiceV2Response, err } diff --git a/internal/rpc/generated/accommodationv2_AccommodationProductListService_client.go b/internal/rpc/generated/accommodationv2_AccommodationProductListService_client.go index b953c287..8657930e 100644 --- a/internal/rpc/generated/accommodationv2_AccommodationProductListService_client.go +++ b/internal/rpc/generated/accommodationv2_AccommodationProductListService_client.go @@ -21,9 +21,9 @@ var _ rpc.Client = (*AccommodationProductListServiceV2Client)(nil) func NewAccommodationProductListServiceV2(grpcCon *grpc.ClientConn) *AccommodationProductListServiceV2Client { client := accommodationv2grpc.NewAccommodationProductListServiceClient(grpcCon) - return &AccommodationProductListServiceV2Client{client: &client} + return &AccommodationProductListServiceV2Client{client: client} } type AccommodationProductListServiceV2Client struct { - client *accommodationv2grpc.AccommodationProductListServiceClient + client accommodationv2grpc.AccommodationProductListServiceClient } diff --git a/internal/rpc/generated/accommodationv2_AccommodationSearchService_AccommodationSearch_client_method.go b/internal/rpc/generated/accommodationv2_AccommodationSearchService_AccommodationSearch_client_method.go index 2f5845f0..2c7af160 100644 --- a/internal/rpc/generated/accommodationv2_AccommodationSearchService_AccommodationSearch_client_method.go +++ b/internal/rpc/generated/accommodationv2_AccommodationSearchService_AccommodationSearch_client_method.go @@ -19,6 +19,6 @@ func (s AccommodationSearchServiceV2Client) Call(ctx context.Context, requestInt if !ok { return nil, AccommodationSearchServiceV2Response, fmt.Errorf("invalid request type") } - response, err := (*s.client).AccommodationSearch(ctx, request, opts...) + response, err := s.client.AccommodationSearch(ctx, request, opts...) return response, AccommodationSearchServiceV2Response, err } diff --git a/internal/rpc/generated/accommodationv2_AccommodationSearchService_client.go b/internal/rpc/generated/accommodationv2_AccommodationSearchService_client.go index cf163196..c3a83f8d 100644 --- a/internal/rpc/generated/accommodationv2_AccommodationSearchService_client.go +++ b/internal/rpc/generated/accommodationv2_AccommodationSearchService_client.go @@ -21,9 +21,9 @@ var _ rpc.Client = (*AccommodationSearchServiceV2Client)(nil) func NewAccommodationSearchServiceV2(grpcCon *grpc.ClientConn) *AccommodationSearchServiceV2Client { client := accommodationv2grpc.NewAccommodationSearchServiceClient(grpcCon) - return &AccommodationSearchServiceV2Client{client: &client} + return &AccommodationSearchServiceV2Client{client: client} } type AccommodationSearchServiceV2Client struct { - client *accommodationv2grpc.AccommodationSearchServiceClient + client accommodationv2grpc.AccommodationSearchServiceClient } diff --git a/internal/rpc/generated/activityv1_ActivityProductInfoService_ActivityProductInfo_client_method.go b/internal/rpc/generated/activityv1_ActivityProductInfoService_ActivityProductInfo_client_method.go index 4a9dc013..453f7c35 100644 --- a/internal/rpc/generated/activityv1_ActivityProductInfoService_ActivityProductInfo_client_method.go +++ b/internal/rpc/generated/activityv1_ActivityProductInfoService_ActivityProductInfo_client_method.go @@ -19,6 +19,6 @@ func (s ActivityProductInfoServiceV1Client) Call(ctx context.Context, requestInt if !ok { return nil, ActivityProductInfoServiceV1Response, fmt.Errorf("invalid request type") } - response, err := (*s.client).ActivityProductInfo(ctx, request, opts...) + response, err := s.client.ActivityProductInfo(ctx, request, opts...) return response, ActivityProductInfoServiceV1Response, err } diff --git a/internal/rpc/generated/activityv1_ActivityProductInfoService_client.go b/internal/rpc/generated/activityv1_ActivityProductInfoService_client.go index 0d51dee7..aa599a68 100644 --- a/internal/rpc/generated/activityv1_ActivityProductInfoService_client.go +++ b/internal/rpc/generated/activityv1_ActivityProductInfoService_client.go @@ -21,9 +21,9 @@ var _ rpc.Client = (*ActivityProductInfoServiceV1Client)(nil) func NewActivityProductInfoServiceV1(grpcCon *grpc.ClientConn) *ActivityProductInfoServiceV1Client { client := activityv1grpc.NewActivityProductInfoServiceClient(grpcCon) - return &ActivityProductInfoServiceV1Client{client: &client} + return &ActivityProductInfoServiceV1Client{client: client} } type ActivityProductInfoServiceV1Client struct { - client *activityv1grpc.ActivityProductInfoServiceClient + client activityv1grpc.ActivityProductInfoServiceClient } diff --git a/internal/rpc/generated/activityv1_ActivityProductListService_ActivityProductList_client_method.go b/internal/rpc/generated/activityv1_ActivityProductListService_ActivityProductList_client_method.go index 5e83dea4..7821875c 100644 --- a/internal/rpc/generated/activityv1_ActivityProductListService_ActivityProductList_client_method.go +++ b/internal/rpc/generated/activityv1_ActivityProductListService_ActivityProductList_client_method.go @@ -19,6 +19,6 @@ func (s ActivityProductListServiceV1Client) Call(ctx context.Context, requestInt if !ok { return nil, ActivityProductListServiceV1Response, fmt.Errorf("invalid request type") } - response, err := (*s.client).ActivityProductList(ctx, request, opts...) + response, err := s.client.ActivityProductList(ctx, request, opts...) return response, ActivityProductListServiceV1Response, err } diff --git a/internal/rpc/generated/activityv1_ActivityProductListService_client.go b/internal/rpc/generated/activityv1_ActivityProductListService_client.go index c8f682f7..57fa04f2 100644 --- a/internal/rpc/generated/activityv1_ActivityProductListService_client.go +++ b/internal/rpc/generated/activityv1_ActivityProductListService_client.go @@ -21,9 +21,9 @@ var _ rpc.Client = (*ActivityProductListServiceV1Client)(nil) func NewActivityProductListServiceV1(grpcCon *grpc.ClientConn) *ActivityProductListServiceV1Client { client := activityv1grpc.NewActivityProductListServiceClient(grpcCon) - return &ActivityProductListServiceV1Client{client: &client} + return &ActivityProductListServiceV1Client{client: client} } type ActivityProductListServiceV1Client struct { - client *activityv1grpc.ActivityProductListServiceClient + client activityv1grpc.ActivityProductListServiceClient } diff --git a/internal/rpc/generated/activityv1_ActivitySearchService_ActivitySearch_client_method.go b/internal/rpc/generated/activityv1_ActivitySearchService_ActivitySearch_client_method.go index f1b73eca..c8ca2293 100644 --- a/internal/rpc/generated/activityv1_ActivitySearchService_ActivitySearch_client_method.go +++ b/internal/rpc/generated/activityv1_ActivitySearchService_ActivitySearch_client_method.go @@ -19,6 +19,6 @@ func (s ActivitySearchServiceV1Client) Call(ctx context.Context, requestIntf pro if !ok { return nil, ActivitySearchServiceV1Response, fmt.Errorf("invalid request type") } - response, err := (*s.client).ActivitySearch(ctx, request, opts...) + response, err := s.client.ActivitySearch(ctx, request, opts...) return response, ActivitySearchServiceV1Response, err } diff --git a/internal/rpc/generated/activityv1_ActivitySearchService_client.go b/internal/rpc/generated/activityv1_ActivitySearchService_client.go index 9874c457..64309192 100644 --- a/internal/rpc/generated/activityv1_ActivitySearchService_client.go +++ b/internal/rpc/generated/activityv1_ActivitySearchService_client.go @@ -21,9 +21,9 @@ var _ rpc.Client = (*ActivitySearchServiceV1Client)(nil) func NewActivitySearchServiceV1(grpcCon *grpc.ClientConn) *ActivitySearchServiceV1Client { client := activityv1grpc.NewActivitySearchServiceClient(grpcCon) - return &ActivitySearchServiceV1Client{client: &client} + return &ActivitySearchServiceV1Client{client: client} } type ActivitySearchServiceV1Client struct { - client *activityv1grpc.ActivitySearchServiceClient + client activityv1grpc.ActivitySearchServiceClient } diff --git a/internal/rpc/generated/activityv2_ActivityProductInfoService_ActivityProductInfo_client_method.go b/internal/rpc/generated/activityv2_ActivityProductInfoService_ActivityProductInfo_client_method.go index 38b91ad0..02e68dda 100644 --- a/internal/rpc/generated/activityv2_ActivityProductInfoService_ActivityProductInfo_client_method.go +++ b/internal/rpc/generated/activityv2_ActivityProductInfoService_ActivityProductInfo_client_method.go @@ -19,6 +19,6 @@ func (s ActivityProductInfoServiceV2Client) Call(ctx context.Context, requestInt if !ok { return nil, ActivityProductInfoServiceV2Response, fmt.Errorf("invalid request type") } - response, err := (*s.client).ActivityProductInfo(ctx, request, opts...) + response, err := s.client.ActivityProductInfo(ctx, request, opts...) return response, ActivityProductInfoServiceV2Response, err } diff --git a/internal/rpc/generated/activityv2_ActivityProductInfoService_client.go b/internal/rpc/generated/activityv2_ActivityProductInfoService_client.go index e21dbd9a..c97de0e0 100644 --- a/internal/rpc/generated/activityv2_ActivityProductInfoService_client.go +++ b/internal/rpc/generated/activityv2_ActivityProductInfoService_client.go @@ -21,9 +21,9 @@ var _ rpc.Client = (*ActivityProductInfoServiceV2Client)(nil) func NewActivityProductInfoServiceV2(grpcCon *grpc.ClientConn) *ActivityProductInfoServiceV2Client { client := activityv2grpc.NewActivityProductInfoServiceClient(grpcCon) - return &ActivityProductInfoServiceV2Client{client: &client} + return &ActivityProductInfoServiceV2Client{client: client} } type ActivityProductInfoServiceV2Client struct { - client *activityv2grpc.ActivityProductInfoServiceClient + client activityv2grpc.ActivityProductInfoServiceClient } diff --git a/internal/rpc/generated/activityv2_ActivityProductListService_ActivityProductList_client_method.go b/internal/rpc/generated/activityv2_ActivityProductListService_ActivityProductList_client_method.go index 9ef917f4..9013a829 100644 --- a/internal/rpc/generated/activityv2_ActivityProductListService_ActivityProductList_client_method.go +++ b/internal/rpc/generated/activityv2_ActivityProductListService_ActivityProductList_client_method.go @@ -19,6 +19,6 @@ func (s ActivityProductListServiceV2Client) Call(ctx context.Context, requestInt if !ok { return nil, ActivityProductListServiceV2Response, fmt.Errorf("invalid request type") } - response, err := (*s.client).ActivityProductList(ctx, request, opts...) + response, err := s.client.ActivityProductList(ctx, request, opts...) return response, ActivityProductListServiceV2Response, err } diff --git a/internal/rpc/generated/activityv2_ActivityProductListService_client.go b/internal/rpc/generated/activityv2_ActivityProductListService_client.go index db67261c..f75db7a6 100644 --- a/internal/rpc/generated/activityv2_ActivityProductListService_client.go +++ b/internal/rpc/generated/activityv2_ActivityProductListService_client.go @@ -21,9 +21,9 @@ var _ rpc.Client = (*ActivityProductListServiceV2Client)(nil) func NewActivityProductListServiceV2(grpcCon *grpc.ClientConn) *ActivityProductListServiceV2Client { client := activityv2grpc.NewActivityProductListServiceClient(grpcCon) - return &ActivityProductListServiceV2Client{client: &client} + return &ActivityProductListServiceV2Client{client: client} } type ActivityProductListServiceV2Client struct { - client *activityv2grpc.ActivityProductListServiceClient + client activityv2grpc.ActivityProductListServiceClient } diff --git a/internal/rpc/generated/activityv2_ActivitySearchService_ActivitySearch_client_method.go b/internal/rpc/generated/activityv2_ActivitySearchService_ActivitySearch_client_method.go index 24da59d2..ec066926 100644 --- a/internal/rpc/generated/activityv2_ActivitySearchService_ActivitySearch_client_method.go +++ b/internal/rpc/generated/activityv2_ActivitySearchService_ActivitySearch_client_method.go @@ -19,6 +19,6 @@ func (s ActivitySearchServiceV2Client) Call(ctx context.Context, requestIntf pro if !ok { return nil, ActivitySearchServiceV2Response, fmt.Errorf("invalid request type") } - response, err := (*s.client).ActivitySearch(ctx, request, opts...) + response, err := s.client.ActivitySearch(ctx, request, opts...) return response, ActivitySearchServiceV2Response, err } diff --git a/internal/rpc/generated/activityv2_ActivitySearchService_client.go b/internal/rpc/generated/activityv2_ActivitySearchService_client.go index 7e77e4a2..d07d1bac 100644 --- a/internal/rpc/generated/activityv2_ActivitySearchService_client.go +++ b/internal/rpc/generated/activityv2_ActivitySearchService_client.go @@ -21,9 +21,9 @@ var _ rpc.Client = (*ActivitySearchServiceV2Client)(nil) func NewActivitySearchServiceV2(grpcCon *grpc.ClientConn) *ActivitySearchServiceV2Client { client := activityv2grpc.NewActivitySearchServiceClient(grpcCon) - return &ActivitySearchServiceV2Client{client: &client} + return &ActivitySearchServiceV2Client{client: client} } type ActivitySearchServiceV2Client struct { - client *activityv2grpc.ActivitySearchServiceClient + client activityv2grpc.ActivitySearchServiceClient } diff --git a/internal/rpc/generated/bookv1_MintService_Mint_client_method.go b/internal/rpc/generated/bookv1_MintService_Mint_client_method.go index 60365fd6..89829c01 100644 --- a/internal/rpc/generated/bookv1_MintService_Mint_client_method.go +++ b/internal/rpc/generated/bookv1_MintService_Mint_client_method.go @@ -19,6 +19,6 @@ func (s MintServiceV1Client) Call(ctx context.Context, requestIntf protoreflect. if !ok { return nil, MintServiceV1Response, fmt.Errorf("invalid request type") } - response, err := (*s.client).Mint(ctx, request, opts...) + response, err := s.client.Mint(ctx, request, opts...) return response, MintServiceV1Response, err } diff --git a/internal/rpc/generated/bookv1_MintService_client.go b/internal/rpc/generated/bookv1_MintService_client.go index fc342fa5..2803d7d9 100644 --- a/internal/rpc/generated/bookv1_MintService_client.go +++ b/internal/rpc/generated/bookv1_MintService_client.go @@ -21,9 +21,9 @@ var _ rpc.Client = (*MintServiceV1Client)(nil) func NewMintServiceV1(grpcCon *grpc.ClientConn) *MintServiceV1Client { client := bookv1grpc.NewMintServiceClient(grpcCon) - return &MintServiceV1Client{client: &client} + return &MintServiceV1Client{client: client} } type MintServiceV1Client struct { - client *bookv1grpc.MintServiceClient + client bookv1grpc.MintServiceClient } diff --git a/internal/rpc/generated/bookv1_ValidationService_Validation_client_method.go b/internal/rpc/generated/bookv1_ValidationService_Validation_client_method.go index 038f391b..d376d604 100644 --- a/internal/rpc/generated/bookv1_ValidationService_Validation_client_method.go +++ b/internal/rpc/generated/bookv1_ValidationService_Validation_client_method.go @@ -19,6 +19,6 @@ func (s ValidationServiceV1Client) Call(ctx context.Context, requestIntf protore if !ok { return nil, ValidationServiceV1Response, fmt.Errorf("invalid request type") } - response, err := (*s.client).Validation(ctx, request, opts...) + response, err := s.client.Validation(ctx, request, opts...) return response, ValidationServiceV1Response, err } diff --git a/internal/rpc/generated/bookv1_ValidationService_client.go b/internal/rpc/generated/bookv1_ValidationService_client.go index 7463c414..8b14aa4a 100644 --- a/internal/rpc/generated/bookv1_ValidationService_client.go +++ b/internal/rpc/generated/bookv1_ValidationService_client.go @@ -21,9 +21,9 @@ var _ rpc.Client = (*ValidationServiceV1Client)(nil) func NewValidationServiceV1(grpcCon *grpc.ClientConn) *ValidationServiceV1Client { client := bookv1grpc.NewValidationServiceClient(grpcCon) - return &ValidationServiceV1Client{client: &client} + return &ValidationServiceV1Client{client: client} } type ValidationServiceV1Client struct { - client *bookv1grpc.ValidationServiceClient + client bookv1grpc.ValidationServiceClient } diff --git a/internal/rpc/generated/bookv2_MintService_Mint_client_method.go b/internal/rpc/generated/bookv2_MintService_Mint_client_method.go index a6a41bab..336d0fee 100644 --- a/internal/rpc/generated/bookv2_MintService_Mint_client_method.go +++ b/internal/rpc/generated/bookv2_MintService_Mint_client_method.go @@ -19,6 +19,6 @@ func (s MintServiceV2Client) Call(ctx context.Context, requestIntf protoreflect. if !ok { return nil, MintServiceV2Response, fmt.Errorf("invalid request type") } - response, err := (*s.client).Mint(ctx, request, opts...) + response, err := s.client.Mint(ctx, request, opts...) return response, MintServiceV2Response, err } diff --git a/internal/rpc/generated/bookv2_MintService_client.go b/internal/rpc/generated/bookv2_MintService_client.go index 4f4f835e..48f1874a 100644 --- a/internal/rpc/generated/bookv2_MintService_client.go +++ b/internal/rpc/generated/bookv2_MintService_client.go @@ -21,9 +21,9 @@ var _ rpc.Client = (*MintServiceV2Client)(nil) func NewMintServiceV2(grpcCon *grpc.ClientConn) *MintServiceV2Client { client := bookv2grpc.NewMintServiceClient(grpcCon) - return &MintServiceV2Client{client: &client} + return &MintServiceV2Client{client: client} } type MintServiceV2Client struct { - client *bookv2grpc.MintServiceClient + client bookv2grpc.MintServiceClient } diff --git a/internal/rpc/generated/bookv2_ValidationService_Validation_client_method.go b/internal/rpc/generated/bookv2_ValidationService_Validation_client_method.go index 59c87ac7..258a2a9f 100644 --- a/internal/rpc/generated/bookv2_ValidationService_Validation_client_method.go +++ b/internal/rpc/generated/bookv2_ValidationService_Validation_client_method.go @@ -19,6 +19,6 @@ func (s ValidationServiceV2Client) Call(ctx context.Context, requestIntf protore if !ok { return nil, ValidationServiceV2Response, fmt.Errorf("invalid request type") } - response, err := (*s.client).Validation(ctx, request, opts...) + response, err := s.client.Validation(ctx, request, opts...) return response, ValidationServiceV2Response, err } diff --git a/internal/rpc/generated/bookv2_ValidationService_client.go b/internal/rpc/generated/bookv2_ValidationService_client.go index 1a51bf62..6b257f41 100644 --- a/internal/rpc/generated/bookv2_ValidationService_client.go +++ b/internal/rpc/generated/bookv2_ValidationService_client.go @@ -21,9 +21,9 @@ var _ rpc.Client = (*ValidationServiceV2Client)(nil) func NewValidationServiceV2(grpcCon *grpc.ClientConn) *ValidationServiceV2Client { client := bookv2grpc.NewValidationServiceClient(grpcCon) - return &ValidationServiceV2Client{client: &client} + return &ValidationServiceV2Client{client: client} } type ValidationServiceV2Client struct { - client *bookv2grpc.ValidationServiceClient + client bookv2grpc.ValidationServiceClient } diff --git a/internal/rpc/generated/infov1_CountryEntryRequirementsService_CountryEntryRequirements_client_method.go b/internal/rpc/generated/infov1_CountryEntryRequirementsService_CountryEntryRequirements_client_method.go index f751b6ce..73f34180 100644 --- a/internal/rpc/generated/infov1_CountryEntryRequirementsService_CountryEntryRequirements_client_method.go +++ b/internal/rpc/generated/infov1_CountryEntryRequirementsService_CountryEntryRequirements_client_method.go @@ -19,6 +19,6 @@ func (s CountryEntryRequirementsServiceV1Client) Call(ctx context.Context, reque if !ok { return nil, CountryEntryRequirementsServiceV1Response, fmt.Errorf("invalid request type") } - response, err := (*s.client).CountryEntryRequirements(ctx, request, opts...) + response, err := s.client.CountryEntryRequirements(ctx, request, opts...) return response, CountryEntryRequirementsServiceV1Response, err } diff --git a/internal/rpc/generated/infov1_CountryEntryRequirementsService_client.go b/internal/rpc/generated/infov1_CountryEntryRequirementsService_client.go index 0dba3f45..7211d649 100644 --- a/internal/rpc/generated/infov1_CountryEntryRequirementsService_client.go +++ b/internal/rpc/generated/infov1_CountryEntryRequirementsService_client.go @@ -21,9 +21,9 @@ var _ rpc.Client = (*CountryEntryRequirementsServiceV1Client)(nil) func NewCountryEntryRequirementsServiceV1(grpcCon *grpc.ClientConn) *CountryEntryRequirementsServiceV1Client { client := infov1grpc.NewCountryEntryRequirementsServiceClient(grpcCon) - return &CountryEntryRequirementsServiceV1Client{client: &client} + return &CountryEntryRequirementsServiceV1Client{client: client} } type CountryEntryRequirementsServiceV1Client struct { - client *infov1grpc.CountryEntryRequirementsServiceClient + client infov1grpc.CountryEntryRequirementsServiceClient } diff --git a/internal/rpc/generated/infov2_CountryEntryRequirementsService_CountryEntryRequirements_client_method.go b/internal/rpc/generated/infov2_CountryEntryRequirementsService_CountryEntryRequirements_client_method.go index c2d3f68e..c3f89963 100644 --- a/internal/rpc/generated/infov2_CountryEntryRequirementsService_CountryEntryRequirements_client_method.go +++ b/internal/rpc/generated/infov2_CountryEntryRequirementsService_CountryEntryRequirements_client_method.go @@ -19,6 +19,6 @@ func (s CountryEntryRequirementsServiceV2Client) Call(ctx context.Context, reque if !ok { return nil, CountryEntryRequirementsServiceV2Response, fmt.Errorf("invalid request type") } - response, err := (*s.client).CountryEntryRequirements(ctx, request, opts...) + response, err := s.client.CountryEntryRequirements(ctx, request, opts...) return response, CountryEntryRequirementsServiceV2Response, err } diff --git a/internal/rpc/generated/infov2_CountryEntryRequirementsService_client.go b/internal/rpc/generated/infov2_CountryEntryRequirementsService_client.go index 7d612ff1..3e9d013d 100644 --- a/internal/rpc/generated/infov2_CountryEntryRequirementsService_client.go +++ b/internal/rpc/generated/infov2_CountryEntryRequirementsService_client.go @@ -21,9 +21,9 @@ var _ rpc.Client = (*CountryEntryRequirementsServiceV2Client)(nil) func NewCountryEntryRequirementsServiceV2(grpcCon *grpc.ClientConn) *CountryEntryRequirementsServiceV2Client { client := infov2grpc.NewCountryEntryRequirementsServiceClient(grpcCon) - return &CountryEntryRequirementsServiceV2Client{client: &client} + return &CountryEntryRequirementsServiceV2Client{client: client} } type CountryEntryRequirementsServiceV2Client struct { - client *infov2grpc.CountryEntryRequirementsServiceClient + client infov2grpc.CountryEntryRequirementsServiceClient } diff --git a/internal/rpc/generated/insurancev1_InsuranceProductInfoService_InsuranceProductInfo_client_method.go b/internal/rpc/generated/insurancev1_InsuranceProductInfoService_InsuranceProductInfo_client_method.go index 9baeb281..3959a7cc 100644 --- a/internal/rpc/generated/insurancev1_InsuranceProductInfoService_InsuranceProductInfo_client_method.go +++ b/internal/rpc/generated/insurancev1_InsuranceProductInfoService_InsuranceProductInfo_client_method.go @@ -19,6 +19,6 @@ func (s InsuranceProductInfoServiceV1Client) Call(ctx context.Context, requestIn if !ok { return nil, InsuranceProductInfoServiceV1Response, fmt.Errorf("invalid request type") } - response, err := (*s.client).InsuranceProductInfo(ctx, request, opts...) + response, err := s.client.InsuranceProductInfo(ctx, request, opts...) return response, InsuranceProductInfoServiceV1Response, err } diff --git a/internal/rpc/generated/insurancev1_InsuranceProductInfoService_client.go b/internal/rpc/generated/insurancev1_InsuranceProductInfoService_client.go index 44d92d83..1ddc059d 100644 --- a/internal/rpc/generated/insurancev1_InsuranceProductInfoService_client.go +++ b/internal/rpc/generated/insurancev1_InsuranceProductInfoService_client.go @@ -21,9 +21,9 @@ var _ rpc.Client = (*InsuranceProductInfoServiceV1Client)(nil) func NewInsuranceProductInfoServiceV1(grpcCon *grpc.ClientConn) *InsuranceProductInfoServiceV1Client { client := insurancev1grpc.NewInsuranceProductInfoServiceClient(grpcCon) - return &InsuranceProductInfoServiceV1Client{client: &client} + return &InsuranceProductInfoServiceV1Client{client: client} } type InsuranceProductInfoServiceV1Client struct { - client *insurancev1grpc.InsuranceProductInfoServiceClient + client insurancev1grpc.InsuranceProductInfoServiceClient } diff --git a/internal/rpc/generated/insurancev1_InsuranceProductListService_InsuranceProductList_client_method.go b/internal/rpc/generated/insurancev1_InsuranceProductListService_InsuranceProductList_client_method.go index ed8e570d..e1fec41b 100644 --- a/internal/rpc/generated/insurancev1_InsuranceProductListService_InsuranceProductList_client_method.go +++ b/internal/rpc/generated/insurancev1_InsuranceProductListService_InsuranceProductList_client_method.go @@ -19,6 +19,6 @@ func (s InsuranceProductListServiceV1Client) Call(ctx context.Context, requestIn if !ok { return nil, InsuranceProductListServiceV1Response, fmt.Errorf("invalid request type") } - response, err := (*s.client).InsuranceProductList(ctx, request, opts...) + response, err := s.client.InsuranceProductList(ctx, request, opts...) return response, InsuranceProductListServiceV1Response, err } diff --git a/internal/rpc/generated/insurancev1_InsuranceProductListService_client.go b/internal/rpc/generated/insurancev1_InsuranceProductListService_client.go index f1d3b054..3e79e356 100644 --- a/internal/rpc/generated/insurancev1_InsuranceProductListService_client.go +++ b/internal/rpc/generated/insurancev1_InsuranceProductListService_client.go @@ -21,9 +21,9 @@ var _ rpc.Client = (*InsuranceProductListServiceV1Client)(nil) func NewInsuranceProductListServiceV1(grpcCon *grpc.ClientConn) *InsuranceProductListServiceV1Client { client := insurancev1grpc.NewInsuranceProductListServiceClient(grpcCon) - return &InsuranceProductListServiceV1Client{client: &client} + return &InsuranceProductListServiceV1Client{client: client} } type InsuranceProductListServiceV1Client struct { - client *insurancev1grpc.InsuranceProductListServiceClient + client insurancev1grpc.InsuranceProductListServiceClient } diff --git a/internal/rpc/generated/insurancev1_InsuranceSearchService_InsuranceSearch_client_method.go b/internal/rpc/generated/insurancev1_InsuranceSearchService_InsuranceSearch_client_method.go index 9d1de569..ceea9926 100644 --- a/internal/rpc/generated/insurancev1_InsuranceSearchService_InsuranceSearch_client_method.go +++ b/internal/rpc/generated/insurancev1_InsuranceSearchService_InsuranceSearch_client_method.go @@ -19,6 +19,6 @@ func (s InsuranceSearchServiceV1Client) Call(ctx context.Context, requestIntf pr if !ok { return nil, InsuranceSearchServiceV1Response, fmt.Errorf("invalid request type") } - response, err := (*s.client).InsuranceSearch(ctx, request, opts...) + response, err := s.client.InsuranceSearch(ctx, request, opts...) return response, InsuranceSearchServiceV1Response, err } diff --git a/internal/rpc/generated/insurancev1_InsuranceSearchService_client.go b/internal/rpc/generated/insurancev1_InsuranceSearchService_client.go index 6d6b862b..0a4611d9 100644 --- a/internal/rpc/generated/insurancev1_InsuranceSearchService_client.go +++ b/internal/rpc/generated/insurancev1_InsuranceSearchService_client.go @@ -21,9 +21,9 @@ var _ rpc.Client = (*InsuranceSearchServiceV1Client)(nil) func NewInsuranceSearchServiceV1(grpcCon *grpc.ClientConn) *InsuranceSearchServiceV1Client { client := insurancev1grpc.NewInsuranceSearchServiceClient(grpcCon) - return &InsuranceSearchServiceV1Client{client: &client} + return &InsuranceSearchServiceV1Client{client: client} } type InsuranceSearchServiceV1Client struct { - client *insurancev1grpc.InsuranceSearchServiceClient + client insurancev1grpc.InsuranceSearchServiceClient } diff --git a/internal/rpc/generated/networkv1_GetNetworkFeeService_GetNetworkFee_client_method.go b/internal/rpc/generated/networkv1_GetNetworkFeeService_GetNetworkFee_client_method.go index ddd345b1..9490ff17 100644 --- a/internal/rpc/generated/networkv1_GetNetworkFeeService_GetNetworkFee_client_method.go +++ b/internal/rpc/generated/networkv1_GetNetworkFeeService_GetNetworkFee_client_method.go @@ -19,6 +19,6 @@ func (s GetNetworkFeeServiceV1Client) Call(ctx context.Context, requestIntf prot if !ok { return nil, GetNetworkFeeServiceV1Response, fmt.Errorf("invalid request type") } - response, err := (*s.client).GetNetworkFee(ctx, request, opts...) + response, err := s.client.GetNetworkFee(ctx, request, opts...) return response, GetNetworkFeeServiceV1Response, err } diff --git a/internal/rpc/generated/networkv1_GetNetworkFeeService_client.go b/internal/rpc/generated/networkv1_GetNetworkFeeService_client.go index 07dfb570..f7765c36 100644 --- a/internal/rpc/generated/networkv1_GetNetworkFeeService_client.go +++ b/internal/rpc/generated/networkv1_GetNetworkFeeService_client.go @@ -21,9 +21,9 @@ var _ rpc.Client = (*GetNetworkFeeServiceV1Client)(nil) func NewGetNetworkFeeServiceV1(grpcCon *grpc.ClientConn) *GetNetworkFeeServiceV1Client { client := networkv1grpc.NewGetNetworkFeeServiceClient(grpcCon) - return &GetNetworkFeeServiceV1Client{client: &client} + return &GetNetworkFeeServiceV1Client{client: client} } type GetNetworkFeeServiceV1Client struct { - client *networkv1grpc.GetNetworkFeeServiceClient + client networkv1grpc.GetNetworkFeeServiceClient } diff --git a/internal/rpc/generated/partnerv1_GetPartnerConfigurationService_GetPartnerConfiguration_client_method.go b/internal/rpc/generated/partnerv1_GetPartnerConfigurationService_GetPartnerConfiguration_client_method.go index e4dba402..89a39b82 100644 --- a/internal/rpc/generated/partnerv1_GetPartnerConfigurationService_GetPartnerConfiguration_client_method.go +++ b/internal/rpc/generated/partnerv1_GetPartnerConfigurationService_GetPartnerConfiguration_client_method.go @@ -19,6 +19,6 @@ func (s GetPartnerConfigurationServiceV1Client) Call(ctx context.Context, reques if !ok { return nil, GetPartnerConfigurationServiceV1Response, fmt.Errorf("invalid request type") } - response, err := (*s.client).GetPartnerConfiguration(ctx, request, opts...) + response, err := s.client.GetPartnerConfiguration(ctx, request, opts...) return response, GetPartnerConfigurationServiceV1Response, err } diff --git a/internal/rpc/generated/partnerv1_GetPartnerConfigurationService_client.go b/internal/rpc/generated/partnerv1_GetPartnerConfigurationService_client.go index 04d8f4aa..c30ac95a 100644 --- a/internal/rpc/generated/partnerv1_GetPartnerConfigurationService_client.go +++ b/internal/rpc/generated/partnerv1_GetPartnerConfigurationService_client.go @@ -21,9 +21,9 @@ var _ rpc.Client = (*GetPartnerConfigurationServiceV1Client)(nil) func NewGetPartnerConfigurationServiceV1(grpcCon *grpc.ClientConn) *GetPartnerConfigurationServiceV1Client { client := partnerv1grpc.NewGetPartnerConfigurationServiceClient(grpcCon) - return &GetPartnerConfigurationServiceV1Client{client: &client} + return &GetPartnerConfigurationServiceV1Client{client: client} } type GetPartnerConfigurationServiceV1Client struct { - client *partnerv1grpc.GetPartnerConfigurationServiceClient + client partnerv1grpc.GetPartnerConfigurationServiceClient } diff --git a/internal/rpc/generated/partnerv2_GetPartnerConfigurationService_GetPartnerConfiguration_client_method.go b/internal/rpc/generated/partnerv2_GetPartnerConfigurationService_GetPartnerConfiguration_client_method.go index 1ad58770..cde24c6d 100644 --- a/internal/rpc/generated/partnerv2_GetPartnerConfigurationService_GetPartnerConfiguration_client_method.go +++ b/internal/rpc/generated/partnerv2_GetPartnerConfigurationService_GetPartnerConfiguration_client_method.go @@ -19,6 +19,6 @@ func (s GetPartnerConfigurationServiceV2Client) Call(ctx context.Context, reques if !ok { return nil, GetPartnerConfigurationServiceV2Response, fmt.Errorf("invalid request type") } - response, err := (*s.client).GetPartnerConfiguration(ctx, request, opts...) + response, err := s.client.GetPartnerConfiguration(ctx, request, opts...) return response, GetPartnerConfigurationServiceV2Response, err } diff --git a/internal/rpc/generated/partnerv2_GetPartnerConfigurationService_client.go b/internal/rpc/generated/partnerv2_GetPartnerConfigurationService_client.go index 59ec8e0f..459817b2 100644 --- a/internal/rpc/generated/partnerv2_GetPartnerConfigurationService_client.go +++ b/internal/rpc/generated/partnerv2_GetPartnerConfigurationService_client.go @@ -21,9 +21,9 @@ var _ rpc.Client = (*GetPartnerConfigurationServiceV2Client)(nil) func NewGetPartnerConfigurationServiceV2(grpcCon *grpc.ClientConn) *GetPartnerConfigurationServiceV2Client { client := partnerv2grpc.NewGetPartnerConfigurationServiceClient(grpcCon) - return &GetPartnerConfigurationServiceV2Client{client: &client} + return &GetPartnerConfigurationServiceV2Client{client: client} } type GetPartnerConfigurationServiceV2Client struct { - client *partnerv2grpc.GetPartnerConfigurationServiceClient + client partnerv2grpc.GetPartnerConfigurationServiceClient } diff --git a/internal/rpc/generated/pingv1_PingService_Ping_client_method.go b/internal/rpc/generated/pingv1_PingService_Ping_client_method.go index b01b9a05..0a1fde01 100644 --- a/internal/rpc/generated/pingv1_PingService_Ping_client_method.go +++ b/internal/rpc/generated/pingv1_PingService_Ping_client_method.go @@ -19,6 +19,6 @@ func (s PingServiceV1Client) Call(ctx context.Context, requestIntf protoreflect. if !ok { return nil, PingServiceV1Response, fmt.Errorf("invalid request type") } - response, err := (*s.client).Ping(ctx, request, opts...) + response, err := s.client.Ping(ctx, request, opts...) return response, PingServiceV1Response, err } diff --git a/internal/rpc/generated/pingv1_PingService_client.go b/internal/rpc/generated/pingv1_PingService_client.go index cea0af4d..a2a269a1 100644 --- a/internal/rpc/generated/pingv1_PingService_client.go +++ b/internal/rpc/generated/pingv1_PingService_client.go @@ -21,9 +21,9 @@ var _ rpc.Client = (*PingServiceV1Client)(nil) func NewPingServiceV1(grpcCon *grpc.ClientConn) *PingServiceV1Client { client := pingv1grpc.NewPingServiceClient(grpcCon) - return &PingServiceV1Client{client: &client} + return &PingServiceV1Client{client: client} } type PingServiceV1Client struct { - client *pingv1grpc.PingServiceClient + client pingv1grpc.PingServiceClient } diff --git a/internal/rpc/generated/seat_mapv1_SeatMapAvailabilityService_SeatMapAvailability_client_method.go b/internal/rpc/generated/seat_mapv1_SeatMapAvailabilityService_SeatMapAvailability_client_method.go index 68badc67..526753df 100644 --- a/internal/rpc/generated/seat_mapv1_SeatMapAvailabilityService_SeatMapAvailability_client_method.go +++ b/internal/rpc/generated/seat_mapv1_SeatMapAvailabilityService_SeatMapAvailability_client_method.go @@ -19,6 +19,6 @@ func (s SeatMapAvailabilityServiceV1Client) Call(ctx context.Context, requestInt if !ok { return nil, SeatMapAvailabilityServiceV1Response, fmt.Errorf("invalid request type") } - response, err := (*s.client).SeatMapAvailability(ctx, request, opts...) + response, err := s.client.SeatMapAvailability(ctx, request, opts...) return response, SeatMapAvailabilityServiceV1Response, err } diff --git a/internal/rpc/generated/seat_mapv1_SeatMapAvailabilityService_client.go b/internal/rpc/generated/seat_mapv1_SeatMapAvailabilityService_client.go index 17a622fe..d43421d1 100644 --- a/internal/rpc/generated/seat_mapv1_SeatMapAvailabilityService_client.go +++ b/internal/rpc/generated/seat_mapv1_SeatMapAvailabilityService_client.go @@ -21,9 +21,9 @@ var _ rpc.Client = (*SeatMapAvailabilityServiceV1Client)(nil) func NewSeatMapAvailabilityServiceV1(grpcCon *grpc.ClientConn) *SeatMapAvailabilityServiceV1Client { client := seat_mapv1grpc.NewSeatMapAvailabilityServiceClient(grpcCon) - return &SeatMapAvailabilityServiceV1Client{client: &client} + return &SeatMapAvailabilityServiceV1Client{client: client} } type SeatMapAvailabilityServiceV1Client struct { - client *seat_mapv1grpc.SeatMapAvailabilityServiceClient + client seat_mapv1grpc.SeatMapAvailabilityServiceClient } diff --git a/internal/rpc/generated/seat_mapv1_SeatMapService_SeatMap_client_method.go b/internal/rpc/generated/seat_mapv1_SeatMapService_SeatMap_client_method.go index e5df1c1e..892eb2fb 100644 --- a/internal/rpc/generated/seat_mapv1_SeatMapService_SeatMap_client_method.go +++ b/internal/rpc/generated/seat_mapv1_SeatMapService_SeatMap_client_method.go @@ -19,6 +19,6 @@ func (s SeatMapServiceV1Client) Call(ctx context.Context, requestIntf protorefle if !ok { return nil, SeatMapServiceV1Response, fmt.Errorf("invalid request type") } - response, err := (*s.client).SeatMap(ctx, request, opts...) + response, err := s.client.SeatMap(ctx, request, opts...) return response, SeatMapServiceV1Response, err } diff --git a/internal/rpc/generated/seat_mapv1_SeatMapService_client.go b/internal/rpc/generated/seat_mapv1_SeatMapService_client.go index 1b6bb2c1..e01becba 100644 --- a/internal/rpc/generated/seat_mapv1_SeatMapService_client.go +++ b/internal/rpc/generated/seat_mapv1_SeatMapService_client.go @@ -21,9 +21,9 @@ var _ rpc.Client = (*SeatMapServiceV1Client)(nil) func NewSeatMapServiceV1(grpcCon *grpc.ClientConn) *SeatMapServiceV1Client { client := seat_mapv1grpc.NewSeatMapServiceClient(grpcCon) - return &SeatMapServiceV1Client{client: &client} + return &SeatMapServiceV1Client{client: client} } type SeatMapServiceV1Client struct { - client *seat_mapv1grpc.SeatMapServiceClient + client seat_mapv1grpc.SeatMapServiceClient } diff --git a/internal/rpc/generated/seat_mapv2_SeatMapAvailabilityService_SeatMapAvailability_client_method.go b/internal/rpc/generated/seat_mapv2_SeatMapAvailabilityService_SeatMapAvailability_client_method.go index 974d55ee..55f7a8bd 100644 --- a/internal/rpc/generated/seat_mapv2_SeatMapAvailabilityService_SeatMapAvailability_client_method.go +++ b/internal/rpc/generated/seat_mapv2_SeatMapAvailabilityService_SeatMapAvailability_client_method.go @@ -19,6 +19,6 @@ func (s SeatMapAvailabilityServiceV2Client) Call(ctx context.Context, requestInt if !ok { return nil, SeatMapAvailabilityServiceV2Response, fmt.Errorf("invalid request type") } - response, err := (*s.client).SeatMapAvailability(ctx, request, opts...) + response, err := s.client.SeatMapAvailability(ctx, request, opts...) return response, SeatMapAvailabilityServiceV2Response, err } diff --git a/internal/rpc/generated/seat_mapv2_SeatMapAvailabilityService_client.go b/internal/rpc/generated/seat_mapv2_SeatMapAvailabilityService_client.go index ed5ceebe..d1cc7de0 100644 --- a/internal/rpc/generated/seat_mapv2_SeatMapAvailabilityService_client.go +++ b/internal/rpc/generated/seat_mapv2_SeatMapAvailabilityService_client.go @@ -21,9 +21,9 @@ var _ rpc.Client = (*SeatMapAvailabilityServiceV2Client)(nil) func NewSeatMapAvailabilityServiceV2(grpcCon *grpc.ClientConn) *SeatMapAvailabilityServiceV2Client { client := seat_mapv2grpc.NewSeatMapAvailabilityServiceClient(grpcCon) - return &SeatMapAvailabilityServiceV2Client{client: &client} + return &SeatMapAvailabilityServiceV2Client{client: client} } type SeatMapAvailabilityServiceV2Client struct { - client *seat_mapv2grpc.SeatMapAvailabilityServiceClient + client seat_mapv2grpc.SeatMapAvailabilityServiceClient } diff --git a/internal/rpc/generated/seat_mapv2_SeatMapService_SeatMap_client_method.go b/internal/rpc/generated/seat_mapv2_SeatMapService_SeatMap_client_method.go index fea429e9..cd9f25b4 100644 --- a/internal/rpc/generated/seat_mapv2_SeatMapService_SeatMap_client_method.go +++ b/internal/rpc/generated/seat_mapv2_SeatMapService_SeatMap_client_method.go @@ -19,6 +19,6 @@ func (s SeatMapServiceV2Client) Call(ctx context.Context, requestIntf protorefle if !ok { return nil, SeatMapServiceV2Response, fmt.Errorf("invalid request type") } - response, err := (*s.client).SeatMap(ctx, request, opts...) + response, err := s.client.SeatMap(ctx, request, opts...) return response, SeatMapServiceV2Response, err } diff --git a/internal/rpc/generated/seat_mapv2_SeatMapService_client.go b/internal/rpc/generated/seat_mapv2_SeatMapService_client.go index 0df3c9f8..349167c5 100644 --- a/internal/rpc/generated/seat_mapv2_SeatMapService_client.go +++ b/internal/rpc/generated/seat_mapv2_SeatMapService_client.go @@ -21,9 +21,9 @@ var _ rpc.Client = (*SeatMapServiceV2Client)(nil) func NewSeatMapServiceV2(grpcCon *grpc.ClientConn) *SeatMapServiceV2Client { client := seat_mapv2grpc.NewSeatMapServiceClient(grpcCon) - return &SeatMapServiceV2Client{client: &client} + return &SeatMapServiceV2Client{client: client} } type SeatMapServiceV2Client struct { - client *seat_mapv2grpc.SeatMapServiceClient + client seat_mapv2grpc.SeatMapServiceClient } diff --git a/internal/rpc/generated/transportv1_TransportSearchService_TransportSearch_client_method.go b/internal/rpc/generated/transportv1_TransportSearchService_TransportSearch_client_method.go index aef51ddb..a5f8fce4 100644 --- a/internal/rpc/generated/transportv1_TransportSearchService_TransportSearch_client_method.go +++ b/internal/rpc/generated/transportv1_TransportSearchService_TransportSearch_client_method.go @@ -19,6 +19,6 @@ func (s TransportSearchServiceV1Client) Call(ctx context.Context, requestIntf pr if !ok { return nil, TransportSearchServiceV1Response, fmt.Errorf("invalid request type") } - response, err := (*s.client).TransportSearch(ctx, request, opts...) + response, err := s.client.TransportSearch(ctx, request, opts...) return response, TransportSearchServiceV1Response, err } diff --git a/internal/rpc/generated/transportv1_TransportSearchService_client.go b/internal/rpc/generated/transportv1_TransportSearchService_client.go index 4879b451..36ce7160 100644 --- a/internal/rpc/generated/transportv1_TransportSearchService_client.go +++ b/internal/rpc/generated/transportv1_TransportSearchService_client.go @@ -21,9 +21,9 @@ var _ rpc.Client = (*TransportSearchServiceV1Client)(nil) func NewTransportSearchServiceV1(grpcCon *grpc.ClientConn) *TransportSearchServiceV1Client { client := transportv1grpc.NewTransportSearchServiceClient(grpcCon) - return &TransportSearchServiceV1Client{client: &client} + return &TransportSearchServiceV1Client{client: client} } type TransportSearchServiceV1Client struct { - client *transportv1grpc.TransportSearchServiceClient + client transportv1grpc.TransportSearchServiceClient } diff --git a/internal/rpc/generated/transportv2_TransportSearchService_TransportSearch_client_method.go b/internal/rpc/generated/transportv2_TransportSearchService_TransportSearch_client_method.go index 5dbe3c74..3d06121c 100644 --- a/internal/rpc/generated/transportv2_TransportSearchService_TransportSearch_client_method.go +++ b/internal/rpc/generated/transportv2_TransportSearchService_TransportSearch_client_method.go @@ -19,6 +19,6 @@ func (s TransportSearchServiceV2Client) Call(ctx context.Context, requestIntf pr if !ok { return nil, TransportSearchServiceV2Response, fmt.Errorf("invalid request type") } - response, err := (*s.client).TransportSearch(ctx, request, opts...) + response, err := s.client.TransportSearch(ctx, request, opts...) return response, TransportSearchServiceV2Response, err } diff --git a/internal/rpc/generated/transportv2_TransportSearchService_client.go b/internal/rpc/generated/transportv2_TransportSearchService_client.go index fc66920f..042494e1 100644 --- a/internal/rpc/generated/transportv2_TransportSearchService_client.go +++ b/internal/rpc/generated/transportv2_TransportSearchService_client.go @@ -21,9 +21,9 @@ var _ rpc.Client = (*TransportSearchServiceV2Client)(nil) func NewTransportSearchServiceV2(grpcCon *grpc.ClientConn) *TransportSearchServiceV2Client { client := transportv2grpc.NewTransportSearchServiceClient(grpcCon) - return &TransportSearchServiceV2Client{client: &client} + return &TransportSearchServiceV2Client{client: client} } type TransportSearchServiceV2Client struct { - client *transportv2grpc.TransportSearchServiceClient + client transportv2grpc.TransportSearchServiceClient } From 9eb239d2f3f60969076bcec1a9118f5ed132552a Mon Sep 17 00:00:00 2001 From: "ev.lekht" Date: Fri, 22 Nov 2024 16:08:20 +0400 Subject: [PATCH 08/20] wip --- internal/messaging/mint.go | 1 - internal/messaging/mint_v1.go | 5 ++--- internal/messaging/mint_v2.go | 5 ++--- internal/messaging/response_handler.go | 1 - 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/internal/messaging/mint.go b/internal/messaging/mint.go index b9d94c85..20357c77 100644 --- a/internal/messaging/mint.go +++ b/internal/messaging/mint.go @@ -212,7 +212,6 @@ func verifyAndFixBuyableUntil(buyableUntil *timestamppb.Timestamp, currentTime t return buyableUntil, nil } -// TODO@ test that its working, its not c++ after all func ensureHeaderV1(response **typesv1.ResponseHeader) { if *response == nil { *response = &typesv1.ResponseHeader{} diff --git a/internal/messaging/mint_v1.go b/internal/messaging/mint_v1.go index 175f28bb..f802c2ef 100644 --- a/internal/messaging/mint_v1.go +++ b/internal/messaging/mint_v1.go @@ -94,10 +94,9 @@ func (h *evmResponseHandler) prepareMintResponseV1( func (h *evmResponseHandler) processMintResponseV1(ctx context.Context, responseIntf protoreflect.ProtoMessage) { response, ok := responseIntf.(*bookv1.MintResponse) + // TODO@ its impossible, its ensured by grpc client down the stack, even if its not clear here if !ok { - // TODO@ we might not have header here, especially since response type is unexpected - // TODO@ should we create dummy error response of correct type here and pass it? - // TODO@ how this could even happen? + // TODO@ we might not have header here! ensure header before that err := fmt.Errorf("%w: expected *bookv1.MintResponse, got %T", errUnexpectedResponseType, responseIntf) h.logger.Error(err) h.AddErrorToResponseHeader(response, err.Error()) diff --git a/internal/messaging/mint_v2.go b/internal/messaging/mint_v2.go index 860b4a2c..dd42d439 100644 --- a/internal/messaging/mint_v2.go +++ b/internal/messaging/mint_v2.go @@ -100,10 +100,9 @@ func (h *evmResponseHandler) prepareMintResponseV2( func (h *evmResponseHandler) processMintResponseV2(ctx context.Context, responseIntf protoreflect.ProtoMessage) { response, ok := responseIntf.(*bookv2.MintResponse) + // TODO@ its impossible, its ensured by grpc client down the stack, even if its not clear here if !ok { - // TODO@ we might not have header here, especially since response type is unexpected - // TODO@ should we create dummy error response of correct type here and pass it? - // TODO@ how this could even happen? + // TODO@ we might not have header here! ensure header before that err := fmt.Errorf("%w: expected *bookv2.MintResponse, got %T", errUnexpectedResponseType, responseIntf) h.logger.Error(err) h.AddErrorToResponseHeader(response, err.Error()) diff --git a/internal/messaging/response_handler.go b/internal/messaging/response_handler.go index c489445a..2c928aff 100644 --- a/internal/messaging/response_handler.go +++ b/internal/messaging/response_handler.go @@ -40,7 +40,6 @@ var ( zeroAddress = common.HexToAddress("0x0000000000000000000000000000000000000000") ) -// TODO@ rename ? type ResponseHandler interface { // Processes incoming response ProcessResponseMessage(ctx context.Context, requestMsg *types.Message, responseMsg *types.Message) From 49507e25a0c6648baa0a527d1c472ab9d122a855 Mon Sep 17 00:00:00 2001 From: "ev.lekht" Date: Fri, 22 Nov 2024 16:14:19 +0400 Subject: [PATCH 09/20] wip --- internal/messaging/mint_v1.go | 12 +----------- internal/messaging/mint_v2.go | 12 +----------- internal/messaging/response_handler.go | 13 ++++++++----- 3 files changed, 10 insertions(+), 27 deletions(-) diff --git a/internal/messaging/mint_v1.go b/internal/messaging/mint_v1.go index f802c2ef..d738d5cc 100644 --- a/internal/messaging/mint_v1.go +++ b/internal/messaging/mint_v1.go @@ -92,17 +92,7 @@ func (h *evmResponseHandler) prepareMintResponseV1( response.MintTransactionId = txID } -func (h *evmResponseHandler) processMintResponseV1(ctx context.Context, responseIntf protoreflect.ProtoMessage) { - response, ok := responseIntf.(*bookv1.MintResponse) - // TODO@ its impossible, its ensured by grpc client down the stack, even if its not clear here - if !ok { - // TODO@ we might not have header here! ensure header before that - err := fmt.Errorf("%w: expected *bookv1.MintResponse, got %T", errUnexpectedResponseType, responseIntf) - h.logger.Error(err) - h.AddErrorToResponseHeader(response, err.Error()) - return - } - +func (h *evmResponseHandler) processMintResponseV1(ctx context.Context, response *bookv1.MintResponse) { ensureHeaderV1(&response.Header) if response.MintTransactionId == "" { diff --git a/internal/messaging/mint_v2.go b/internal/messaging/mint_v2.go index dd42d439..a9eebbf4 100644 --- a/internal/messaging/mint_v2.go +++ b/internal/messaging/mint_v2.go @@ -98,17 +98,7 @@ func (h *evmResponseHandler) prepareMintResponseV2( response.MintTransactionId = txID } -func (h *evmResponseHandler) processMintResponseV2(ctx context.Context, responseIntf protoreflect.ProtoMessage) { - response, ok := responseIntf.(*bookv2.MintResponse) - // TODO@ its impossible, its ensured by grpc client down the stack, even if its not clear here - if !ok { - // TODO@ we might not have header here! ensure header before that - err := fmt.Errorf("%w: expected *bookv2.MintResponse, got %T", errUnexpectedResponseType, responseIntf) - h.logger.Error(err) - h.AddErrorToResponseHeader(response, err.Error()) - return - } - +func (h *evmResponseHandler) processMintResponseV2(ctx context.Context, response *bookv2.MintResponse) { ensureHeaderV1(&response.Header) if response.MintTransactionId == "" { diff --git a/internal/messaging/response_handler.go b/internal/messaging/response_handler.go index 2c928aff..8f3e0579 100644 --- a/internal/messaging/response_handler.go +++ b/internal/messaging/response_handler.go @@ -106,19 +106,21 @@ type evmResponseHandler struct { erc20 erc20.Service } +// Processes incoming response func (h *evmResponseHandler) ProcessResponseMessage( ctx context.Context, requestMsg *types.Message, responseMsg *types.Message, ) { - switch requestMsg.Type { - case generated.MintServiceV1Request: // distributor will post-process a mint request to buy the returned NFT - h.processMintResponseV1(ctx, responseMsg.Content) - case generated.MintServiceV2Request: // distributor will post-process a mint request to buy the returned NFT - h.processMintResponseV2(ctx, responseMsg.Content) + switch response := responseMsg.Content.(type) { + case *bookv1.MintResponse: // distributor will post-process a mint request to buy the returned NFT + h.processMintResponseV1(ctx, response) + case *bookv2.MintResponse: // distributor will post-process a mint request to buy the returned NFT + h.processMintResponseV2(ctx, response) } } +// Prepares response by performing any necessary modifications to it func (h *evmResponseHandler) PrepareResponseMessage( ctx context.Context, requestMsg *types.Message, @@ -132,6 +134,7 @@ func (h *evmResponseHandler) PrepareResponseMessage( } } +// Prepares request by performing any necessary modifications to it func (h *evmResponseHandler) PrepareRequest(msgType types.MessageType, request protoreflect.ProtoMessage) error { switch msgType { case generated.MintServiceV2Request: From 2ca65a8e30299062e1d0a1afcaf9e4005128f263 Mon Sep 17 00:00:00 2001 From: "ev.lekht" Date: Fri, 22 Nov 2024 16:32:36 +0400 Subject: [PATCH 10/20] wip --- internal/messaging/mint.go | 2 -- internal/messaging/mint_v1.go | 11 +------- internal/messaging/mint_v2.go | 12 +------- internal/messaging/noop_response_handler.go | 2 +- internal/messaging/processor.go | 9 ++++-- internal/messaging/response_handler.go | 31 ++++++++------------- internal/messaging/types/types.go | 2 +- 7 files changed, 23 insertions(+), 46 deletions(-) diff --git a/internal/messaging/mint.go b/internal/messaging/mint.go index 20357c77..a46d4f08 100644 --- a/internal/messaging/mint.go +++ b/internal/messaging/mint.go @@ -19,8 +19,6 @@ import ( ) var errMissingMintTxID = errors.New("missing mint transaction id") -var errUnexpectedRequestType = errors.New("unexpected request type") -var errUnexpectedResponseType = errors.New("unexpected response type") // Mints a BookingToken with the supplier private key and reserves it for the buyer address // For testing you can use this uri: "data:application/json;base64,eyJuYW1lIjoiQ2FtaW5vIE1lc3NlbmdlciBCb29raW5nVG9rZW4gVGVzdCJ9Cg==" diff --git a/internal/messaging/mint_v1.go b/internal/messaging/mint_v1.go index d738d5cc..17fdee0c 100644 --- a/internal/messaging/mint_v1.go +++ b/internal/messaging/mint_v1.go @@ -10,22 +10,13 @@ import ( typesv1 "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/types/v1" "github.com/ethereum/go-ethereum/common" - "google.golang.org/protobuf/reflect/protoreflect" ) func (h *evmResponseHandler) prepareMintResponseV1( ctx context.Context, response *bookv1.MintResponse, - requestIntf protoreflect.ProtoMessage, + request *bookv1.MintRequest, ) { - request, ok := requestIntf.(*bookv1.MintRequest) - if !ok { - err := fmt.Errorf("%w: expected *bookv1.MintRequest, got %T", errUnexpectedRequestType, requestIntf) - h.logger.Error(err) - h.AddErrorToResponseHeader(response, err.Error()) - return - } - ensureHeaderV1(&response.Header) if response.Header.Status == typesv1.StatusType_STATUS_TYPE_FAILURE { diff --git a/internal/messaging/mint_v2.go b/internal/messaging/mint_v2.go index a9eebbf4..a2eafc4a 100644 --- a/internal/messaging/mint_v2.go +++ b/internal/messaging/mint_v2.go @@ -11,23 +11,13 @@ import ( typesv2 "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/types/v2" "github.com/ethereum/go-ethereum/common" - - "google.golang.org/protobuf/reflect/protoreflect" ) func (h *evmResponseHandler) prepareMintResponseV2( ctx context.Context, response *bookv2.MintResponse, - requestIntf protoreflect.ProtoMessage, + request *bookv2.MintRequest, ) { - request, ok := requestIntf.(*bookv2.MintRequest) - if !ok { - err := fmt.Errorf("%w: expected *bookv2.MintRequest, got %T", errUnexpectedRequestType, requestIntf) - h.logger.Error(err) - h.AddErrorToResponseHeader(response, err.Error()) - return - } - ensureHeaderV1(&response.Header) // Check if the response from plugin is successful before minting diff --git a/internal/messaging/noop_response_handler.go b/internal/messaging/noop_response_handler.go index 3ffdd275..b4f117ac 100644 --- a/internal/messaging/noop_response_handler.go +++ b/internal/messaging/noop_response_handler.go @@ -20,7 +20,7 @@ func (NoopResponseHandler) ProcessResponseMessage(context.Context, *types.Messag func (NoopResponseHandler) PrepareResponseMessage(context.Context, *types.Message, *types.Message) {} -func (NoopResponseHandler) PrepareRequest(types.MessageType, protoreflect.ProtoMessage) error { +func (NoopResponseHandler) PrepareRequest(protoreflect.ProtoMessage) error { return nil } diff --git a/internal/messaging/processor.go b/internal/messaging/processor.go index ef761573..7f15df02 100644 --- a/internal/messaging/processor.go +++ b/internal/messaging/processor.go @@ -182,7 +182,7 @@ func (p *messageProcessor) SendRequestMessage(ctx context.Context, requestMsg *t return nil, err } - if err := p.responseHandler.PrepareRequest(requestMsg.Type, requestMsg.Content); err != nil { + if err := p.responseHandler.PrepareRequest(requestMsg.Content); err != nil { return nil, err } @@ -292,7 +292,12 @@ func (p *messageProcessor) callPartnerPluginAndGetResponse( responseMsg.Content = response } - // TODO@ ensure response header, ensure that response has correct type ? + // TODO@ ensure response header there instead of doing it in mint specifically + // TODO@ that way it will be ensured for all response types and in just one place + + // TODO@ what do we do if pp responded without header, btw? is it ok? + // TODO@ should we add some default header? + // TODO@ should we consider this error? if err != nil { errMessage := fmt.Sprintf("error calling partner plugin service: %v", err) diff --git a/internal/messaging/response_handler.go b/internal/messaging/response_handler.go index 8f3e0579..61a15d1e 100644 --- a/internal/messaging/response_handler.go +++ b/internal/messaging/response_handler.go @@ -16,7 +16,6 @@ import ( "google.golang.org/protobuf/reflect/protoreflect" "github.com/chain4travel/camino-messenger-bot/internal/messaging/types" - "github.com/chain4travel/camino-messenger-bot/internal/rpc/generated" "github.com/chain4travel/camino-messenger-bot/pkg/booking" cmaccounts "github.com/chain4travel/camino-messenger-bot/pkg/cm_accounts" "github.com/chain4travel/camino-messenger-bot/pkg/erc20" @@ -45,10 +44,11 @@ type ResponseHandler interface { ProcessResponseMessage(ctx context.Context, requestMsg *types.Message, responseMsg *types.Message) // Prepares response by performing any necessary modifications to it + // It expects the request and response to be of the same service. PrepareResponseMessage(ctx context.Context, requestMsg *types.Message, responseMsg *types.Message) // Prepares request by performing any necessary modifications to it - PrepareRequest(msgType types.MessageType, request protoreflect.ProtoMessage) error + PrepareRequest(request protoreflect.ProtoMessage) error // Adds an error message to the response header AddErrorToResponseHeader(response protoreflect.ProtoMessage, errMessage string) @@ -120,7 +120,8 @@ func (h *evmResponseHandler) ProcessResponseMessage( } } -// Prepares response by performing any necessary modifications to it +// Prepares response by performing any necessary modifications to it. +// It expects the request and response to be of the same service. func (h *evmResponseHandler) PrepareResponseMessage( ctx context.Context, requestMsg *types.Message, @@ -128,27 +129,19 @@ func (h *evmResponseHandler) PrepareResponseMessage( ) { switch response := responseMsg.Content.(type) { case *bookv1.MintResponse: // supplier will act upon receiving a mint response by minting an NFT - h.prepareMintResponseV1(ctx, response, requestMsg.Content) + h.prepareMintResponseV1(ctx, response, requestMsg.Content.(*bookv1.MintRequest)) case *bookv2.MintResponse: // supplier will act upon receiving a mint response by minting an NFT - h.prepareMintResponseV2(ctx, response, requestMsg.Content) + h.prepareMintResponseV2(ctx, response, requestMsg.Content.(*bookv2.MintRequest)) } } // Prepares request by performing any necessary modifications to it -func (h *evmResponseHandler) PrepareRequest(msgType types.MessageType, request protoreflect.ProtoMessage) error { - switch msgType { - case generated.MintServiceV2Request: - mintReq, ok := request.(*bookv2.MintRequest) - if !ok { - return nil - } - mintReq.BuyerAddress = h.cmAccountAddress.Hex() - case generated.MintServiceV1Request: - mintReq, ok := request.(*bookv1.MintRequest) - if !ok { - return nil - } - mintReq.BuyerAddress = h.cmAccountAddress.Hex() +func (h *evmResponseHandler) PrepareRequest(request protoreflect.ProtoMessage) error { + switch request := request.(type) { + case *bookv1.MintRequest: + request.BuyerAddress = h.cmAccountAddress.Hex() + case *bookv2.MintRequest: + request.BuyerAddress = h.cmAccountAddress.Hex() } return nil } diff --git a/internal/messaging/types/types.go b/internal/messaging/types/types.go index ba6149cb..31d42691 100644 --- a/internal/messaging/types/types.go +++ b/internal/messaging/types/types.go @@ -48,7 +48,7 @@ func ServiceNameToRequestMessageType(serviceName string) MessageType { // Message is the message format used for communication between the messenger and the service // TODO @evlekht why json tags? where is this shown? Its not passed into matrix message type Message struct { - Type MessageType `json:"msgtype"` + Type MessageType `json:"msgtype"` // TODO @evlekht it might be possible to get rid of this field Content protoreflect.ProtoMessage `json:"content"` Metadata metadata.Metadata `json:"metadata"` Sender id.UserID From 1cd4575cd848fdc95a193e34b0a5f125aadecc14 Mon Sep 17 00:00:00 2001 From: "ev.lekht" Date: Fri, 22 Nov 2024 16:34:42 +0400 Subject: [PATCH 11/20] wip --- internal/messaging/noop_response_handler.go | 2 +- internal/messaging/processor.go | 2 +- internal/messaging/response_handler.go | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/internal/messaging/noop_response_handler.go b/internal/messaging/noop_response_handler.go index b4f117ac..e2acd5fb 100644 --- a/internal/messaging/noop_response_handler.go +++ b/internal/messaging/noop_response_handler.go @@ -16,7 +16,7 @@ var _ ResponseHandler = (*NoopResponseHandler)(nil) type NoopResponseHandler struct{} -func (NoopResponseHandler) ProcessResponseMessage(context.Context, *types.Message, *types.Message) {} +func (NoopResponseHandler) ProcessResponseMessage(context.Context, *types.Message) {} func (NoopResponseHandler) PrepareResponseMessage(context.Context, *types.Message, *types.Message) {} diff --git a/internal/messaging/processor.go b/internal/messaging/processor.go index 7f15df02..fad62770 100644 --- a/internal/messaging/processor.go +++ b/internal/messaging/processor.go @@ -214,7 +214,7 @@ func (p *messageProcessor) SendRequestMessage(ctx context.Context, requestMsg *t select { case responseMsg := <-responseChan: if responseMsg.Metadata.RequestID == requestMsg.Metadata.RequestID { - p.responseHandler.ProcessResponseMessage(ctx, requestMsg, responseMsg) + p.responseHandler.ProcessResponseMessage(ctx, responseMsg) return responseMsg, nil } else { err := fmt.Errorf("unexpected response (%s) for request (%s)", responseMsg.Metadata.RequestID, requestMsg.Metadata.RequestID) diff --git a/internal/messaging/response_handler.go b/internal/messaging/response_handler.go index 61a15d1e..869110f0 100644 --- a/internal/messaging/response_handler.go +++ b/internal/messaging/response_handler.go @@ -41,7 +41,7 @@ var ( type ResponseHandler interface { // Processes incoming response - ProcessResponseMessage(ctx context.Context, requestMsg *types.Message, responseMsg *types.Message) + ProcessResponseMessage(ctx context.Context, responseMsg *types.Message) // Prepares response by performing any necessary modifications to it // It expects the request and response to be of the same service. @@ -109,7 +109,6 @@ type evmResponseHandler struct { // Processes incoming response func (h *evmResponseHandler) ProcessResponseMessage( ctx context.Context, - requestMsg *types.Message, responseMsg *types.Message, ) { switch response := responseMsg.Content.(type) { From a66937c8b8a6a8fa2552ea2b5be46384ea7c1225 Mon Sep 17 00:00:00 2001 From: "ev.lekht" Date: Fri, 22 Nov 2024 17:02:58 +0400 Subject: [PATCH 12/20] wip --- scripts/generate_grpc_service_handlers.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/generate_grpc_service_handlers.sh b/scripts/generate_grpc_service_handlers.sh index 0f90da72..b47c08b8 100755 --- a/scripts/generate_grpc_service_handlers.sh +++ b/scripts/generate_grpc_service_handlers.sh @@ -293,8 +293,7 @@ while read file ; do # "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/activity/v2" # "buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/activity/v2/activityv2grpc" # We already have the base URL in BUF_SDK_URL_GO - now we only need the suffixes for the protocolbuffers and grpc - # And store them into the INCLUDES array - declare -a INCLUDES=() + # And store them into the PROTO_INCLUDES_FOR_UNMARSHALLING array # First the protocolbuffers SUFFIX=$(echo ${FQPN%.*} | tr "." "/") PROTO_INCLUDE="${BUF_SDK_BASE}/protocolbuffers/go/${SUFFIX}" From 178932ed8572f8341d68ca95a291ff77e30e9ed1 Mon Sep 17 00:00:00 2001 From: "ev.lekht" Date: Fri, 22 Nov 2024 17:37:23 +0400 Subject: [PATCH 13/20] wip --- internal/messaging/processor.go | 17 +++-------------- internal/messaging/response_handler.go | 9 --------- ...ce_AccommodationProductInfo_client_method.go | 6 ++++++ templates/client_method.go.tpl | 5 +++++ 4 files changed, 14 insertions(+), 23 deletions(-) diff --git a/internal/messaging/processor.go b/internal/messaging/processor.go index fad62770..0d3893a4 100644 --- a/internal/messaging/processor.go +++ b/internal/messaging/processor.go @@ -282,26 +282,15 @@ func (p *messageProcessor) callPartnerPluginAndGetResponse( } ctx = grpc_metadata.NewOutgoingContext(ctx, requestMsg.Metadata.ToGrpcMD()) + var err error header := &grpc_metadata.MD{} ctx, partnerPluginSpan := p.tracer.Start(ctx, "service.Call", trace.WithSpanKind(trace.SpanKindClient), trace.WithAttributes(attribute.String("type", string(requestMsg.Type)))) - response, msgType, err := service.Call(ctx, requestMsg.Content, grpc.Header(header)) + responseMsg.Content, responseMsg.Type, err = service.Call(ctx, requestMsg.Content, grpc.Header(header)) partnerPluginSpan.End() - - responseMsg.Type = msgType - if response != nil { - responseMsg.Content = response - } - - // TODO@ ensure response header there instead of doing it in mint specifically - // TODO@ that way it will be ensured for all response types and in just one place - - // TODO@ what do we do if pp responded without header, btw? is it ok? - // TODO@ should we add some default header? - // TODO@ should we consider this error? - if err != nil { errMessage := fmt.Sprintf("error calling partner plugin service: %v", err) p.logger.Errorf(errMessage) + // non-nil response header is ensured by the grpc client generated code p.responseHandler.AddErrorToResponseHeader(responseMsg.Content, errMessage) return ctx, responseMsg } diff --git a/internal/messaging/response_handler.go b/internal/messaging/response_handler.go index 869110f0..967fc2fb 100644 --- a/internal/messaging/response_handler.go +++ b/internal/messaging/response_handler.go @@ -149,15 +149,6 @@ func (h *evmResponseHandler) AddErrorToResponseHeader(response protoreflect.Prot headerFieldDescriptor := response.ProtoReflect().Descriptor().Fields().ByName("header") headerReflectValue := response.ProtoReflect().Get(headerFieldDescriptor) - if !headerReflectValue.IsValid() || !headerReflectValue.Message().IsValid() { - // TODO: @VjeraTurk support more than 1 version! Or ensure header is not nil elsewhere - // Initialize the header if it is not set - header := &typesv1.ResponseHeader{} - response.ProtoReflect().Set(headerFieldDescriptor, protoreflect.ValueOfMessage(header.ProtoReflect())) - addErrorToResponseHeaderV1(header, errMessage) - return - } - switch header := headerReflectValue.Message().Interface().(type) { case *typesv1.ResponseHeader: addErrorToResponseHeaderV1(header, errMessage) diff --git a/internal/rpc/generated/accommodationv1_AccommodationProductInfoService_AccommodationProductInfo_client_method.go b/internal/rpc/generated/accommodationv1_AccommodationProductInfoService_AccommodationProductInfo_client_method.go index c7ccbe32..873c1fa0 100644 --- a/internal/rpc/generated/accommodationv1_AccommodationProductInfoService_AccommodationProductInfo_client_method.go +++ b/internal/rpc/generated/accommodationv1_AccommodationProductInfoService_AccommodationProductInfo_client_method.go @@ -8,6 +8,7 @@ import ( "fmt" accommodationv1 "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/accommodation/v1" + typesv1 "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/types/v1" "github.com/chain4travel/camino-messenger-bot/internal/messaging/types" "google.golang.org/grpc" @@ -20,5 +21,10 @@ func (s AccommodationProductInfoServiceV1Client) Call(ctx context.Context, reque return nil, AccommodationProductInfoServiceV1Response, fmt.Errorf("invalid request type") } response, err := s.client.AccommodationProductInfo(ctx, request, opts...) + if response == nil { + response = &accommodationv1.AccommodationProductInfoResponse{ + Header: &typesv1.ResponseHeader{}, + } + } return response, AccommodationProductInfoServiceV1Response, err } diff --git a/templates/client_method.go.tpl b/templates/client_method.go.tpl index d1de441b..3c8a7587 100644 --- a/templates/client_method.go.tpl +++ b/templates/client_method.go.tpl @@ -20,5 +20,10 @@ func (s {{SERVICE}}V{{VERSION}}Client) Call(ctx context.Context, requestIntf pro return nil, {{SERVICE}}V{{VERSION}}Response, fmt.Errorf("invalid request type") } response, err := s.client.{{METHOD}}(ctx, request, opts...) + if response == nil { + response = &{{TYPE_PACKAGE}}.AccommodationProductInfoResponse{ + Header: &typesv1.ResponseHeader{}, + } + } return response, {{SERVICE}}V{{VERSION}}Response, err } From 998250ac02ae43467f0c00e5ed0877e5a43259a3 Mon Sep 17 00:00:00 2001 From: "ev.lekht" Date: Fri, 22 Nov 2024 17:40:05 +0400 Subject: [PATCH 14/20] wip --- internal/messaging/mint_v1.go | 1 - internal/messaging/mint_v2.go | 2 -- internal/messaging/response_handler.go | 9 +++++++++ ...InfoService_AccommodationProductInfo_client_method.go | 6 ------ templates/client_method.go.tpl | 5 ----- 5 files changed, 9 insertions(+), 14 deletions(-) diff --git a/internal/messaging/mint_v1.go b/internal/messaging/mint_v1.go index 17fdee0c..2fbf5ce2 100644 --- a/internal/messaging/mint_v1.go +++ b/internal/messaging/mint_v1.go @@ -18,7 +18,6 @@ func (h *evmResponseHandler) prepareMintResponseV1( request *bookv1.MintRequest, ) { ensureHeaderV1(&response.Header) - if response.Header.Status == typesv1.StatusType_STATUS_TYPE_FAILURE { return } diff --git a/internal/messaging/mint_v2.go b/internal/messaging/mint_v2.go index a2eafc4a..ed514ed6 100644 --- a/internal/messaging/mint_v2.go +++ b/internal/messaging/mint_v2.go @@ -19,8 +19,6 @@ func (h *evmResponseHandler) prepareMintResponseV2( request *bookv2.MintRequest, ) { ensureHeaderV1(&response.Header) - - // Check if the response from plugin is successful before minting if response.Header.Status == typesv1.StatusType_STATUS_TYPE_FAILURE { return } diff --git a/internal/messaging/response_handler.go b/internal/messaging/response_handler.go index 967fc2fb..869110f0 100644 --- a/internal/messaging/response_handler.go +++ b/internal/messaging/response_handler.go @@ -149,6 +149,15 @@ func (h *evmResponseHandler) AddErrorToResponseHeader(response protoreflect.Prot headerFieldDescriptor := response.ProtoReflect().Descriptor().Fields().ByName("header") headerReflectValue := response.ProtoReflect().Get(headerFieldDescriptor) + if !headerReflectValue.IsValid() || !headerReflectValue.Message().IsValid() { + // TODO: @VjeraTurk support more than 1 version! Or ensure header is not nil elsewhere + // Initialize the header if it is not set + header := &typesv1.ResponseHeader{} + response.ProtoReflect().Set(headerFieldDescriptor, protoreflect.ValueOfMessage(header.ProtoReflect())) + addErrorToResponseHeaderV1(header, errMessage) + return + } + switch header := headerReflectValue.Message().Interface().(type) { case *typesv1.ResponseHeader: addErrorToResponseHeaderV1(header, errMessage) diff --git a/internal/rpc/generated/accommodationv1_AccommodationProductInfoService_AccommodationProductInfo_client_method.go b/internal/rpc/generated/accommodationv1_AccommodationProductInfoService_AccommodationProductInfo_client_method.go index 873c1fa0..c7ccbe32 100644 --- a/internal/rpc/generated/accommodationv1_AccommodationProductInfoService_AccommodationProductInfo_client_method.go +++ b/internal/rpc/generated/accommodationv1_AccommodationProductInfoService_AccommodationProductInfo_client_method.go @@ -8,7 +8,6 @@ import ( "fmt" accommodationv1 "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/accommodation/v1" - typesv1 "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/types/v1" "github.com/chain4travel/camino-messenger-bot/internal/messaging/types" "google.golang.org/grpc" @@ -21,10 +20,5 @@ func (s AccommodationProductInfoServiceV1Client) Call(ctx context.Context, reque return nil, AccommodationProductInfoServiceV1Response, fmt.Errorf("invalid request type") } response, err := s.client.AccommodationProductInfo(ctx, request, opts...) - if response == nil { - response = &accommodationv1.AccommodationProductInfoResponse{ - Header: &typesv1.ResponseHeader{}, - } - } return response, AccommodationProductInfoServiceV1Response, err } diff --git a/templates/client_method.go.tpl b/templates/client_method.go.tpl index 3c8a7587..d1de441b 100644 --- a/templates/client_method.go.tpl +++ b/templates/client_method.go.tpl @@ -20,10 +20,5 @@ func (s {{SERVICE}}V{{VERSION}}Client) Call(ctx context.Context, requestIntf pro return nil, {{SERVICE}}V{{VERSION}}Response, fmt.Errorf("invalid request type") } response, err := s.client.{{METHOD}}(ctx, request, opts...) - if response == nil { - response = &{{TYPE_PACKAGE}}.AccommodationProductInfoResponse{ - Header: &typesv1.ResponseHeader{}, - } - } return response, {{SERVICE}}V{{VERSION}}Response, err } From d68871faf56ed836261b998692228220b130afab Mon Sep 17 00:00:00 2001 From: "ev.lekht" Date: Fri, 22 Nov 2024 17:53:19 +0400 Subject: [PATCH 15/20] wip --- internal/messaging/mint_v1.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/messaging/mint_v1.go b/internal/messaging/mint_v1.go index 2fbf5ce2..37166e19 100644 --- a/internal/messaging/mint_v1.go +++ b/internal/messaging/mint_v1.go @@ -35,7 +35,7 @@ func (h *evmResponseHandler) prepareMintResponseV1( if err != nil { errMsg := fmt.Sprintf("error creating token URI: %v", err) h.logger.Debugf(errMsg) // TODO: @VjeraTurk change to Error after we stop using mocked uri data - h.AddErrorToResponseHeader(request, errMsg) + h.AddErrorToResponseHeader(response, errMsg) return } @@ -44,7 +44,7 @@ func (h *evmResponseHandler) prepareMintResponseV1( buyableUntil, err := verifyAndFixBuyableUntil(response.BuyableUntil, time.Now()) if err != nil { h.logger.Error(err) - h.AddErrorToResponseHeader(request, err.Error()) + h.AddErrorToResponseHeader(response, err.Error()) return } response.BuyableUntil = buyableUntil @@ -53,7 +53,7 @@ func (h *evmResponseHandler) prepareMintResponseV1( if err != nil { errMessage := fmt.Sprintf("error getting price and payment token: %v", err) h.logger.Errorf(errMessage) - h.AddErrorToResponseHeader(request, errMessage) + h.AddErrorToResponseHeader(response, errMessage) return } @@ -69,7 +69,7 @@ func (h *evmResponseHandler) prepareMintResponseV1( if err != nil { errMessage := fmt.Sprintf("error minting NFT: %v", err) h.logger.Errorf(errMessage) - h.AddErrorToResponseHeader(request, errMessage) + h.AddErrorToResponseHeader(response, errMessage) return } From 6d4e6302455318f32a01057630bdbb8704bb7599 Mon Sep 17 00:00:00 2001 From: "ev.lekht" Date: Fri, 22 Nov 2024 18:16:45 +0400 Subject: [PATCH 16/20] lint --- internal/messaging/processor.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/messaging/processor.go b/internal/messaging/processor.go index 0d3893a4..3893487a 100644 --- a/internal/messaging/processor.go +++ b/internal/messaging/processor.go @@ -224,7 +224,6 @@ func (p *messageProcessor) SendRequestMessage(ctx context.Context, requestMsg *t case <-ctx.Done(): return nil, fmt.Errorf("%w of %v seconds for request: %s", ErrExceededResponseTimeout, p.responseTimeout, requestMsg.Metadata.RequestID) } - } func (p *messageProcessor) respond(msg *types.Message) error { From 3db00a476084b8f353b133cbaa10bffe184624de Mon Sep 17 00:00:00 2001 From: "ev.lekht" Date: Fri, 22 Nov 2024 18:32:37 +0400 Subject: [PATCH 17/20] fix tests --- internal/messaging/processor_test.go | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/internal/messaging/processor_test.go b/internal/messaging/processor_test.go index 90400d28..26dab611 100644 --- a/internal/messaging/processor_test.go +++ b/internal/messaging/processor_test.go @@ -53,7 +53,7 @@ var ( } ) -func TestProcessInbound(t *testing.T) { +func TestProcessIncomingMessage(t *testing.T) { responseMessage := types.Message{ Type: generated.PingServiceV1Response, Metadata: metadata.Metadata{ @@ -113,13 +113,6 @@ func TestProcessInbound(t *testing.T) { }, err: ErrUnsupportedService, }, - "ignore own outbound messages": { - fields: fields{}, - args: args{ - msg: &types.Message{Metadata: metadata.Metadata{}, Sender: userID}, - }, - err: nil, // no error, msg will be just ignored - }, "err: process request message failed": { fields: fields{ serviceRegistry: mockServiceRegistry, @@ -304,7 +297,7 @@ func TestSendRequestMessage(t *testing.T) { }, }, prepare: func() { - mockCMAccounts.EXPECT().GetChequeOperators(gomock.Any(), gomock.Any()).Return([]common.Address{{}}, nil) + mockCMAccounts.EXPECT().GetFirstChequeOperator(gomock.Any(), gomock.Any()).Return(common.Address{}, nil) mockCMAccounts.EXPECT().GetServiceFee(gomock.Any(), gomock.Any(), gomock.Any()).Return(big.NewInt(1), nil) mockCMAccounts.EXPECT().IsBotAllowed(gomock.Any(), gomock.Any(), gomock.Any()).Return(true, nil) mockChequeHandler.EXPECT().IssueCheque(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Times(2).Return(&cheques.SignedCheque{}, nil) @@ -329,8 +322,7 @@ func TestSendRequestMessage(t *testing.T) { }, }, prepare: func() { - mockCMAccounts.EXPECT().GetChequeOperators(gomock.Any(), gomock.Any()). - Return([]common.Address{{}}, nil) + mockCMAccounts.EXPECT().GetFirstChequeOperator(gomock.Any(), gomock.Any()).Return(common.Address{}, nil) mockCMAccounts.EXPECT().GetServiceFee(gomock.Any(), gomock.Any(), gomock.Any()). Return(big.NewInt(1), nil) mockCMAccounts.EXPECT().IsBotAllowed(gomock.Any(), gomock.Any(), gomock.Any()).Return(true, nil) @@ -357,7 +349,7 @@ func TestSendRequestMessage(t *testing.T) { }, }, prepare: func() { - mockCMAccounts.EXPECT().GetChequeOperators(gomock.Any(), gomock.Any()).Return([]common.Address{{}}, nil) + mockCMAccounts.EXPECT().GetFirstChequeOperator(gomock.Any(), gomock.Any()).Return(common.Address{}, nil) mockCMAccounts.EXPECT().GetServiceFee(gomock.Any(), gomock.Any(), gomock.Any()).Return(big.NewInt(1), nil) mockCMAccounts.EXPECT().IsBotAllowed(gomock.Any(), gomock.Any(), gomock.Any()).Return(true, nil) mockMessenger.EXPECT().SendAsync(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) From efe4409ce1c5e75da70460c574c743db2bcba891 Mon Sep 17 00:00:00 2001 From: sk263 Date: Tue, 26 Nov 2024 16:18:27 +0100 Subject: [PATCH 18/20] GetChequeOperators crash fix --- pkg/cm_accounts/cm_accounts.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/cm_accounts/cm_accounts.go b/pkg/cm_accounts/cm_accounts.go index c1eece17..653dd4a2 100644 --- a/pkg/cm_accounts/cm_accounts.go +++ b/pkg/cm_accounts/cm_accounts.go @@ -3,6 +3,7 @@ package cmaccounts import ( "context" "crypto/ecdsa" + "errors" "fmt" "math/big" @@ -129,6 +130,11 @@ func (s *service) GetChequeOperators(ctx context.Context, cmAccountAddress commo botsAddresses = append(botsAddresses, address) } + if len(botsAddresses) == 0 { + s.logger.Error("No bot addresses found for CM account") + return nil, errors.New("no bot addresses found") + } + return botsAddresses, nil } From 2247c6b61282f22c4bdb76dbc0e6b073521d5637 Mon Sep 17 00:00:00 2001 From: evlekht Date: Wed, 27 Nov 2024 22:02:55 +0400 Subject: [PATCH 19/20] Update internal/messaging/mint.go Co-authored-by: Vjera Turk --- internal/messaging/mint.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/messaging/mint.go b/internal/messaging/mint.go index a46d4f08..8c6ac03d 100644 --- a/internal/messaging/mint.go +++ b/internal/messaging/mint.go @@ -210,8 +210,8 @@ func verifyAndFixBuyableUntil(buyableUntil *timestamppb.Timestamp, currentTime t return buyableUntil, nil } -func ensureHeaderV1(response **typesv1.ResponseHeader) { - if *response == nil { - *response = &typesv1.ResponseHeader{} +func ensureHeaderV1(responseHeader **typesv1.ResponseHeader) { + if *responseHeader == nil { + *responseHeader = &typesv1.ResponseHeader{} } } From f649e0b1035e8982f4ee99101da712efd01fa258 Mon Sep 17 00:00:00 2001 From: "ev.lekht" Date: Thu, 28 Nov 2024 16:48:28 +0400 Subject: [PATCH 20/20] Remove unused GetChequeOperators method --- pkg/cm_accounts/cm_accounts.go | 34 ----------------------------- pkg/cm_accounts/mock_cm_accounts.go | 15 ------------- 2 files changed, 49 deletions(-) diff --git a/pkg/cm_accounts/cm_accounts.go b/pkg/cm_accounts/cm_accounts.go index 653dd4a2..990518e6 100644 --- a/pkg/cm_accounts/cm_accounts.go +++ b/pkg/cm_accounts/cm_accounts.go @@ -3,7 +3,6 @@ package cmaccounts import ( "context" "crypto/ecdsa" - "errors" "fmt" "math/big" @@ -26,7 +25,6 @@ var ( ) type Service interface { - GetChequeOperators(ctx context.Context, cmAccountAddress common.Address) ([]common.Address, error) GetFirstChequeOperator(ctx context.Context, cmAccountAddress common.Address) (common.Address, error) VerifyCheque(ctx context.Context, cheque *cheques.SignedCheque) (bool, error) @@ -106,38 +104,6 @@ type service struct { chainID *big.Int } -func (s *service) GetChequeOperators(ctx context.Context, cmAccountAddress common.Address) ([]common.Address, error) { - cmAccount, err := s.cmAccount(cmAccountAddress) - if err != nil { - s.logger.Errorf("Failed to get cm account: %v", err) - return nil, err - } - - countBig, err := cmAccount.GetRoleMemberCount(&bind.CallOpts{Context: ctx}, chequeOperatorRole) - if err != nil { - s.logger.Errorf("Failed to call contract function: %v", err) - return nil, err - } - - count := countBig.Int64() - botsAddresses := make([]common.Address, 0, count) - for i := int64(0); i < count; i++ { - address, err := cmAccount.GetRoleMember(&bind.CallOpts{Context: ctx}, chequeOperatorRole, big.NewInt(i)) - if err != nil { - s.logger.Errorf("Failed to call contract function: %v", err) - continue - } - botsAddresses = append(botsAddresses, address) - } - - if len(botsAddresses) == 0 { - s.logger.Error("No bot addresses found for CM account") - return nil, errors.New("no bot addresses found") - } - - return botsAddresses, nil -} - func (s *service) GetFirstChequeOperator(ctx context.Context, cmAccountAddress common.Address) (common.Address, error) { cmAccount, err := s.cmAccount(cmAccountAddress) if err != nil { diff --git a/pkg/cm_accounts/mock_cm_accounts.go b/pkg/cm_accounts/mock_cm_accounts.go index f6a5c680..60e19a79 100644 --- a/pkg/cm_accounts/mock_cm_accounts.go +++ b/pkg/cm_accounts/mock_cm_accounts.go @@ -75,21 +75,6 @@ func (mr *MockServiceMockRecorder) CashInCheque(arg0, arg1, arg2 any) *gomock.Ca return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CashInCheque", reflect.TypeOf((*MockService)(nil).CashInCheque), arg0, arg1, arg2) } -// GetChequeOperators mocks base method. -func (m *MockService) GetChequeOperators(arg0 context.Context, arg1 common.Address) ([]common.Address, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetChequeOperators", arg0, arg1) - ret0, _ := ret[0].([]common.Address) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetChequeOperators indicates an expected call of GetChequeOperators. -func (mr *MockServiceMockRecorder) GetChequeOperators(arg0, arg1 any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetChequeOperators", reflect.TypeOf((*MockService)(nil).GetChequeOperators), arg0, arg1) -} - // GetFirstChequeOperator mocks base method. func (m *MockService) GetFirstChequeOperator(arg0 context.Context, arg1 common.Address) (common.Address, error) { m.ctrl.T.Helper()