From 41e32e36b33ff45462e4b1e5251508ef3ea29424 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Thu, 3 Mar 2022 19:11:57 +0300 Subject: [PATCH 01/32] fix for empty default response Signed-off-by: Vasiliy Tolstov --- openapiv3.go | 83 ++++++++++++++++++++++++++++------------------------ variables.go | 4 +-- 2 files changed, 46 insertions(+), 41 deletions(-) diff --git a/openapiv3.go b/openapiv3.go index 00a3ed8..7723d5a 100644 --- a/openapiv3.go +++ b/openapiv3.go @@ -653,49 +653,54 @@ func (g *openapiv3Generator) buildOperationV3( opt := eopt.(*v3.Operation) if r := opt.Responses; r != nil { responses = r - } - if ref := responses.Default.GetReference(); ref != nil && ref.GetXRef() != "" { - xref := strings.TrimPrefix(ref.GetXRef(), ".") - description := "Default" - if strings.Contains(xref, "micro.errors.Error") { - description += " Error" - } - desc, err := protofiles.FindDescriptorByName(protoreflect.FullName(xref)) - if err != nil { - log.Printf("unknown ref type %s err %v", xref, err) - } else { - responses.Default.Oneof = &v3.ResponseOrReference_Response{ - Response: &v3.Response{ - Description: description, - Content: g.responseContentForMessage(&protogen.Message{ - Desc: desc.(protoreflect.MessageDescriptor), - }), - }, - } - } - } - for _, rref := range responses.GetResponseOrReference() { - if ref := rref.Value.GetReference(); ref != nil && ref.GetXRef() != "" { - xref := strings.TrimPrefix(ref.GetXRef(), ".") - description := "Default" - if strings.Contains(xref, "micro.errors.Error") { - description += " Error" - } - desc, err := protofiles.FindDescriptorByName(protoreflect.FullName(xref)) - if err != nil { - log.Printf("unknown ref type %s err %v", xref, err) - } else { - responses.Default.Oneof = &v3.ResponseOrReference_Response{ - Response: &v3.Response{ - Description: description, - Content: g.responseContentForMessage(&protogen.Message{ - Desc: desc.(protoreflect.MessageDescriptor), - }), - }, + rd := responses.Default + if rd != nil { + if ref := rd.GetReference(); ref != nil && ref.GetXRef() != "" { + xref := strings.TrimPrefix(ref.GetXRef(), ".") + description := "Default" + if strings.Contains(xref, "micro.errors.Error") { + description += " Error" + } + desc, err := protofiles.FindDescriptorByName(protoreflect.FullName(xref)) + if err != nil { + log.Printf("unknown ref type %s err %v", xref, err) + } else { + responses.Default.Oneof = &v3.ResponseOrReference_Response{ + Response: &v3.Response{ + Description: description, + Content: g.responseContentForMessage(&protogen.Message{ + Desc: desc.(protoreflect.MessageDescriptor), + }), + }, + } } } } + for _, rref := range responses.GetResponseOrReference() { + if ref := rref.Value.GetReference(); ref != nil && ref.GetXRef() != "" { + xref := strings.TrimPrefix(ref.GetXRef(), ".") + description := "Default" + if strings.Contains(xref, "micro.errors.Error") { + description += " Error" + } + desc, err := protofiles.FindDescriptorByName(protoreflect.FullName(xref)) + if err != nil { + log.Printf("unknown ref type %s err %v", xref, err) + } else { + responses.Default.Oneof = &v3.ResponseOrReference_Response{ + Response: &v3.Response{ + Description: description, + Content: g.responseContentForMessage(&protogen.Message{ + Desc: desc.(protoreflect.MessageDescriptor), + }), + }, + } + } + } + } + } else { + responses = &v3.Responses{} } } else { responses = &v3.Responses{} diff --git a/variables.go b/variables.go index 05d4a01..0cf425b 100644 --- a/variables.go +++ b/variables.go @@ -16,8 +16,8 @@ var ( microServerPackage = protogen.GoImportPath("go.unistack.org/micro/v3/server") microClientHttpPackage = protogen.GoImportPath("go.unistack.org/micro-client-http/v3") microServerHttpPackage = protogen.GoImportPath("go.unistack.org/micro-server-http/v3") - microCodecPackage = protogen.GoImportPath("go.unistack.org/micro-proto/v3/codec") - microErrorsPackage = protogen.GoImportPath("go.unistack.org/micro-proto/v3/errors") + microCodecPackage = protogen.GoImportPath("go.unistack.org/micro/v3/codec") + microErrorsPackage = protogen.GoImportPath("go.unistack.org/micro/v3/errors") timePackage = protogen.GoImportPath("time") deprecationComment = "// Deprecated: Do not use." versionComment = "v3.5.3" From 225887fef804b1bdaa05be58823470bb8e97b761 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Mar 2022 09:43:09 +0000 Subject: [PATCH 02/32] Bump actions/checkout from 2 to 3 Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v2...v3) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/build.yml | 4 ++-- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/pr.yml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4182c04..e8c3488 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,7 +13,7 @@ jobs: with: go-version: 1.16 - name: checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: cache uses: actions/cache@v2 with: @@ -31,7 +31,7 @@ jobs: runs-on: ubuntu-latest steps: - name: checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: lint uses: golangci/golangci-lint-action@v3 continue-on-error: true diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index fa4081e..9a3f470 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -43,7 +43,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index f807f24..309a470 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -13,7 +13,7 @@ jobs: with: go-version: 1.16 - name: checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: cache uses: actions/cache@v2 with: @@ -31,7 +31,7 @@ jobs: runs-on: ubuntu-latest steps: - name: checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: lint uses: golangci/golangci-lint-action@v3 continue-on-error: true From 8ecb705550d85490bc70a7b791357fe8707053a2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Mar 2022 09:43:13 +0000 Subject: [PATCH 03/32] Bump go.unistack.org/micro-proto/v3 from 3.2.5 to 3.2.7 Bumps [go.unistack.org/micro-proto/v3](https://github.com/unistack-org/micro-proto) from 3.2.5 to 3.2.7. - [Release notes](https://github.com/unistack-org/micro-proto/releases) - [Commits](https://github.com/unistack-org/micro-proto/compare/v3.2.5...v3.2.7) --- updated-dependencies: - dependency-name: go.unistack.org/micro-proto/v3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index e415ad8..4952a11 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.16 require ( github.com/fatih/structtag v1.2.0 - go.unistack.org/micro-proto/v3 v3.2.5 + go.unistack.org/micro-proto/v3 v3.2.7 golang.org/x/tools v0.1.9 google.golang.org/protobuf v1.27.1 ) diff --git a/go.sum b/go.sum index a10a838..8189285 100644 --- a/go.sum +++ b/go.sum @@ -68,8 +68,8 @@ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1: github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= -go.unistack.org/micro-proto/v3 v3.2.5 h1:qaMr9oaO8J2X9nvcZfQ+JriuEFfoMzRvFfQdKoVlWgU= -go.unistack.org/micro-proto/v3 v3.2.5/go.mod h1:ZltVWNECD5yK+40+OCONzGw4OtmSdTpVi8/KFgo9dqM= +go.unistack.org/micro-proto/v3 v3.2.7 h1:zG6d69kHc+oij2lwQ3AfrCgdjiEVRG2A7TlsxjusWs4= +go.unistack.org/micro-proto/v3 v3.2.7/go.mod h1:ZltVWNECD5yK+40+OCONzGw4OtmSdTpVi8/KFgo9dqM= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= From 8844f015580f1b8151f700b6adeee3979fc21b68 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Mon, 7 Mar 2022 13:47:14 +0300 Subject: [PATCH 04/32] update go version Signed-off-by: Vasiliy Tolstov --- .github/workflows/build.yml | 2 +- .github/workflows/pr.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e8c3488..6af7ba8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,7 +11,7 @@ jobs: - name: setup uses: actions/setup-go@v2 with: - go-version: 1.16 + go-version: 1.17 - name: checkout uses: actions/checkout@v3 - name: cache diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 309a470..e0ca38e 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -11,7 +11,7 @@ jobs: - name: setup uses: actions/setup-go@v2 with: - go-version: 1.16 + go-version: 1.17 - name: checkout uses: actions/checkout@v3 - name: cache From 4f0a7e0c93eb800a32647aff5cd38d564724e87b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 16 Mar 2022 15:14:49 +0000 Subject: [PATCH 05/32] Bump golang.org/x/tools from 0.1.9 to 0.1.10 Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.1.9 to 0.1.10. - [Release notes](https://github.com/golang/tools/releases) - [Commits](https://github.com/golang/tools/compare/v0.1.9...v0.1.10) --- updated-dependencies: - dependency-name: golang.org/x/tools dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 4952a11..03a3570 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,6 @@ go 1.16 require ( github.com/fatih/structtag v1.2.0 go.unistack.org/micro-proto/v3 v3.2.7 - golang.org/x/tools v0.1.9 + golang.org/x/tools v0.1.10 google.golang.org/protobuf v1.27.1 ) diff --git a/go.sum b/go.sum index 8189285..1530b39 100644 --- a/go.sum +++ b/go.sum @@ -71,14 +71,14 @@ go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqe go.unistack.org/micro-proto/v3 v3.2.7 h1:zG6d69kHc+oij2lwQ3AfrCgdjiEVRG2A7TlsxjusWs4= go.unistack.org/micro-proto/v3 v3.2.7/go.mod h1:ZltVWNECD5yK+40+OCONzGw4OtmSdTpVi8/KFgo9dqM= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/mod v0.5.1 h1:OJxoQ/rynoF0dcCdI7cLPktw/hR2cueqYfjm43oqK38= -golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= +golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o= +golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -87,6 +87,7 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= @@ -105,6 +106,7 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 h1:id054HUawV2/6IGm2IV8KZQjqtwAOo2CYlOToYqa0d0= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -119,8 +121,8 @@ golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3 golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.9 h1:j9KsMiaP1c3B0OTQGth0/k+miLGTgLsAFUCrF2vLcF8= -golang.org/x/tools v0.1.9/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= +golang.org/x/tools v0.1.10 h1:QjFRCZxdOhBJ/UNgnBZLbNV13DlbnK0quyivTnXJM20= +golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From 378c00c16da7496781ac042e459e31be4a193adf Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Sat, 19 Mar 2022 15:13:34 +0300 Subject: [PATCH 06/32] support message reference Signed-off-by: Vasiliy Tolstov --- http.go | 8 ++--- main.go | 2 ++ micro.go | 10 +++---- rpc.go | 8 ++--- util.go | 90 ++++++++++++++++++++++++++++++++++++++++---------------- 5 files changed, 80 insertions(+), 38 deletions(-) diff --git a/http.go b/http.go index ef55026..ffd0a7b 100644 --- a/http.go +++ b/http.go @@ -40,13 +40,13 @@ func (g *Generator) httpGenerate(component string, plugin *protogen.Plugin, genC for _, service := range file.Services { if genClient { - generateServiceClient(gfile, service) - generateServiceClientMethods(gfile, service, true) + g.generateServiceClient(gfile, service) + g.generateServiceClientMethods(gfile, service, true) } if genServer { generateServiceServer(gfile, service) - generateServiceServerMethods(gfile, service) - generateServiceRegister(gfile, service) + g.generateServiceServerMethods(gfile, service) + g.generateServiceRegister(gfile, service) } } } diff --git a/main.go b/main.go index 710bced..5a0a556 100644 --- a/main.go +++ b/main.go @@ -45,11 +45,13 @@ type Generator struct { fieldaligment bool tagPath string openapiFile string + plugin *protogen.Plugin } func (g *Generator) Generate(plugin *protogen.Plugin) error { var err error + g.plugin = plugin g.standalone = *flagStandalone g.debug = *flagDebug g.components = *flagComponents diff --git a/micro.go b/micro.go index 0daf737..c99d60c 100644 --- a/micro.go +++ b/micro.go @@ -35,14 +35,14 @@ func (g *Generator) microGenerate(component string, plugin *protogen.Plugin, gen } // generate services for _, service := range file.Services { - generateServiceEndpoints(gfile, service) + g.generateServiceEndpoints(gfile, service) if genClient { - generateServiceClientInterface(gfile, service) - generateServiceClientStreamInterface(gfile, service) + g.generateServiceClientInterface(gfile, service) + g.generateServiceClientStreamInterface(gfile, service) } if genServer { - generateServiceServerInterface(gfile, service) - generateServiceServerStreamInterface(gfile, service) + g.generateServiceServerInterface(gfile, service) + g.generateServiceServerStreamInterface(gfile, service) } } diff --git a/rpc.go b/rpc.go index 157114c..0efdd03 100644 --- a/rpc.go +++ b/rpc.go @@ -37,13 +37,13 @@ func (g *Generator) rpcGenerate(component string, plugin *protogen.Plugin, genCl } for _, service := range file.Services { if genClient { - generateServiceClient(gfile, service) - generateServiceClientMethods(gfile, service, false) + g.generateServiceClient(gfile, service) + g.generateServiceClientMethods(gfile, service, false) } if genServer { generateServiceServer(gfile, service) - generateServiceServerMethods(gfile, service) - generateServiceRegister(gfile, service) + g.generateServiceServerMethods(gfile, service) + g.generateServiceRegister(gfile, service) } } } diff --git a/util.go b/util.go index 3dc1e63..d9a93e8 100644 --- a/util.go +++ b/util.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "log" "net/http" "strings" @@ -28,7 +29,7 @@ func unexport(s string) string { return strings.ToLower(s[:1]) + s[1:] } -func generateServiceClient(gfile *protogen.GeneratedFile, service *protogen.Service) { +func (g *Generator) generateServiceClient(gfile *protogen.GeneratedFile, service *protogen.Service) { serviceName := service.GoName // if rule, ok := getMicroApiService(service); ok { // gfile.P("// client wrappers ", strings.Join(rule.ClientWrappers, ", ")) @@ -44,11 +45,11 @@ func generateServiceClient(gfile *protogen.GeneratedFile, service *protogen.Serv gfile.P() } -func generateServiceClientMethods(gfile *protogen.GeneratedFile, service *protogen.Service, http bool) { +func (g *Generator) generateServiceClientMethods(gfile *protogen.GeneratedFile, service *protogen.Service, http bool) { serviceName := service.GoName for _, method := range service.Methods { methodName := fmt.Sprintf("%s.%s", serviceName, method.GoName) - generateClientFuncSignature(gfile, serviceName, method) + g.generateClientFuncSignature(gfile, serviceName, method) if http && method.Desc.Options() != nil { if proto.HasExtension(method.Desc.Options(), v2.E_Openapiv2Operation) { @@ -61,20 +62,25 @@ func generateServiceClientMethods(gfile *protogen.GeneratedFile, service *protog gfile.P("errmap := make(map[string]interface{}, ", len(r.Responses.ResponseCode), ")") for _, rsp := range r.Responses.ResponseCode { if schema := rsp.Value.GetJsonReference(); schema != nil { - ref := schema.XRef - if strings.HasPrefix(ref, "."+string(service.Desc.ParentFile().Package())+".") { - ref = strings.TrimPrefix(ref, "."+string(service.Desc.ParentFile().Package())+".") + xref := schema.XRef + if strings.HasPrefix(xref, "."+string(service.Desc.ParentFile().Package())+".") { + xref = strings.TrimPrefix(xref, "."+string(service.Desc.ParentFile().Package())+".") } - if ref[0] == '.' { - ref = ref[1:] + if xref[0] == '.' { + xref = xref[1:] } - switch ref { + switch xref { case "micro.codec.Frame": gfile.P(`errmap["`, rsp.Name, `"] = &`, microCodecPackage.Ident("Frame"), "{}") case "micro.errors.Error": gfile.P(`errmap["`, rsp.Name, `"] = &`, microErrorsPackage.Ident("Error"), "{}") default: - gfile.P(`errmap["`, rsp.Name, `"] = &`, ref, "{}") + ident, err := g.getGoIdentByXref(strings.TrimPrefix(schema.XRef, ".")) + if err != nil { + log.Printf("cant find message by ref %s\n", schema.XRef) + continue + } + gfile.P(`errmap["`, rsp.Name, `"] = &`, gfile.QualifiedGoIdent(ident), "{}") } } } @@ -97,20 +103,25 @@ func generateServiceClientMethods(gfile *protogen.GeneratedFile, service *protog gfile.P("errmap := make(map[string]interface{}, ", len(resps), ")") for _, rsp := range resps { if schema := rsp.Value.GetReference(); schema != nil { - ref := schema.XRef - if strings.HasPrefix(ref, "."+string(service.Desc.ParentFile().Package())+".") { - ref = strings.TrimPrefix(ref, "."+string(service.Desc.ParentFile().Package())+".") + xref := schema.XRef + if strings.HasPrefix(xref, "."+string(service.Desc.ParentFile().Package())+".") { + xref = strings.TrimPrefix(xref, "."+string(service.Desc.ParentFile().Package())+".") } - if ref[0] == '.' { - ref = ref[1:] + if xref[0] == '.' { + xref = xref[1:] } - switch ref { + switch xref { case "micro.codec.Frame": gfile.P(`errmap["`, rsp.Name, `"] = &`, microCodecPackage.Ident("Frame"), "{}") case "micro.errors.Error": gfile.P(`errmap["`, rsp.Name, `"] = &`, microErrorsPackage.Ident("Error"), "{}") default: - gfile.P(`errmap["`, rsp.Name, `"] = &`, ref, "{}") + ident, err := g.getGoIdentByXref(strings.TrimPrefix(schema.XRef, ".")) + if err != nil { + log.Printf("cant find message by ref %s\n", schema.XRef) + continue + } + gfile.P(`errmap["`, rsp.Name, `"] = &`, gfile.QualifiedGoIdent(ident), "{}") } } } @@ -300,7 +311,7 @@ func generateServiceServer(gfile *protogen.GeneratedFile, service *protogen.Serv gfile.P() } -func generateServiceServerMethods(gfile *protogen.GeneratedFile, service *protogen.Service) { +func (g *Generator) generateServiceServerMethods(gfile *protogen.GeneratedFile, service *protogen.Service) { serviceName := service.GoName for _, method := range service.Methods { generateServerFuncSignature(gfile, serviceName, method, true) @@ -444,7 +455,7 @@ func generateServiceServerMethods(gfile *protogen.GeneratedFile, service *protog } } -func generateServiceRegister(gfile *protogen.GeneratedFile, service *protogen.Service) { +func (g *Generator) generateServiceRegister(gfile *protogen.GeneratedFile, service *protogen.Service) { serviceName := service.GoName gfile.P("func Register", serviceName, "Server(s ", microServerPackage.Ident("Server"), ", sh ", serviceName, "Server, opts ...", microServerPackage.Ident("HandlerOption"), ") error {") gfile.P("type ", unexport(serviceName), " interface {") @@ -508,7 +519,7 @@ func generateServerSignature(gfile *protogen.GeneratedFile, serviceName string, gfile.P(args...) } -func generateClientFuncSignature(gfile *protogen.GeneratedFile, serviceName string, method *protogen.Method) { +func (g *Generator) generateClientFuncSignature(gfile *protogen.GeneratedFile, serviceName string, method *protogen.Method) { args := append([]interface{}{}, "func (c *", unexport(serviceName), @@ -547,7 +558,7 @@ func generateClientSignature(gfile *protogen.GeneratedFile, serviceName string, gfile.P(args...) } -func generateServiceClientInterface(gfile *protogen.GeneratedFile, service *protogen.Service) { +func (g *Generator) generateServiceClientInterface(gfile *protogen.GeneratedFile, service *protogen.Service) { serviceName := service.GoName gfile.P("type ", serviceName, "Client interface {") for _, method := range service.Methods { @@ -557,7 +568,7 @@ func generateServiceClientInterface(gfile *protogen.GeneratedFile, service *prot gfile.P() } -func generateServiceServerInterface(gfile *protogen.GeneratedFile, service *protogen.Service) { +func (g *Generator) generateServiceServerInterface(gfile *protogen.GeneratedFile, service *protogen.Service) { serviceName := service.GoName gfile.P("type ", serviceName, "Server interface {") for _, method := range service.Methods { @@ -567,7 +578,7 @@ func generateServiceServerInterface(gfile *protogen.GeneratedFile, service *prot gfile.P() } -func generateServiceClientStreamInterface(gfile *protogen.GeneratedFile, service *protogen.Service) { +func (g *Generator) generateServiceClientStreamInterface(gfile *protogen.GeneratedFile, service *protogen.Service) { serviceName := service.GoName for _, method := range service.Methods { if !method.Desc.IsStreamingClient() && !method.Desc.IsStreamingServer() { @@ -594,7 +605,7 @@ func generateServiceClientStreamInterface(gfile *protogen.GeneratedFile, service } } -func generateServiceServerStreamInterface(gfile *protogen.GeneratedFile, service *protogen.Service) { +func (g *Generator) generateServiceServerStreamInterface(gfile *protogen.GeneratedFile, service *protogen.Service) { serviceName := service.GoName for _, method := range service.Methods { if !method.Desc.IsStreamingClient() && !method.Desc.IsStreamingServer() { @@ -621,7 +632,7 @@ func generateServiceServerStreamInterface(gfile *protogen.GeneratedFile, service } } -func generateServiceEndpoints(gfile *protogen.GeneratedFile, service *protogen.Service) { +func (g *Generator) generateServiceEndpoints(gfile *protogen.GeneratedFile, service *protogen.Service) { serviceName := service.GoName gfile.P("var (") gfile.P(serviceName, "Name", "=", `"`, serviceName, `"`) @@ -755,3 +766,32 @@ func generateEndpoint(gfile *protogen.GeneratedFile, serviceName string, methodN } gfile.P(`Handler: "rpc",`) } + +func (g *Generator) getGoIdentByXref(xref string) (protogen.GoIdent, error) { + idx := strings.LastIndex(xref, ".") + pkg := xref[:idx] + msg := xref[idx+1:] + for _, file := range g.plugin.Files { + if strings.Compare(pkg, *(file.Proto.Package)) != 0 { + continue + } + if ident, err := getGoIdentByMessage(file.Messages, msg); err == nil { + return ident, nil + } + } + return protogen.GoIdent{}, fmt.Errorf("not found") +} + +func getGoIdentByMessage(messages []*protogen.Message, msg string) (protogen.GoIdent, error) { + for _, message := range messages { + if strings.Compare(msg, message.GoIdent.GoName) == 0 { + return message.GoIdent, nil + } + if len(message.Messages) > 0 { + if ident, err := getGoIdentByMessage(message.Messages, msg); err == nil { + return ident, nil + } + } + } + return protogen.GoIdent{}, fmt.Errorf("not found") +} From 59ffe0f3eab03deaca6bb6dffb5d182aac3f992d Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Sat, 19 Mar 2022 15:14:58 +0300 Subject: [PATCH 07/32] update workflows Signed-off-by: Vasiliy Tolstov --- .github/workflows/autoapprove.yml | 20 ++++++ .github/workflows/automerge.yml | 21 +++++++ .github/workflows/build.yml | 3 +- .github/workflows/codeql-analysis.yml | 21 ++++--- .github/workflows/dependabot-automerge.yml | 73 +++++----------------- .github/workflows/pr.yml | 3 +- 6 files changed, 74 insertions(+), 67 deletions(-) create mode 100644 .github/workflows/autoapprove.yml create mode 100644 .github/workflows/automerge.yml diff --git a/.github/workflows/autoapprove.yml b/.github/workflows/autoapprove.yml new file mode 100644 index 0000000..ebe28c9 --- /dev/null +++ b/.github/workflows/autoapprove.yml @@ -0,0 +1,20 @@ +name: "autoapprove" + +on: + pull_request_target: + types: [assigned, opened, synchronize, reopened] + +permissions: + pull-requests: write + contents: write + +jobs: + autoapprove: + runs-on: ubuntu-latest + steps: + - name: approve + uses: hmarr/auto-approve-action@v2 + if: github.actor == 'vtolstov' || github.actor == 'dependabot[bot]' + id: approve + with: + github-token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml new file mode 100644 index 0000000..5ff3f69 --- /dev/null +++ b/.github/workflows/automerge.yml @@ -0,0 +1,21 @@ +name: "automerge" + +on: + pull_request_target: + types: [assigned, opened, synchronize, reopened] + +permissions: + pull-requests: write + contents: write + +jobs: + automerge: + runs-on: ubuntu-latest + if: github.actor == 'vtolstov' + steps: + - name: merge + id: merge + run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.TOKEN}} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6af7ba8..ddc5253 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,6 +3,7 @@ on: push: branches: - master + - v3 jobs: test: name: test @@ -33,7 +34,7 @@ jobs: - name: checkout uses: actions/checkout@v3 - name: lint - uses: golangci/golangci-lint-action@v3 + uses: golangci/golangci-lint-action@v3.1.0 continue-on-error: true with: # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 9a3f470..b3d478e 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -9,7 +9,7 @@ # the `language` matrix defined below to confirm you have the correct set of # supported CodeQL languages. # -name: "CodeQL" +name: "codeql" on: workflow_run: @@ -17,16 +17,16 @@ on: types: - completed push: - branches: [ master ] + branches: [ master, v3 ] pull_request: # The branches below must be a subset of the branches above - branches: [ master ] + branches: [ master, v3 ] schedule: - cron: '34 1 * * 0' jobs: analyze: - name: Analyze + name: analyze runs-on: ubuntu-latest permissions: actions: read @@ -42,11 +42,14 @@ jobs: # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed steps: - - name: Checkout repository + - name: checkout uses: actions/checkout@v3 - + - name: setup + uses: actions/setup-go@v2 + with: + go-version: 1.17 # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL + - name: init uses: github/codeql-action/init@v1 with: languages: ${{ matrix.language }} @@ -57,7 +60,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild + - name: autobuild uses: github/codeql-action/autobuild@v1 # ℹ️ Command-line programs to run using the OS shell. @@ -71,5 +74,5 @@ jobs: # make bootstrap # make release - - name: Perform CodeQL Analysis + - name: analyze uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/dependabot-automerge.yml b/.github/workflows/dependabot-automerge.yml index 69de7d8..3681028 100644 --- a/.github/workflows/dependabot-automerge.yml +++ b/.github/workflows/dependabot-automerge.yml @@ -1,66 +1,27 @@ -name: "prautomerge" +name: "dependabot-automerge" on: - workflow_run: - workflows: ["prbuild"] - types: - - completed + pull_request_target: + types: [assigned, opened, synchronize, reopened] permissions: - contents: write pull-requests: write + contents: write jobs: - Dependabot-Automerge: + automerge: runs-on: ubuntu-latest - # Contains workaround to execute if dependabot updates the PR by checking for the base branch in the linked PR - # The the github.event.workflow_run.event value is 'push' and not 'pull_request' - # dont work with multiple workflows when last returns success - if: >- - github.event.workflow_run.conclusion == 'success' - && github.actor == 'dependabot[bot]' - && github.event.sender.login == 'dependabot[bot]' - && github.event.sender.type == 'Bot' - && (github.event.workflow_run.event == 'pull_request' - || (github.event.workflow_run.event == 'push' && github.event.workflow_run.pull_requests[0].base.ref == github.event.repository.default_branch )) + if: github.actor == 'dependabot[bot]' steps: - - name: Approve Changes and Merge changes if label 'dependencies' is set - uses: actions/github-script@v6 + - name: metadata + id: metadata + uses: dependabot/fetch-metadata@v1.3.0 with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - console.log(context.payload.workflow_run); - - var labelNames = await github.paginate( - github.issues.listLabelsOnIssue, - { - repo: context.repo.repo, - owner: context.repo.owner, - issue_number: context.payload.workflow_run.pull_requests[0].number, - }, - (response) => response.data.map( - (label) => label.name - ) - ); - - console.log(labelNames); - - if (labelNames.includes('dependencies')) { - console.log('Found label'); - - await github.pulls.createReview({ - repo: context.repo.repo, - owner: context.repo.owner, - pull_number: context.payload.workflow_run.pull_requests[0].number, - event: 'APPROVE' - }); - console.log('Approved PR'); - - await github.pulls.merge({ - repo: context.repo.repo, - owner: context.repo.owner, - pull_number: context.payload.workflow_run.pull_requests[0].number, - }); - - console.log('Merged PR'); - } + github-token: "${{ secrets.TOKEN }}" + - name: merge + id: merge + if: ${{contains(steps.metadata.outputs.dependency-names, 'go.unistack.org')}} + run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.TOKEN}} diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index e0ca38e..b6a6345 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -3,6 +3,7 @@ on: pull_request: branches: - master + - v3 jobs: test: name: test @@ -33,7 +34,7 @@ jobs: - name: checkout uses: actions/checkout@v3 - name: lint - uses: golangci/golangci-lint-action@v3 + uses: golangci/golangci-lint-action@v3.1.0 continue-on-error: true with: # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. From 15e7f6bd164612b6e397d4a2711bc3863e1e083d Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Sun, 20 Mar 2022 14:18:35 +0300 Subject: [PATCH 08/32] add drpc as known component Signed-off-by: Vasiliy Tolstov --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index 5a0a556..5a5b9b2 100644 --- a/main.go +++ b/main.go @@ -89,7 +89,7 @@ func (g *Generator) Generate(plugin *protogen.Plugin) error { err = g.microGenerate(component, plugin, genClient, genServer) case "http": err = g.httpGenerate(component, plugin, genClient, genServer) - case "grpc", "rpc": + case "grpc", "drpc", "rpc": err = g.rpcGenerate("rpc", plugin, genClient, genServer) case "gorilla": err = g.gorillaGenerate(component, plugin) From a2fea36f50498cf3de775ead86a1fd683422316f Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Sun, 20 Mar 2022 15:08:04 +0300 Subject: [PATCH 09/32] fix drpc method name in generator Signed-off-by: Vasiliy Tolstov --- http.go | 2 +- main.go | 2 +- rpc.go | 2 +- util.go | 7 +++++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/http.go b/http.go index ffd0a7b..8fc04ab 100644 --- a/http.go +++ b/http.go @@ -41,7 +41,7 @@ func (g *Generator) httpGenerate(component string, plugin *protogen.Plugin, genC for _, service := range file.Services { if genClient { g.generateServiceClient(gfile, service) - g.generateServiceClientMethods(gfile, service, true) + g.generateServiceClientMethods(gfile, service, component) } if genServer { generateServiceServer(gfile, service) diff --git a/main.go b/main.go index 5a5b9b2..9b18889 100644 --- a/main.go +++ b/main.go @@ -90,7 +90,7 @@ func (g *Generator) Generate(plugin *protogen.Plugin) error { case "http": err = g.httpGenerate(component, plugin, genClient, genServer) case "grpc", "drpc", "rpc": - err = g.rpcGenerate("rpc", plugin, genClient, genServer) + err = g.rpcGenerate(component, plugin, genClient, genServer) case "gorilla": err = g.gorillaGenerate(component, plugin) case "chi": diff --git a/rpc.go b/rpc.go index 0efdd03..ab0bedb 100644 --- a/rpc.go +++ b/rpc.go @@ -38,7 +38,7 @@ func (g *Generator) rpcGenerate(component string, plugin *protogen.Plugin, genCl for _, service := range file.Services { if genClient { g.generateServiceClient(gfile, service) - g.generateServiceClientMethods(gfile, service, false) + g.generateServiceClientMethods(gfile, service, component) } if genServer { generateServiceServer(gfile, service) diff --git a/util.go b/util.go index d9a93e8..be1a34b 100644 --- a/util.go +++ b/util.go @@ -45,13 +45,16 @@ func (g *Generator) generateServiceClient(gfile *protogen.GeneratedFile, service gfile.P() } -func (g *Generator) generateServiceClientMethods(gfile *protogen.GeneratedFile, service *protogen.Service, http bool) { +func (g *Generator) generateServiceClientMethods(gfile *protogen.GeneratedFile, service *protogen.Service, component string) { serviceName := service.GoName for _, method := range service.Methods { methodName := fmt.Sprintf("%s.%s", serviceName, method.GoName) + if component == "drpc" { + methodName = fmt.Sprintf("%s.%s", method.Parent.Desc.FullName(), method.Desc.Name()) + } g.generateClientFuncSignature(gfile, serviceName, method) - if http && method.Desc.Options() != nil { + if component == "http" && method.Desc.Options() != nil { if proto.HasExtension(method.Desc.Options(), v2.E_Openapiv2Operation) { opts := proto.GetExtension(method.Desc.Options(), v2.E_Openapiv2Operation) if opts != nil { From 773793955d6aaccf9d677fe361f1436272c8fb04 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 22 Mar 2022 15:29:50 +0000 Subject: [PATCH 10/32] Bump google.golang.org/protobuf from 1.27.1 to 1.28.0 Bumps [google.golang.org/protobuf](https://github.com/protocolbuffers/protobuf-go) from 1.27.1 to 1.28.0. - [Release notes](https://github.com/protocolbuffers/protobuf-go/releases) - [Changelog](https://github.com/protocolbuffers/protobuf-go/blob/master/release.bash) - [Commits](https://github.com/protocolbuffers/protobuf-go/compare/v1.27.1...v1.28.0) --- updated-dependencies: - dependency-name: google.golang.org/protobuf dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 03a3570..9b13454 100644 --- a/go.mod +++ b/go.mod @@ -6,5 +6,5 @@ require ( github.com/fatih/structtag v1.2.0 go.unistack.org/micro-proto/v3 v3.2.7 golang.org/x/tools v0.1.10 - google.golang.org/protobuf v1.27.1 + google.golang.org/protobuf v1.28.0 ) diff --git a/go.sum b/go.sum index 1530b39..5a34acb 100644 --- a/go.sum +++ b/go.sum @@ -153,8 +153,9 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From e587b778b2d8dc1b5482851ef169eaded6942014 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 22 Mar 2022 19:58:08 +0000 Subject: [PATCH 11/32] Bump actions/cache from 2 to 3 Bumps [actions/cache](https://github.com/actions/cache) from 2 to 3. - [Release notes](https://github.com/actions/cache/releases) - [Commits](https://github.com/actions/cache/compare/v2...v3) --- updated-dependencies: - dependency-name: actions/cache dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/build.yml | 2 +- .github/workflows/pr.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ddc5253..958bd05 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,7 @@ jobs: - name: checkout uses: actions/checkout@v3 - name: cache - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index b6a6345..4fc074b 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -16,7 +16,7 @@ jobs: - name: checkout uses: actions/checkout@v3 - name: cache - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} From a9d41f3adb346944d7cd5dcf8f90d30639761d0c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Apr 2022 15:20:06 +0000 Subject: [PATCH 12/32] Bump actions/setup-go from 2 to 3 Bumps [actions/setup-go](https://github.com/actions/setup-go) from 2 to 3. - [Release notes](https://github.com/actions/setup-go/releases) - [Commits](https://github.com/actions/setup-go/compare/v2...v3) --- updated-dependencies: - dependency-name: actions/setup-go dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/build.yml | 2 +- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/pr.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 958bd05..ae83070 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - name: setup - uses: actions/setup-go@v2 + uses: actions/setup-go@v3 with: go-version: 1.17 - name: checkout diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index b3d478e..bf6299c 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -45,7 +45,7 @@ jobs: - name: checkout uses: actions/checkout@v3 - name: setup - uses: actions/setup-go@v2 + uses: actions/setup-go@v3 with: go-version: 1.17 # Initializes the CodeQL tools for scanning. diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 4fc074b..68510b4 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - name: setup - uses: actions/setup-go@v2 + uses: actions/setup-go@v3 with: go-version: 1.17 - name: checkout From 78a508f48d174eff4136c1ab302d7ef5b1e516cd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 21 Apr 2022 15:15:35 +0300 Subject: [PATCH 13/32] Bump dependabot/fetch-metadata from 1.3.0 to 1.3.1 (#48) Bumps [dependabot/fetch-metadata](https://github.com/dependabot/fetch-metadata) from 1.3.0 to 1.3.1. - [Release notes](https://github.com/dependabot/fetch-metadata/releases) - [Commits](https://github.com/dependabot/fetch-metadata/compare/v1.3.0...v1.3.1) --- updated-dependencies: - dependency-name: dependabot/fetch-metadata dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/dependabot-automerge.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dependabot-automerge.yml b/.github/workflows/dependabot-automerge.yml index 3681028..7cf424b 100644 --- a/.github/workflows/dependabot-automerge.yml +++ b/.github/workflows/dependabot-automerge.yml @@ -15,7 +15,7 @@ jobs: steps: - name: metadata id: metadata - uses: dependabot/fetch-metadata@v1.3.0 + uses: dependabot/fetch-metadata@v1.3.1 with: github-token: "${{ secrets.TOKEN }}" - name: merge From adb15d9a67258b999fec88463c291dc1cd44d4bf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Apr 2022 21:45:08 +0300 Subject: [PATCH 14/32] Bump github/codeql-action from 1 to 2 (#49) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 1 to 2. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/v1...v2) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/codeql-analysis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index bf6299c..2f6c6de 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -50,7 +50,7 @@ jobs: go-version: 1.17 # Initializes the CodeQL tools for scanning. - name: init - uses: github/codeql-action/init@v1 + uses: github/codeql-action/init@v2 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -61,7 +61,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: autobuild - uses: github/codeql-action/autobuild@v1 + uses: github/codeql-action/autobuild@v2 # ℹ️ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -75,4 +75,4 @@ jobs: # make release - name: analyze - uses: github/codeql-action/analyze@v1 + uses: github/codeql-action/analyze@v2 From e8389ad0f8f2bb8057e54cbac0093163eae847c6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 25 Jun 2022 22:41:48 +0300 Subject: [PATCH 15/32] Bump golang.org/x/tools from 0.1.10 to 0.1.11 (#51) Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.1.10 to 0.1.11. - [Release notes](https://github.com/golang/tools/releases) - [Commits](https://github.com/golang/tools/compare/v0.1.10...v0.1.11) --- updated-dependencies: - dependency-name: golang.org/x/tools dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 9b13454..5eb447d 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,6 @@ go 1.16 require ( github.com/fatih/structtag v1.2.0 go.unistack.org/micro-proto/v3 v3.2.7 - golang.org/x/tools v0.1.10 + golang.org/x/tools v0.1.11 google.golang.org/protobuf v1.28.0 ) diff --git a/go.sum b/go.sum index 5a34acb..ba4c15b 100644 --- a/go.sum +++ b/go.sum @@ -77,8 +77,8 @@ golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o= -golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -121,10 +121,9 @@ golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3 golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.10 h1:QjFRCZxdOhBJ/UNgnBZLbNV13DlbnK0quyivTnXJM20= -golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= +golang.org/x/tools v0.1.11 h1:loJ25fNOEhSXfHrpoGj91eCUThwdNX6u24rO1xnNteY= +golang.org/x/tools v0.1.11/go.mod h1:SgwaegtQh8clINPpECJMqnxLv9I09HLqnW3RMqW0CA4= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From f07229411097dd743f74ff0c17e60ecb6d8b0682 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 25 Jun 2022 22:51:12 +0300 Subject: [PATCH 16/32] Bump golangci/golangci-lint-action from 3.1.0 to 3.2.0 (#50) Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 3.1.0 to 3.2.0. - [Release notes](https://github.com/golangci/golangci-lint-action/releases) - [Commits](https://github.com/golangci/golangci-lint-action/compare/v3.1.0...v3.2.0) --- updated-dependencies: - dependency-name: golangci/golangci-lint-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/build.yml | 2 +- .github/workflows/pr.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ae83070..9c95dde 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,7 +34,7 @@ jobs: - name: checkout uses: actions/checkout@v3 - name: lint - uses: golangci/golangci-lint-action@v3.1.0 + uses: golangci/golangci-lint-action@v3.2.0 continue-on-error: true with: # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 68510b4..b7f1bcf 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -34,7 +34,7 @@ jobs: - name: checkout uses: actions/checkout@v3 - name: lint - uses: golangci/golangci-lint-action@v3.1.0 + uses: golangci/golangci-lint-action@v3.2.0 continue-on-error: true with: # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. From a58a9d51735ea228b6cb173efdd0704cf37f0b59 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 28 Aug 2022 17:23:36 +0300 Subject: [PATCH 17/32] Bump google.golang.org/protobuf from 1.28.0 to 1.28.1 (#55) Bumps [google.golang.org/protobuf](https://github.com/protocolbuffers/protobuf-go) from 1.28.0 to 1.28.1. - [Release notes](https://github.com/protocolbuffers/protobuf-go/releases) - [Changelog](https://github.com/protocolbuffers/protobuf-go/blob/master/release.bash) - [Commits](https://github.com/protocolbuffers/protobuf-go/compare/v1.28.0...v1.28.1) --- updated-dependencies: - dependency-name: google.golang.org/protobuf dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 5eb447d..9186a1e 100644 --- a/go.mod +++ b/go.mod @@ -6,5 +6,5 @@ require ( github.com/fatih/structtag v1.2.0 go.unistack.org/micro-proto/v3 v3.2.7 golang.org/x/tools v0.1.11 - google.golang.org/protobuf v1.28.0 + google.golang.org/protobuf v1.28.1 ) diff --git a/go.sum b/go.sum index ba4c15b..ef572e8 100644 --- a/go.sum +++ b/go.sum @@ -153,8 +153,8 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= -google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From 3d887ac2bf870393f579da99d020bc8bb417cb65 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 28 Aug 2022 14:32:29 +0000 Subject: [PATCH 18/32] Bump golang.org/x/tools from 0.1.11 to 0.1.12 (#54) Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.1.11 to 0.1.12. - [Release notes](https://github.com/golang/tools/releases) - [Commits](https://github.com/golang/tools/compare/v0.1.11...v0.1.12) --- updated-dependencies: - dependency-name: golang.org/x/tools dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index 9186a1e..dfdc3aa 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,6 @@ go 1.16 require ( github.com/fatih/structtag v1.2.0 go.unistack.org/micro-proto/v3 v3.2.7 - golang.org/x/tools v0.1.11 + golang.org/x/tools v0.1.12 google.golang.org/protobuf v1.28.1 ) diff --git a/go.sum b/go.sum index ef572e8..3498d2b 100644 --- a/go.sum +++ b/go.sum @@ -66,7 +66,7 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= -github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.unistack.org/micro-proto/v3 v3.2.7 h1:zG6d69kHc+oij2lwQ3AfrCgdjiEVRG2A7TlsxjusWs4= go.unistack.org/micro-proto/v3 v3.2.7/go.mod h1:ZltVWNECD5yK+40+OCONzGw4OtmSdTpVi8/KFgo9dqM= @@ -90,14 +90,14 @@ golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -107,9 +107,11 @@ golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 h1:id054HUawV2/6IGm2IV8KZQjqtwAOo2CYlOToYqa0d0= -golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -121,8 +123,8 @@ golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3 golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.11 h1:loJ25fNOEhSXfHrpoGj91eCUThwdNX6u24rO1xnNteY= -golang.org/x/tools v0.1.11/go.mod h1:SgwaegtQh8clINPpECJMqnxLv9I09HLqnW3RMqW0CA4= +golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= From 94b653cbe8c5d0c56ccdd40b64ca3c26ba4867c7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 28 Aug 2022 14:38:50 +0000 Subject: [PATCH 19/32] Bump dependabot/fetch-metadata from 1.3.1 to 1.3.3 (#53) Bumps [dependabot/fetch-metadata](https://github.com/dependabot/fetch-metadata) from 1.3.1 to 1.3.3. - [Release notes](https://github.com/dependabot/fetch-metadata/releases) - [Commits](https://github.com/dependabot/fetch-metadata/compare/v1.3.1...v1.3.3) --- updated-dependencies: - dependency-name: dependabot/fetch-metadata dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/dependabot-automerge.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dependabot-automerge.yml b/.github/workflows/dependabot-automerge.yml index 7cf424b..1aa679d 100644 --- a/.github/workflows/dependabot-automerge.yml +++ b/.github/workflows/dependabot-automerge.yml @@ -15,7 +15,7 @@ jobs: steps: - name: metadata id: metadata - uses: dependabot/fetch-metadata@v1.3.1 + uses: dependabot/fetch-metadata@v1.3.3 with: github-token: "${{ secrets.TOKEN }}" - name: merge From 53ed35a106398c9208962d78fb1d8f5370880ae7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 4 Oct 2022 13:07:09 +0300 Subject: [PATCH 20/32] Bump dependabot/fetch-metadata from 1.3.3 to 1.3.4 (#56) Bumps [dependabot/fetch-metadata](https://github.com/dependabot/fetch-metadata) from 1.3.3 to 1.3.4. - [Release notes](https://github.com/dependabot/fetch-metadata/releases) - [Commits](https://github.com/dependabot/fetch-metadata/compare/v1.3.3...v1.3.4) --- updated-dependencies: - dependency-name: dependabot/fetch-metadata dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/dependabot-automerge.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dependabot-automerge.yml b/.github/workflows/dependabot-automerge.yml index 1aa679d..44105e8 100644 --- a/.github/workflows/dependabot-automerge.yml +++ b/.github/workflows/dependabot-automerge.yml @@ -15,7 +15,7 @@ jobs: steps: - name: metadata id: metadata - uses: dependabot/fetch-metadata@v1.3.3 + uses: dependabot/fetch-metadata@v1.3.4 with: github-token: "${{ secrets.TOKEN }}" - name: merge From bc4de7e63270f5c9a0bc4172aa93d7d84fe4e34b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 12 Nov 2022 18:20:28 +0300 Subject: [PATCH 21/32] Bump golang.org/x/tools from 0.1.12 to 0.3.0 (#61) Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.1.12 to 0.3.0. - [Release notes](https://github.com/golang/tools/releases) - [Commits](https://github.com/golang/tools/compare/v0.1.12...v0.3.0) --- updated-dependencies: - dependency-name: golang.org/x/tools dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index dfdc3aa..c179930 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,6 @@ go 1.16 require ( github.com/fatih/structtag v1.2.0 go.unistack.org/micro-proto/v3 v3.2.7 - golang.org/x/tools v0.1.12 + golang.org/x/tools v0.3.0 google.golang.org/protobuf v1.28.1 ) diff --git a/go.sum b/go.sum index 3498d2b..7acbb35 100644 --- a/go.sum +++ b/go.sum @@ -77,8 +77,9 @@ golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA= +golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -91,6 +92,7 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -98,6 +100,8 @@ golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -108,23 +112,27 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A= +golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.3.0 h1:SrNbZl6ECOS1qFzgTdQfWXZM9XBkiA6tkFrH9YSTPHM= +golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= From a3cf27d062a4502f3253a4d77f1114dc67131a9b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Nov 2022 07:04:10 +0300 Subject: [PATCH 22/32] Bump dependabot/fetch-metadata from 1.3.4 to 1.3.5 (#59) Bumps [dependabot/fetch-metadata](https://github.com/dependabot/fetch-metadata) from 1.3.4 to 1.3.5. - [Release notes](https://github.com/dependabot/fetch-metadata/releases) - [Commits](https://github.com/dependabot/fetch-metadata/compare/v1.3.4...v1.3.5) --- updated-dependencies: - dependency-name: dependabot/fetch-metadata dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/dependabot-automerge.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dependabot-automerge.yml b/.github/workflows/dependabot-automerge.yml index 44105e8..b8e71a1 100644 --- a/.github/workflows/dependabot-automerge.yml +++ b/.github/workflows/dependabot-automerge.yml @@ -15,7 +15,7 @@ jobs: steps: - name: metadata id: metadata - uses: dependabot/fetch-metadata@v1.3.4 + uses: dependabot/fetch-metadata@v1.3.5 with: github-token: "${{ secrets.TOKEN }}" - name: merge From e545d81720a668363512a39aed45e8e8e6b9b66a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Nov 2022 07:22:48 +0300 Subject: [PATCH 23/32] Bump golangci/golangci-lint-action from 3.2.0 to 3.3.1 (#60) Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 3.2.0 to 3.3.1. - [Release notes](https://github.com/golangci/golangci-lint-action/releases) - [Commits](https://github.com/golangci/golangci-lint-action/compare/v3.2.0...v3.3.1) --- updated-dependencies: - dependency-name: golangci/golangci-lint-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/build.yml | 2 +- .github/workflows/pr.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9c95dde..66e730f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,7 +34,7 @@ jobs: - name: checkout uses: actions/checkout@v3 - name: lint - uses: golangci/golangci-lint-action@v3.2.0 + uses: golangci/golangci-lint-action@v3.3.1 continue-on-error: true with: # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index b7f1bcf..14c16ea 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -34,7 +34,7 @@ jobs: - name: checkout uses: actions/checkout@v3 - name: lint - uses: golangci/golangci-lint-action@v3.2.0 + uses: golangci/golangci-lint-action@v3.3.1 continue-on-error: true with: # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. From 83b6567d3ea91c00dffedce0d5e3f80350d13527 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Tue, 15 Nov 2022 12:53:04 +0300 Subject: [PATCH 24/32] allow to catch response headers Signed-off-by: Vasiliy Tolstov --- example/example.proto | 2 +- go.mod | 4 +-- go.sum | 11 ++++--- main.go | 3 ++ micro.go | 20 ++++++++++-- rpc.go | 3 ++ util.go | 74 +++++++++++++++++++++++++++++++++++++++---- variables.go | 2 ++ 8 files changed, 103 insertions(+), 16 deletions(-) diff --git a/example/example.proto b/example/example.proto index 14fce3f..06ded90 100644 --- a/example/example.proto +++ b/example/example.proto @@ -26,7 +26,7 @@ service Example { } }; option (micro.api.http) = { post: "/v1/example/call/{name}"; body: "*"; }; - option (micro.api.micro_method) = { timeout: 5; }; + option (micro.api.micro_method) = { timeout: "5s"; }; }; }; diff --git a/go.mod b/go.mod index 03a3570..7653ee8 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.16 require ( github.com/fatih/structtag v1.2.0 - go.unistack.org/micro-proto/v3 v3.2.7 + go.unistack.org/micro-proto/v3 v3.3.1 golang.org/x/tools v0.1.10 - google.golang.org/protobuf v1.27.1 + google.golang.org/protobuf v1.28.1 ) diff --git a/go.sum b/go.sum index 1530b39..7af05fb 100644 --- a/go.sum +++ b/go.sum @@ -39,8 +39,8 @@ github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/gnostic v0.6.6 h1:MVSM2r2j9aRUvYNym66JGW96Ddd5MN4sTi59yktb6yk= -github.com/google/gnostic v0.6.6/go.mod h1:Nm8234We1lq6iB9OmlgNv3nH91XLLVZHCDayfA3xq+E= +github.com/google/gnostic v0.6.9 h1:ZK/5VhkoX835RikCHpSUJV9a+S3e1zLh59YnyWeBW+0= +github.com/google/gnostic v0.6.9/go.mod h1:Nm8234We1lq6iB9OmlgNv3nH91XLLVZHCDayfA3xq+E= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -68,8 +68,8 @@ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1: github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= -go.unistack.org/micro-proto/v3 v3.2.7 h1:zG6d69kHc+oij2lwQ3AfrCgdjiEVRG2A7TlsxjusWs4= -go.unistack.org/micro-proto/v3 v3.2.7/go.mod h1:ZltVWNECD5yK+40+OCONzGw4OtmSdTpVi8/KFgo9dqM= +go.unistack.org/micro-proto/v3 v3.3.1 h1:nQ0MtWvP2G3QrpOgawVOPhpZZYkq6umTGDqs8FxJYIo= +go.unistack.org/micro-proto/v3 v3.3.1/go.mod h1:cwRyv8uInM2I7EbU7O8Fx2Ls3N90Uw9UCCcq4olOdfE= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= @@ -153,8 +153,9 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/main.go b/main.go index 9b18889..c816eae 100644 --- a/main.go +++ b/main.go @@ -18,6 +18,7 @@ var ( flagComponents = flagSet.String("components", "micro|rpc|http|client|server|openapiv3", "specify components to generate") flagTagPath = flagSet.String("tag_path", "", "tag rewriting dir") flagOpenapiFile = flagSet.String("openapi_file", "apidocs.swagger.json", "openapi file name") + flagReflection = flagSet.Bool("reflection", false, "enable server reflection support") flagHelp = flagSet.Bool("help", false, "display help message") ) @@ -45,6 +46,7 @@ type Generator struct { fieldaligment bool tagPath string openapiFile string + reflection bool plugin *protogen.Plugin } @@ -58,6 +60,7 @@ func (g *Generator) Generate(plugin *protogen.Plugin) error { g.fieldaligment = *flagFieldaligment g.tagPath = *flagTagPath g.openapiFile = *flagOpenapiFile + g.reflection = *flagReflection plugin.SupportedFeatures = uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL) var genClient bool diff --git a/micro.go b/micro.go index c99d60c..dd82fb3 100644 --- a/micro.go +++ b/micro.go @@ -1,6 +1,8 @@ package main import ( + "fmt" + "google.golang.org/protobuf/compiler/protogen" ) @@ -22,8 +24,10 @@ func (g *Generator) microGenerate(component string, plugin *protogen.Plugin, gen gfile := plugin.NewGeneratedFile(gname, path) gfile.P("// Code generated by protoc-gen-go-micro. DO NOT EDIT.") - gfile.P("// protoc-gen-go-micro version: " + versionComment) - gfile.P("// source: ", file.Proto.GetName()) + gfile.P("// versions:") + gfile.P("// - protoc-gen-go-micro " + versionComment) + gfile.P("// - protoc ", protocVersion(plugin)) + gfile.P("// source: ", file.Desc.Path()) gfile.P() gfile.P("package ", file.GoPackageName) gfile.P() @@ -50,3 +54,15 @@ func (g *Generator) microGenerate(component string, plugin *protogen.Plugin, gen return nil } + +func protocVersion(plugin *protogen.Plugin) string { + v := plugin.Request.GetCompilerVersion() + if v == nil { + return "(unknown)" + } + var suffix string + if s := v.GetSuffix(); s != "" { + suffix = "-" + s + } + return fmt.Sprintf("v%d.%d.%d%s", v.GetMajor(), v.GetMinor(), v.GetPatch(), suffix) +} diff --git a/rpc.go b/rpc.go index ab0bedb..ee36775 100644 --- a/rpc.go +++ b/rpc.go @@ -45,6 +45,9 @@ func (g *Generator) rpcGenerate(component string, plugin *protogen.Plugin, genCl g.generateServiceServerMethods(gfile, service) g.generateServiceRegister(gfile, service) } + if component == "grpc" && g.reflection { + g.generateServiceDesc(gfile, file, service) + } } } diff --git a/util.go b/util.go index be1a34b..d913de7 100644 --- a/util.go +++ b/util.go @@ -4,7 +4,9 @@ import ( "fmt" "log" "net/http" + "strconv" "strings" + "time" api_options "go.unistack.org/micro-proto/v3/api" v2 "go.unistack.org/micro-proto/v3/openapiv2" @@ -213,8 +215,14 @@ func (g *Generator) generateServiceClientMethods(gfile *protogen.GeneratedFile, } if rule, ok := getMicroApiMethod(method); ok { - if rule.Timeout > 0 { - gfile.P("opts = append(opts, ", microClientPackage.Ident("WithRequestTimeout"), "(", timePackage.Ident("Second"), "*", rule.Timeout, "))") + if rule.Timeout != "" { + td, err := time.ParseDuration(rule.Timeout) + if err != nil { + log.Printf("parse duration error %s\n", err.Error()) + } else { + gfile.P("td := uint64(", td.Nanoseconds(), ")") + gfile.P("opts = append(opts, ", microClientPackage.Ident("WithRequestTimeout"), "(", timePackage.Ident("Nanosecond"), "* ", "td", "))") + } } } @@ -287,6 +295,11 @@ func (g *Generator) generateServiceClientMethods(gfile *protogen.GeneratedFile, gfile.P() if method.Desc.IsStreamingClient() { + gfile.P("func (s *", unexport(serviceName), "Client", method.GoName, ") Header() ", microMetadataPackage.Ident("Metadata"), "{") + gfile.P("return s.stream.Response().Header()") + gfile.P("}") + gfile.P() + gfile.P("func (s *", unexport(serviceName), "Client", method.GoName, ") Send(msg *", gfile.QualifiedGoIdent(method.Input.GoIdent), ") error {") gfile.P("return s.stream.Send(msg)") gfile.P("}") @@ -319,10 +332,16 @@ func (g *Generator) generateServiceServerMethods(gfile *protogen.GeneratedFile, for _, method := range service.Methods { generateServerFuncSignature(gfile, serviceName, method, true) if rule, ok := getMicroApiMethod(method); ok { - if rule.Timeout > 0 { - gfile.P("var cancel ", contextPackage.Ident("CancelFunc")) - gfile.P("ctx, cancel = ", contextPackage.Ident("WithTimeout"), "(ctx, ", timePackage.Ident("Second"), "*", rule.Timeout, ")") - gfile.P("defer cancel()") + if rule.Timeout != "" { + td, err := time.ParseDuration(rule.Timeout) + if err != nil { + log.Printf("parse duration error %s\n", err.Error()) + } else { + gfile.P("var cancel ", contextPackage.Ident("CancelFunc")) + gfile.P("td := ", timePackage.Ident("Duration"), "(", td.Nanoseconds(), ")") + gfile.P("ctx, cancel = ", contextPackage.Ident("WithTimeout"), "(ctx, ", "td", ")") + gfile.P("defer cancel()") + } } } if method.Desc.IsStreamingClient() || method.Desc.IsStreamingServer() { @@ -598,6 +617,7 @@ func (g *Generator) generateServiceClientStreamInterface(gfile *protogen.Generat } gfile.P("Close() error") if method.Desc.IsStreamingClient() { + gfile.P("Header() ", microMetadataPackage.Ident("Metadata")) gfile.P("Send(msg *", gfile.QualifiedGoIdent(method.Input.GoIdent), ") error") } if method.Desc.IsStreamingServer() { @@ -798,3 +818,45 @@ func getGoIdentByMessage(messages []*protogen.Message, msg string) (protogen.GoI } return protogen.GoIdent{}, fmt.Errorf("not found") } + +func (g *Generator) generateServiceDesc(gfile *protogen.GeneratedFile, file *protogen.File, service *protogen.Service) { + serviceName := service.GoName + + gfile.P("// ", serviceName, "_ServiceDesc", " is the ", grpcPackage.Ident("ServiceDesc"), " for ", serviceName, " service.") + gfile.P("// It's only intended for direct use with ", grpcPackage.Ident("RegisterService"), ",") + gfile.P("// and not to be introspected or modified (even as a copy)") + gfile.P("var ", serviceName, "_ServiceDesc", " = ", grpcPackage.Ident("ServiceDesc"), " {") + gfile.P("ServiceName: ", strconv.Quote(string(service.Desc.FullName())), ",") + gfile.P("HandlerType: (*", serviceName, "Server)(nil),") + gfile.P("Methods: []", grpcPackage.Ident("MethodDesc"), "{") + for _, method := range service.Methods { + if method.Desc.IsStreamingClient() || method.Desc.IsStreamingServer() { + continue + } + gfile.P("{") + gfile.P("MethodName: ", strconv.Quote(string(method.Desc.Name())), ",") + gfile.P("Handler: ", method.GoName, ",") + gfile.P("},") + } + gfile.P("},") + gfile.P("Streams: []", grpcPackage.Ident("StreamDesc"), "{") + for _, method := range service.Methods { + if !method.Desc.IsStreamingClient() && !method.Desc.IsStreamingServer() { + continue + } + gfile.P("{") + gfile.P("StreamName: ", strconv.Quote(string(method.Desc.Name())), ",") + gfile.P("Handler: ", method.GoName, ",") + if method.Desc.IsStreamingServer() { + gfile.P("ServerStreams: true,") + } + if method.Desc.IsStreamingClient() { + gfile.P("ClientStreams: true,") + } + gfile.P("},") + } + gfile.P("},") + gfile.P("Metadata: \"", file.Desc.Path(), "\",") + gfile.P("}") + gfile.P() +} diff --git a/variables.go b/variables.go index 0cf425b..64fa863 100644 --- a/variables.go +++ b/variables.go @@ -12,12 +12,14 @@ var ( chiPackage = protogen.GoImportPath("github.com/go-chi/chi/v5") chiMiddlewarePackage = protogen.GoImportPath("github.com/go-chi/chi/v5/middleware") microApiPackage = protogen.GoImportPath("go.unistack.org/micro/v3/api") + microMetadataPackage = protogen.GoImportPath("go.unistack.org/micro/v3/metadata") microClientPackage = protogen.GoImportPath("go.unistack.org/micro/v3/client") microServerPackage = protogen.GoImportPath("go.unistack.org/micro/v3/server") microClientHttpPackage = protogen.GoImportPath("go.unistack.org/micro-client-http/v3") microServerHttpPackage = protogen.GoImportPath("go.unistack.org/micro-server-http/v3") microCodecPackage = protogen.GoImportPath("go.unistack.org/micro/v3/codec") microErrorsPackage = protogen.GoImportPath("go.unistack.org/micro/v3/errors") + grpcPackage = protogen.GoImportPath("google.golang.org/grpc") timePackage = protogen.GoImportPath("time") deprecationComment = "// Deprecated: Do not use." versionComment = "v3.5.3" From da5d5191dbb2d6f7243ce92567dbee267ea5d602 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 28 Nov 2022 16:26:11 +0300 Subject: [PATCH 25/32] Bump hmarr/auto-approve-action from 2 to 3 (#64) Bumps [hmarr/auto-approve-action](https://github.com/hmarr/auto-approve-action) from 2 to 3. - [Release notes](https://github.com/hmarr/auto-approve-action/releases) - [Commits](https://github.com/hmarr/auto-approve-action/compare/v2...v3) --- updated-dependencies: - dependency-name: hmarr/auto-approve-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/autoapprove.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/autoapprove.yml b/.github/workflows/autoapprove.yml index ebe28c9..5bf5d9f 100644 --- a/.github/workflows/autoapprove.yml +++ b/.github/workflows/autoapprove.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest steps: - name: approve - uses: hmarr/auto-approve-action@v2 + uses: hmarr/auto-approve-action@v3 if: github.actor == 'vtolstov' || github.actor == 'dependabot[bot]' id: approve with: From b35607a63e6ef1c27482a888d0a19af563fdc565 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Jan 2023 22:29:50 +0300 Subject: [PATCH 26/32] Bump golangci/golangci-lint-action from 3.3.1 to 3.4.0 (#67) Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 3.3.1 to 3.4.0. - [Release notes](https://github.com/golangci/golangci-lint-action/releases) - [Commits](https://github.com/golangci/golangci-lint-action/compare/v3.3.1...v3.4.0) --- updated-dependencies: - dependency-name: golangci/golangci-lint-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/build.yml | 2 +- .github/workflows/pr.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 66e730f..9603352 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,7 +34,7 @@ jobs: - name: checkout uses: actions/checkout@v3 - name: lint - uses: golangci/golangci-lint-action@v3.3.1 + uses: golangci/golangci-lint-action@v3.4.0 continue-on-error: true with: # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 14c16ea..f313ebe 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -34,7 +34,7 @@ jobs: - name: checkout uses: actions/checkout@v3 - name: lint - uses: golangci/golangci-lint-action@v3.3.1 + uses: golangci/golangci-lint-action@v3.4.0 continue-on-error: true with: # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. From 821949fed3d9101de4492d56ed344f76d019acc8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 31 Jan 2023 06:49:26 +0300 Subject: [PATCH 27/32] Bump dependabot/fetch-metadata from 1.3.5 to 1.3.6 (#68) Bumps [dependabot/fetch-metadata](https://github.com/dependabot/fetch-metadata) from 1.3.5 to 1.3.6. - [Release notes](https://github.com/dependabot/fetch-metadata/releases) - [Commits](https://github.com/dependabot/fetch-metadata/compare/v1.3.5...v1.3.6) --- updated-dependencies: - dependency-name: dependabot/fetch-metadata dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/dependabot-automerge.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dependabot-automerge.yml b/.github/workflows/dependabot-automerge.yml index b8e71a1..f41c1c0 100644 --- a/.github/workflows/dependabot-automerge.yml +++ b/.github/workflows/dependabot-automerge.yml @@ -15,7 +15,7 @@ jobs: steps: - name: metadata id: metadata - uses: dependabot/fetch-metadata@v1.3.5 + uses: dependabot/fetch-metadata@v1.3.6 with: github-token: "${{ secrets.TOKEN }}" - name: merge From 5c4a300a4f3ac5b7ea528f0ddb1e19a7f25abd59 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 31 Jan 2023 06:57:40 +0300 Subject: [PATCH 28/32] Bump golang.org/x/tools from 0.3.0 to 0.5.0 (#66) Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.3.0 to 0.5.0. - [Release notes](https://github.com/golang/tools/releases) - [Commits](https://github.com/golang/tools/compare/v0.3.0...v0.5.0) --- updated-dependencies: - dependency-name: golang.org/x/tools dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index c3e1b20..3ff7f66 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,6 @@ go 1.16 require ( github.com/fatih/structtag v1.2.0 go.unistack.org/micro-proto/v3 v3.3.1 - golang.org/x/tools v0.3.0 + golang.org/x/tools v0.5.0 google.golang.org/protobuf v1.28.1 ) diff --git a/go.sum b/go.sum index 2cbff43..bea59a2 100644 --- a/go.sum +++ b/go.sum @@ -92,7 +92,7 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= +golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -113,17 +113,17 @@ golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A= -golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18= +golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= +golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= @@ -131,8 +131,8 @@ golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3 golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.3.0 h1:SrNbZl6ECOS1qFzgTdQfWXZM9XBkiA6tkFrH9YSTPHM= -golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k= +golang.org/x/tools v0.5.0 h1:+bSpV5HIeWkuvgaMfI3UmKRThoTA5ODJTUd8T17NO+4= +golang.org/x/tools v0.5.0/go.mod h1:N+Kgy78s5I24c24dU8OfWNEotWjutIs8SnJvn5IDq+k= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= From 16a4ceaf26282ac6cf1a0ac771046bed6339b253 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Feb 2023 16:03:53 +0000 Subject: [PATCH 29/32] Bump golang.org/x/tools from 0.5.0 to 0.6.0 Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.5.0 to 0.6.0. - [Release notes](https://github.com/golang/tools/releases) - [Commits](https://github.com/golang/tools/compare/v0.5.0...v0.6.0) --- updated-dependencies: - dependency-name: golang.org/x/tools dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/go.mod b/go.mod index 3ff7f66..77e54ea 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,6 @@ go 1.16 require ( github.com/fatih/structtag v1.2.0 go.unistack.org/micro-proto/v3 v3.3.1 - golang.org/x/tools v0.5.0 + golang.org/x/tools v0.6.0 google.golang.org/protobuf v1.28.1 ) diff --git a/go.sum b/go.sum index bea59a2..40890a0 100644 --- a/go.sum +++ b/go.sum @@ -78,8 +78,8 @@ golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTk golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA= -golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -92,7 +92,7 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -113,17 +113,17 @@ golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18= -golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= @@ -131,8 +131,8 @@ golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3 golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.5.0 h1:+bSpV5HIeWkuvgaMfI3UmKRThoTA5ODJTUd8T17NO+4= -golang.org/x/tools v0.5.0/go.mod h1:N+Kgy78s5I24c24dU8OfWNEotWjutIs8SnJvn5IDq+k= +golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= From 71ad836e068b8c8ccdbef2e7611c6dde819c91d4 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Tue, 14 Feb 2023 00:22:35 +0300 Subject: [PATCH 30/32] micro api cleanup Signed-off-by: Vasiliy Tolstov --- util.go | 77 ++++++++++++++++++++++++++++++++------------------------- 1 file changed, 43 insertions(+), 34 deletions(-) diff --git a/util.go b/util.go index d913de7..6f04368 100644 --- a/util.go +++ b/util.go @@ -220,8 +220,8 @@ func (g *Generator) generateServiceClientMethods(gfile *protogen.GeneratedFile, if err != nil { log.Printf("parse duration error %s\n", err.Error()) } else { - gfile.P("td := uint64(", td.Nanoseconds(), ")") - gfile.P("opts = append(opts, ", microClientPackage.Ident("WithRequestTimeout"), "(", timePackage.Ident("Nanosecond"), "* ", "td", "))") + gfile.P("td := ", timePackage.Ident("Duration"), "(", td.Nanoseconds(), ")") + gfile.P("opts = append(opts, ", microClientPackage.Ident("WithRequestTimeout"), "(td))") } } } @@ -481,18 +481,49 @@ func (g *Generator) generateServiceRegister(gfile *protogen.GeneratedFile, servi serviceName := service.GoName gfile.P("func Register", serviceName, "Server(s ", microServerPackage.Ident("Server"), ", sh ", serviceName, "Server, opts ...", microServerPackage.Ident("HandlerOption"), ") error {") gfile.P("type ", unexport(serviceName), " interface {") + var endpoints []*api_options.HttpRule for _, method := range service.Methods { generateServerSignature(gfile, serviceName, method, true) + if proto.HasExtension(method.Desc.Options(), api_options.E_Http) { + if ep, _ := generateEndpoints(method); ep != nil { + endpoints = append(endpoints, ep...) + } + } } + gfile.P("}") gfile.P("type ", serviceName, " struct {") gfile.P(unexport(serviceName)) gfile.P("}") gfile.P("h := &", unexport(serviceName), "Server{sh}") gfile.P("var nopts []", microServerPackage.Ident("HandlerOption")) - gfile.P("for _, endpoint := range ", serviceName, "Endpoints {") - gfile.P("nopts = append(nopts, ", microApiPackage.Ident("WithEndpoint"), "(&endpoint))") - gfile.P("}") + for _, method := range service.Methods { + if proto.HasExtension(method.Desc.Options(), api_options.E_Http) { + if endpoints, streaming := generateEndpoints(method); endpoints != nil { + gfile.P("nopts = append(nopts, ", microServerHttpPackage.Ident("HandlerMetadata"), "(", "map[string]map[string]string{") + for _, ep := range endpoints { + path, method, body := getEndpoint(ep) + gfile.P(`"`, path, `":map[string]string{`) + if vmethod, ok := httpMethodMap[method]; ok { + gfile.P(`"Method": `, httpPackage.Ident(vmethod), `,`) + } else { + gfile.P(`"Method": "`, method, `",`) + } + if body != "" { + gfile.P(`"Body": "`, body, `",`) + } + if streaming { + gfile.P(`"Stream": "true",`) + } else { + gfile.P(`"Stream": "false",`) + } + gfile.P(`},`) + } + gfile.P("}", "))") + } + } + } + gfile.P("return s.Handle(s.NewHandler(&", serviceName, "{h}, append(nopts, opts...)...))") gfile.P("}") } @@ -655,35 +686,6 @@ func (g *Generator) generateServiceServerStreamInterface(gfile *protogen.Generat } } -func (g *Generator) generateServiceEndpoints(gfile *protogen.GeneratedFile, service *protogen.Service) { - serviceName := service.GoName - gfile.P("var (") - gfile.P(serviceName, "Name", "=", `"`, serviceName, `"`) - gfile.P() - gfile.P(serviceName, "Endpoints", "=", "[]", microApiPackage.Ident("Endpoint"), "{") - for _, method := range service.Methods { - if method.Desc.Options() == nil { - continue - } - if proto.HasExtension(method.Desc.Options(), api_options.E_Http) { - endpoints, streaming := generateEndpoints(method) - for _, endpoint := range endpoints { - gfile.P("{") - generateEndpoint(gfile, serviceName, method.GoName, endpoint, streaming) - gfile.P("},") - } - } - } - gfile.P("}") - gfile.P(")") - gfile.P() - - gfile.P("func New", serviceName, "Endpoints()", "[]", microApiPackage.Ident("Endpoint"), "{") - gfile.P("return ", serviceName, "Endpoints") - gfile.P("}") - gfile.P() -} - func generateEndpoints(method *protogen.Method) ([]*api_options.HttpRule, bool) { if method.Desc.Options() == nil { return nil, false @@ -860,3 +862,10 @@ func (g *Generator) generateServiceDesc(gfile *protogen.GeneratedFile, file *pro gfile.P("}") gfile.P() } + +func (g *Generator) generateServiceEndpoints(gfile *protogen.GeneratedFile, service *protogen.Service) { + serviceName := service.GoName + gfile.P("var (") + gfile.P(serviceName, "Name", "=", `"`, serviceName, `"`) + gfile.P(")") +} From 388a58d998e740fd78bb3bebb04dff5c1e639167 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Wed, 22 Feb 2023 00:05:54 +0300 Subject: [PATCH 31/32] replace map Signed-off-by: Vasiliy Tolstov --- chi.go | 17 +++++--------- gorilla.go | 15 +++++-------- http.go | 1 - micro.go | 3 ++- rpc.go | 2 +- util.go | 63 ++++++++++++++++++++++++---------------------------- variables.go | 3 +-- 7 files changed, 45 insertions(+), 59 deletions(-) diff --git a/chi.go b/chi.go index b0b96a6..464a135 100644 --- a/chi.go +++ b/chi.go @@ -4,9 +4,7 @@ import ( "google.golang.org/protobuf/compiler/protogen" ) -var ( - chiPackageFiles map[protogen.GoPackageName]struct{} -) +var chiPackageFiles map[protogen.GoPackageName]struct{} func (g *Generator) chiGenerate(component string, plugin *protogen.Plugin) error { chiPackageFiles = make(map[protogen.GoPackageName]struct{}) @@ -43,7 +41,6 @@ func (g *Generator) chiGenerate(component string, plugin *protogen.Plugin) error gfile.Import(stringsPackage) gfile.Import(chiPackage) gfile.Import(chiMiddlewarePackage) - gfile.Import(microApiPackage) gfile.P("type routeKey struct{}") @@ -52,17 +49,17 @@ func (g *Generator) chiGenerate(component string, plugin *protogen.Plugin) error gfile.P("return value, ok") gfile.P("}") gfile.P() - gfile.P("func RegisterHandlers(r *", chiPackage.Ident("Mux"), ", h interface{}, eps []*", microApiPackage.Ident("Endpoint"), ") error {") + gfile.P("func RegisterHandlers(r *", chiPackage.Ident("Mux"), ", h interface{}, eps []", microServerHttpPackage.Ident("EndpointMetadata"), ") error {") gfile.P("v := ", reflectPackage.Ident("ValueOf"), "(h)") gfile.P("if v.NumMethod() < 1 {") gfile.P(`return `, fmtPackage.Ident("Errorf"), `("handler has no methods: %T", h)`) gfile.P("}") gfile.P("for _, ep := range eps {") gfile.P(`idx := `, stringsPackage.Ident("Index"), `(ep.Name, ".")`) - gfile.P("if idx < 1 || len(ep.Name) <= idx {") - gfile.P(`return `, fmtPackage.Ident("Errorf"), `("invalid `, microApiPackage.Ident("Endpoint"), ` name: %s", ep.Name)`) + gfile.P(`if idx < 1 || len(ep.Name) <= idx {`) + gfile.P(`return `, fmtPackage.Ident("Errorf"), `("invalid endpoint name: %s", ep.Name)`) gfile.P("}") - gfile.P("name := ep.Name[idx+1:]") + gfile.P(`name := ep.Name[idx+1:]`) gfile.P("m := v.MethodByName(name)") gfile.P("if !m.IsValid() || m.IsZero() {") gfile.P(`return `, fmtPackage.Ident("Errorf"), `("invalid handler, method %s not found", name)`) @@ -71,9 +68,7 @@ func (g *Generator) chiGenerate(component string, plugin *protogen.Plugin) error gfile.P("if !ok {") gfile.P(`return `, fmtPackage.Ident("Errorf"), `("invalid handler: %#+v", m.Interface())`) gfile.P("}") - gfile.P("for _, method := range ep.Method {") - gfile.P("r.With(", chiMiddlewarePackage.Ident("WithValue"), "(routeKey{}, ep.Name)).MethodFunc(method, ep.Path[0], rh)") - gfile.P("}") + gfile.P("r.With(", chiMiddlewarePackage.Ident("WithValue"), `(routeKey{}, ep.Name)).MethodFunc(ep.Method, ep.Path, rh)`) gfile.P("}") gfile.P("return nil") gfile.P("}") diff --git a/gorilla.go b/gorilla.go index 6147cdd..ff7b2dc 100644 --- a/gorilla.go +++ b/gorilla.go @@ -4,9 +4,7 @@ import ( "google.golang.org/protobuf/compiler/protogen" ) -var ( - gorillaPackageFiles map[protogen.GoPackageName]struct{} -) +var gorillaPackageFiles map[protogen.GoPackageName]struct{} func (g *Generator) gorillaGenerate(component string, plugin *protogen.Plugin) error { gorillaPackageFiles = make(map[protogen.GoPackageName]struct{}) @@ -40,20 +38,19 @@ func (g *Generator) gorillaGenerate(component string, plugin *protogen.Plugin) e gfile.Import(httpPackage) gfile.Import(reflectPackage) gfile.Import(stringsPackage) - gfile.Import(microApiPackage) gfile.Import(gorillaMuxPackage) - gfile.P("func RegisterHandlers(r *", gorillaMuxPackage.Ident("Router"), ", h interface{}, eps []*", microApiPackage.Ident("Endpoint"), ") error {") + gfile.P("func RegisterHandlers(r *", gorillaMuxPackage.Ident("Router"), ", h interface{}, eps []", microServerHttpPackage.Ident("EndpointMetadata"), ") error {") gfile.P("v := ", reflectPackage.Ident("ValueOf"), "(h)") gfile.P("if v.NumMethod() < 1 {") gfile.P(`return `, fmtPackage.Ident("Errorf"), `("handler has no methods: %T", h)`) gfile.P("}") gfile.P("for _, ep := range eps {") gfile.P(`idx := `, stringsPackage.Ident("Index"), `(ep.Name, ".")`) - gfile.P("if idx < 1 || len(ep.Name) <= idx {") - gfile.P(`return `, fmtPackage.Ident("Errorf"), `("invalid `, microApiPackage.Ident("Endpoint"), ` name: %s", ep.Name)`) + gfile.P(`if idx < 1 || len(ep.Name) <= idx {`) + gfile.P(`return `, fmtPackage.Ident("Errorf"), `("invalid endpoint name: %s", ep.Name)`) gfile.P("}") - gfile.P("name := ep.Name[idx+1:]") + gfile.P(`name := ep.Name[idx+1:]`) gfile.P("m := v.MethodByName(name)") gfile.P("if !m.IsValid() || m.IsZero() {") gfile.P(`return `, fmtPackage.Ident("Errorf"), `("invalid handler, method %s not found", name)`) @@ -62,7 +59,7 @@ func (g *Generator) gorillaGenerate(component string, plugin *protogen.Plugin) e gfile.P("if !ok {") gfile.P(`return `, fmtPackage.Ident("Errorf"), `("invalid handler: %#+v", m.Interface())`) gfile.P("}") - gfile.P("r.HandleFunc(ep.Path[0], rh).Methods(ep.Method...).Name(ep.Name)") + gfile.P(`r.HandleFunc(ep.Path, rh).Methods(ep.Method).Name(ep.Name)`) gfile.P("}") gfile.P("return nil") gfile.P("}") diff --git a/http.go b/http.go index 8fc04ab..e854cf1 100644 --- a/http.go +++ b/http.go @@ -28,7 +28,6 @@ func (g *Generator) httpGenerate(component string, plugin *protogen.Plugin, genC gfile.P() gfile.Import(contextPackage) - gfile.Import(microApiPackage) if genClient { gfile.Import(microClientPackage) diff --git a/micro.go b/micro.go index dd82fb3..6c33b23 100644 --- a/micro.go +++ b/micro.go @@ -33,12 +33,13 @@ func (g *Generator) microGenerate(component string, plugin *protogen.Plugin, gen gfile.P() gfile.Import(contextPackage) - gfile.Import(microApiPackage) + if genClient { gfile.Import(microClientPackage) } // generate services for _, service := range file.Services { + g.generateServiceName(gfile, service) g.generateServiceEndpoints(gfile, service) if genClient { g.generateServiceClientInterface(gfile, service) diff --git a/rpc.go b/rpc.go index ee36775..049ecac 100644 --- a/rpc.go +++ b/rpc.go @@ -28,7 +28,7 @@ func (g *Generator) rpcGenerate(component string, plugin *protogen.Plugin, genCl gfile.P() gfile.Import(contextPackage) - gfile.Import(microApiPackage) + if genClient { gfile.Import(microClientPackage) } diff --git a/util.go b/util.go index 6f04368..be68e57 100644 --- a/util.go +++ b/util.go @@ -481,48 +481,16 @@ func (g *Generator) generateServiceRegister(gfile *protogen.GeneratedFile, servi serviceName := service.GoName gfile.P("func Register", serviceName, "Server(s ", microServerPackage.Ident("Server"), ", sh ", serviceName, "Server, opts ...", microServerPackage.Ident("HandlerOption"), ") error {") gfile.P("type ", unexport(serviceName), " interface {") - var endpoints []*api_options.HttpRule for _, method := range service.Methods { generateServerSignature(gfile, serviceName, method, true) - if proto.HasExtension(method.Desc.Options(), api_options.E_Http) { - if ep, _ := generateEndpoints(method); ep != nil { - endpoints = append(endpoints, ep...) - } - } } - gfile.P("}") gfile.P("type ", serviceName, " struct {") gfile.P(unexport(serviceName)) gfile.P("}") gfile.P("h := &", unexport(serviceName), "Server{sh}") gfile.P("var nopts []", microServerPackage.Ident("HandlerOption")) - for _, method := range service.Methods { - if proto.HasExtension(method.Desc.Options(), api_options.E_Http) { - if endpoints, streaming := generateEndpoints(method); endpoints != nil { - gfile.P("nopts = append(nopts, ", microServerHttpPackage.Ident("HandlerMetadata"), "(", "map[string]map[string]string{") - for _, ep := range endpoints { - path, method, body := getEndpoint(ep) - gfile.P(`"`, path, `":map[string]string{`) - if vmethod, ok := httpMethodMap[method]; ok { - gfile.P(`"Method": `, httpPackage.Ident(vmethod), `,`) - } else { - gfile.P(`"Method": "`, method, `",`) - } - if body != "" { - gfile.P(`"Body": "`, body, `",`) - } - if streaming { - gfile.P(`"Stream": "true",`) - } else { - gfile.P(`"Stream": "false",`) - } - gfile.P(`},`) - } - gfile.P("}", "))") - } - } - } + gfile.P("nopts = append(nopts, ", microServerHttpPackage.Ident("HandlerEndpoints"), "(", serviceName, "ServerEndpoints))") gfile.P("return s.Handle(s.NewHandler(&", serviceName, "{h}, append(nopts, opts...)...))") gfile.P("}") @@ -863,9 +831,36 @@ func (g *Generator) generateServiceDesc(gfile *protogen.GeneratedFile, file *pro gfile.P() } -func (g *Generator) generateServiceEndpoints(gfile *protogen.GeneratedFile, service *protogen.Service) { +func (g *Generator) generateServiceName(gfile *protogen.GeneratedFile, service *protogen.Service) { serviceName := service.GoName gfile.P("var (") gfile.P(serviceName, "Name", "=", `"`, serviceName, `"`) gfile.P(")") } + +func (g *Generator) generateServiceEndpoints(gfile *protogen.GeneratedFile, service *protogen.Service) { + serviceName := service.GoName + + gfile.P("var (") + gfile.P(serviceName, "ServerEndpoints = []", microServerHttpPackage.Ident("EndpointMetadata"), "{") + + for _, method := range service.Methods { + if proto.HasExtension(method.Desc.Options(), api_options.E_Http) { + if endpoints, streaming := generateEndpoints(method); endpoints != nil { + for _, ep := range endpoints { + epath, emethod, ebody := getEndpoint(ep) + gfile.P("{") + gfile.P(`Name: "`, serviceName+"."+method.GoName, `",`) + gfile.P(`Path: "`, epath, `",`) + gfile.P(`Method: "`, emethod, `",`) + gfile.P(`Body: "`, ebody, `",`) + gfile.P(`Stream: `, streaming, `,`) + gfile.P("},") + } + } + } + } + + gfile.P("}") + gfile.P(")") +} diff --git a/variables.go b/variables.go index 64fa863..6fc5e31 100644 --- a/variables.go +++ b/variables.go @@ -11,7 +11,6 @@ var ( gorillaMuxPackage = protogen.GoImportPath("github.com/gorilla/mux") chiPackage = protogen.GoImportPath("github.com/go-chi/chi/v5") chiMiddlewarePackage = protogen.GoImportPath("github.com/go-chi/chi/v5/middleware") - microApiPackage = protogen.GoImportPath("go.unistack.org/micro/v3/api") microMetadataPackage = protogen.GoImportPath("go.unistack.org/micro/v3/metadata") microClientPackage = protogen.GoImportPath("go.unistack.org/micro/v3/client") microServerPackage = protogen.GoImportPath("go.unistack.org/micro/v3/server") @@ -22,5 +21,5 @@ var ( grpcPackage = protogen.GoImportPath("google.golang.org/grpc") timePackage = protogen.GoImportPath("time") deprecationComment = "// Deprecated: Do not use." - versionComment = "v3.5.3" + versionComment = "v3.10.2" ) From dbaa0089b654c30bf64b4317c0030bac8e8538f7 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Wed, 15 Mar 2023 01:10:59 +0300 Subject: [PATCH 32/32] generate endpoint metadata only for http server Signed-off-by: Vasiliy Tolstov --- http.go | 2 +- rpc.go | 2 +- util.go | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/http.go b/http.go index e854cf1..a9c0335 100644 --- a/http.go +++ b/http.go @@ -45,7 +45,7 @@ func (g *Generator) httpGenerate(component string, plugin *protogen.Plugin, genC if genServer { generateServiceServer(gfile, service) g.generateServiceServerMethods(gfile, service) - g.generateServiceRegister(gfile, service) + g.generateServiceRegister(gfile, service, component) } } } diff --git a/rpc.go b/rpc.go index 049ecac..2160468 100644 --- a/rpc.go +++ b/rpc.go @@ -43,7 +43,7 @@ func (g *Generator) rpcGenerate(component string, plugin *protogen.Plugin, genCl if genServer { generateServiceServer(gfile, service) g.generateServiceServerMethods(gfile, service) - g.generateServiceRegister(gfile, service) + g.generateServiceRegister(gfile, service, component) } if component == "grpc" && g.reflection { g.generateServiceDesc(gfile, file, service) diff --git a/util.go b/util.go index be68e57..645b7da 100644 --- a/util.go +++ b/util.go @@ -477,7 +477,7 @@ func (g *Generator) generateServiceServerMethods(gfile *protogen.GeneratedFile, } } -func (g *Generator) generateServiceRegister(gfile *protogen.GeneratedFile, service *protogen.Service) { +func (g *Generator) generateServiceRegister(gfile *protogen.GeneratedFile, service *protogen.Service, component string) { serviceName := service.GoName gfile.P("func Register", serviceName, "Server(s ", microServerPackage.Ident("Server"), ", sh ", serviceName, "Server, opts ...", microServerPackage.Ident("HandlerOption"), ") error {") gfile.P("type ", unexport(serviceName), " interface {") @@ -490,8 +490,9 @@ func (g *Generator) generateServiceRegister(gfile *protogen.GeneratedFile, servi gfile.P("}") gfile.P("h := &", unexport(serviceName), "Server{sh}") gfile.P("var nopts []", microServerPackage.Ident("HandlerOption")) - gfile.P("nopts = append(nopts, ", microServerHttpPackage.Ident("HandlerEndpoints"), "(", serviceName, "ServerEndpoints))") - + if component == "http" { + gfile.P("nopts = append(nopts, ", microServerHttpPackage.Ident("HandlerEndpoints"), "(", serviceName, "ServerEndpoints))") + } gfile.P("return s.Handle(s.NewHandler(&", serviceName, "{h}, append(nopts, opts...)...))") gfile.P("}") }