From 8670988bd04013e92e2e8bc030f1d1b3ea3763e0 Mon Sep 17 00:00:00 2001 From: tioffs Date: Fri, 6 May 2022 14:00:03 +0300 Subject: [PATCH 1/6] fix: message id to string --- handler.kafka.tmpl | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/handler.kafka.tmpl b/handler.kafka.tmpl index 0de6fca..edc6699 100644 --- a/handler.kafka.tmpl +++ b/handler.kafka.tmpl @@ -19,7 +19,7 @@ import ( // {{.ModelName}}Event структурая, содержащая поля сообщения type {{.ModelName}}Event struct { - ID uuid.UUID + ID string Meta map[string]string Body *{{.ModelName}} } @@ -27,7 +27,7 @@ type {{.ModelName}}Event struct { // New{{.ModelName}}Event конструктор события {{.ModelName}}Event func New{{.ModelName}}Event(data *{{.ModelName}}) *{{.ModelName}}Event { return &{{.ModelName}}Event{ - ID: uuid.New(), + ID: uuid.New().String(), Meta: make(map[string]string), Body: data, } @@ -62,15 +62,8 @@ func Make{{.ModelName}}Handler(handler {{.ModelName}}Handler) message.NoPublishH return nil } - id, err := uuid.Parse(msg.UUID) - if err != nil { - log.Err(err).Msg("невозможно разобрать идентификатор сообщения") - - return nil - } - evt := &{{.ModelName}}Event{ - ID: id, + ID: msg.UUID, Meta: msg.Metadata, Body: r, } @@ -103,7 +96,7 @@ func (r *{{.ModelNamePrivate}}Publisher) Publish(event *{{.ModelName}}Event) err return errors.Wrap(err, "невозможно сериализовать данные") } - msg := message.NewMessage(event.ID.String(), payload) + msg := message.NewMessage(event.ID, payload) if event.Meta == nil { event.Meta = map[string]string{} From 7b0bfb3d236455e3328767b6b94a84b90a4ba6b2 Mon Sep 17 00:00:00 2001 From: tioffs Date: Fri, 6 May 2022 14:07:43 +0300 Subject: [PATCH 2/6] fix: change lint version --- .github/workflows/golangci-lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 8559736..8b3f99e 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -17,4 +17,4 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v2 with: - version: v1.43 + version: v1.42 From 2c643120b792248af1c053f4a713e0896b1ddc50 Mon Sep 17 00:00:00 2001 From: tioffs Date: Wed, 11 May 2022 12:20:51 +0300 Subject: [PATCH 3/6] fix: id event to param, delete import, err fix --- handler.kafka.tmpl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/handler.kafka.tmpl b/handler.kafka.tmpl index edc6699..f58a7ee 100644 --- a/handler.kafka.tmpl +++ b/handler.kafka.tmpl @@ -11,7 +11,6 @@ import ( "context" "github.com/ThreeDotsLabs/watermill/message" - "github.com/google/uuid" "github.com/pkg/errors" "github.com/rs/zerolog/log" "google.golang.org/protobuf/encoding/protojson" @@ -25,9 +24,9 @@ type {{.ModelName}}Event struct { } // New{{.ModelName}}Event конструктор события {{.ModelName}}Event -func New{{.ModelName}}Event(data *{{.ModelName}}) *{{.ModelName}}Event { +func New{{.ModelName}}Event(id string, data *{{.ModelName}}) *{{.ModelName}}Event { return &{{.ModelName}}Event{ - ID: uuid.New().String(), + ID: id, Meta: make(map[string]string), Body: data, } @@ -68,7 +67,7 @@ func Make{{.ModelName}}Handler(handler {{.ModelName}}Handler) message.NoPublishH Body: r, } - if err = handler.Handle(msg.Context(), evt); err != nil { + if err := handler.Handle(msg.Context(), evt); err != nil { return errors.Wrap(err, "не удалось обработать событие") } From a0ac9aae789273cc71f27f78f28ef66cb8d8d9f9 Mon Sep 17 00:00:00 2001 From: tioffs Date: Fri, 13 May 2022 10:14:07 +0300 Subject: [PATCH 4/6] fix: versions name --- handler.kafka.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/handler.kafka.tmpl b/handler.kafka.tmpl index f58a7ee..09bef94 100644 --- a/handler.kafka.tmpl +++ b/handler.kafka.tmpl @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // // versions: -// protoc-gen-go v1.27.1 +// protoc-gen-go-kafka v1.1.3 // protoc (unknown) // source: {{.PathFile}} From 679acde01a1c43375476fd0df870410f71a70575 Mon Sep 17 00:00:00 2001 From: tioffs Date: Fri, 13 May 2022 10:18:55 +0300 Subject: [PATCH 5/6] fix: versions name --- handler.kafka.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/handler.kafka.tmpl b/handler.kafka.tmpl index 09bef94..b3a7b48 100644 --- a/handler.kafka.tmpl +++ b/handler.kafka.tmpl @@ -1,4 +1,4 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. +// Code generated by protoc-gen-go-kafka. DO NOT EDIT. // // versions: // protoc-gen-go-kafka v1.1.3 From 2e4753b6b891a45b031957a3824212646dace28b Mon Sep 17 00:00:00 2001 From: tioffs Date: Fri, 13 May 2022 11:14:38 +0300 Subject: [PATCH 6/6] fix: render version in constant --- handler.kafka.tmpl | 2 +- main.go | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/handler.kafka.tmpl b/handler.kafka.tmpl index b3a7b48..752890d 100644 --- a/handler.kafka.tmpl +++ b/handler.kafka.tmpl @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-kafka. DO NOT EDIT. // // versions: -// protoc-gen-go-kafka v1.1.3 +// protoc-gen-go-kafka {{.Version}} // protoc (unknown) // source: {{.PathFile}} diff --git a/main.go b/main.go index aafbadf..ea481a5 100644 --- a/main.go +++ b/main.go @@ -19,11 +19,12 @@ type gen struct { ModelName string PackageName string PathFile string + Version string } const ( defaultSuffix = "Export" - version = "v1.1.1" + version = "v1.1.3" ) func main() { @@ -53,6 +54,7 @@ func main() { ModelName: message.GetName(), PackageName: string(file.GoPackageName), PathFile: file.Desc.Path(), + Version: version, }) if err != nil { plugin.Error(err)