From f46d54b0f0c509f36202c995d9679c20dafa274f Mon Sep 17 00:00:00 2001 From: Alexander Zemtsov Date: Wed, 2 Oct 2024 13:33:22 +0300 Subject: [PATCH] using proto to unmarshal tasks (#39) Signed-off-by: Alexander Zemtsov --- pkg/hlf/parser/batch.go | 6 ++++-- test/builder/batcher/execute_tasks_request.go | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/hlf/parser/batch.go b/pkg/hlf/parser/batch.go index 0e3b419..9b7d28b 100644 --- a/pkg/hlf/parser/batch.go +++ b/pkg/hlf/parser/batch.go @@ -56,8 +56,10 @@ func (p *Parser) extractBatchResponse(payload []byte) (*fpb.BatchResponse, error func (p *Parser) extractTaskRequest(payload []byte) (*fpb.ExecuteTasksRequest, error) { response := &fpb.ExecuteTasksRequest{} - if err := protojson.Unmarshal(payload, response); err != nil { - return nil, err + if err := proto.Unmarshal(payload, response); err != nil { + if err = protojson.Unmarshal(payload, response); err != nil { + return nil, err + } } return response, nil diff --git a/test/builder/batcher/execute_tasks_request.go b/test/builder/batcher/execute_tasks_request.go index 7c5c795..f708d47 100644 --- a/test/builder/batcher/execute_tasks_request.go +++ b/test/builder/batcher/execute_tasks_request.go @@ -3,7 +3,7 @@ package batcher import ( fpb "github.com/anoideaopen/foundation/proto" "github.com/go-errors/errors" - "google.golang.org/protobuf/encoding/protojson" + "github.com/golang/protobuf/proto" //nolint:staticcheck ) type ExecuteTasksRequestBuilder struct { @@ -28,7 +28,7 @@ func (b *ExecuteTasksRequestBuilder) Build() *fpb.ExecuteTasksRequest { } func (b *ExecuteTasksRequestBuilder) Marshal() []byte { - requestBytes, err := protojson.Marshal(b.request) + requestBytes, err := proto.Marshal(b.request) if err != nil { panic(errors.Errorf("Failed to marshal ExecuteTasksRequest: %v\n", err)) }