Compare commits

...

115 Commits

Author SHA1 Message Date
858bf4716c Merge pull request 'fix gen' (#90) from ff into master
Reviewed-on: #90
2023-12-26 00:56:33 +03:00
0c6589a630 fix gen
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-12-26 00:55:57 +03:00
6152d866d6 error generate in standalone mode
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-10-18 01:01:30 +03:00
5565534f79 check error field in proto message
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-10-18 00:37:58 +03:00
6228457361 generate error interface
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-10-17 23:43:18 +03:00
190a1903f4 Merge pull request 'append Service only in generated go files' (#87) from namingfix into master
Reviewed-on: #87
2023-08-20 13:16:24 +03:00
d658731441 append Service only in generated go files
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-08-20 13:16:08 +03:00
6256b7061b Merge pull request 'v4 fixes' (#86) from v4fix into master
Reviewed-on: #86
2023-08-14 07:38:47 +03:00
02ab3ed5f6 v4 fixes
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-08-12 19:52:46 +03:00
5eaac2003d Merge pull request 'fixes for standalone mode' (#85) from reorg into master
Reviewed-on: #85
2023-07-31 00:57:47 +03:00
59922913a9 fixes for standalone mode
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-07-31 00:56:32 +03:00
d702897cb4 Merge pull request 'generate client and server types in micro file' (#83) from interfaces into master
Reviewed-on: #83
2023-07-30 23:54:26 +03:00
ec03ee131e generate client and server types in micro file
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-07-30 23:54:05 +03:00
86e3dafc12 Merge pull request 'generate http metadata only in case of http component' (#82) from grpc-http into master
Reviewed-on: #82
2023-07-30 23:34:33 +03:00
221e4aff6d generate http metadata only in case of http component
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-07-30 23:33:22 +03:00
d1cc553df8 Merge pull request 'fix codec.Frame usage' (#77) from codec-proto into master
Reviewed-on: #77
2023-05-19 00:29:45 +03:00
454d86cbff fix codec.Frame usage
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-05-19 00:29:23 +03:00
e542efc463 Merge pull request 'fixup rpc CloseSend method' (#76) from closeSendfixup into master
Reviewed-on: #76
2023-05-11 10:36:56 +03:00
8e9be8cda7 fixup rpc CloseSend method
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-05-11 10:36:39 +03:00
46ff53ccd7 Merge pull request 'move to micro v4' (#75) from v4 into master
Reviewed-on: #75
2023-05-04 00:25:54 +03:00
244afcbe64 Merge branch 'master' into v4 2023-05-04 00:25:02 +03:00
d6307cc251 Merge branch 'v3' 2023-05-04 00:23:28 +03:00
543132594b update to micro v4
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-05-04 00:22:05 +03:00
1bdd68d6ea Merge pull request 'generate endpoint metadata only for http server' (#74) from fixup into v3
Reviewed-on: #74
2023-03-15 01:11:20 +03:00
dbaa0089b6 generate endpoint metadata only for http server
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-03-15 01:10:59 +03:00
2f9003161b
Merge pull request #72 from unistack-org/update
replace map
2023-02-22 00:07:58 +03:00
388a58d998 replace map
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-02-22 00:05:54 +03:00
d519d8ac6d
Merge pull request #69 from unistack-org/dependabot/go_modules/golang.org/x/tools-0.6.0
Bump golang.org/x/tools from 0.5.0 to 0.6.0
2023-02-18 02:04:27 +03:00
92e78b6754
Merge branch 'v3' into dependabot/go_modules/golang.org/x/tools-0.6.0 2023-02-18 02:01:43 +03:00
e25d0cdf02
Merge pull request #70 from unistack-org/api-remove
micro api cleanup
2023-02-14 00:24:40 +03:00
71ad836e06 micro api cleanup
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-02-14 00:22:35 +03:00
dependabot[bot]
16a4ceaf26
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] <support@github.com>
2023-02-13 16:03:53 +00:00
dependabot[bot]
5c4a300a4f
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] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-31 06:57:40 +03:00
dependabot[bot]
821949fed3
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] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-31 06:49:26 +03:00
dependabot[bot]
b35607a63e
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] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-30 22:29:50 +03:00
dependabot[bot]
da5d5191db
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] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-28 16:26:11 +03:00
0d2781dfc9
Merge pull request #63 from unistack-org/catch_response_headers
allow to catch response headers
2022-11-15 13:09:44 +03:00
edd1ba2175
Merge branch 'v3' into catch_response_headers 2022-11-15 13:07:59 +03:00
83b6567d3e allow to catch response headers
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-11-15 12:53:04 +03:00
dependabot[bot]
e545d81720
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] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-14 07:22:48 +03:00
dependabot[bot]
a3cf27d062
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] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-14 07:04:10 +03:00
dependabot[bot]
bc4de7e632
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] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-12 18:20:28 +03:00
dependabot[bot]
53ed35a106
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] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-04 13:07:09 +03:00
dependabot[bot]
94b653cbe8
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] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-08-28 14:38:50 +00:00
dependabot[bot]
3d887ac2bf
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] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-08-28 14:32:29 +00:00
dependabot[bot]
a58a9d5173
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] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-08-28 17:23:36 +03:00
dependabot[bot]
f072294110
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] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-25 22:51:12 +03:00
dependabot[bot]
e8389ad0f8
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] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-25 22:41:48 +03:00
dependabot[bot]
adb15d9a67
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] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-25 21:45:08 +03:00
dependabot[bot]
78a508f48d
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] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-21 15:15:35 +03:00
80ed8fba15
Merge pull request #47 from unistack-org/dependabot/github_actions/actions/setup-go-3
Bump actions/setup-go from 2 to 3
2022-04-11 22:50:48 +03:00
dependabot[bot]
a9d41f3adb
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] <support@github.com>
2022-04-08 15:20:06 +00:00
a73c4b836f
Merge pull request #45 from unistack-org/dependabot/github_actions/actions/cache-3
Bump actions/cache from 2 to 3
2022-03-22 23:12:10 +03:00
dependabot[bot]
e587b778b2
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] <support@github.com>
2022-03-22 19:58:08 +00:00
b950206585
Merge pull request #46 from unistack-org/dependabot/go_modules/google.golang.org/protobuf-1.28.0
Bump google.golang.org/protobuf from 1.27.1 to 1.28.0
2022-03-22 22:57:30 +03:00
dependabot[bot]
773793955d
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] <support@github.com>
2022-03-22 15:29:50 +00:00
3591d02d42
Merge pull request #44 from unistack-org/drpc
fix drpc method name in generator
2022-03-20 15:10:23 +03:00
a2fea36f50 fix drpc method name in generator
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-03-20 15:08:04 +03:00
03355d0d83
Merge pull request #43 from unistack-org/drpc
add drpc as known component
2022-03-20 14:20:36 +03:00
15e7f6bd16 add drpc as known component
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-03-20 14:18:35 +03:00
a2da7d4ceb
Merge pull request #42 from unistack-org/messageref
support message reference
2022-03-19 15:17:56 +03:00
211999bb04
Merge pull request #41 from unistack-org/dependabot/go_modules/golang.org/x/tools-0.1.10
Bump golang.org/x/tools from 0.1.9 to 0.1.10
2022-03-19 15:17:39 +03:00
59ffe0f3ea update workflows
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-03-19 15:14:58 +03:00
378c00c16d support message reference
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-03-19 15:13:34 +03:00
dependabot[bot]
4f0a7e0c93
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] <support@github.com>
2022-03-16 15:14:49 +00:00
8844f01558 update go version
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-03-07 13:47:14 +03:00
7c25072247
Merge pull request #40 from unistack-org/dependabot/go_modules/go.unistack.org/micro-proto/v3-3.2.7
Bump go.unistack.org/micro-proto/v3 from 3.2.5 to 3.2.7
2022-03-07 13:27:23 +03:00
65151b3e3e
Merge branch 'v3' into dependabot/go_modules/go.unistack.org/micro-proto/v3-3.2.7 2022-03-07 13:27:15 +03:00
ad0fd42945
Merge pull request #39 from unistack-org/dependabot/github_actions/actions/checkout-3
Bump actions/checkout from 2 to 3
2022-03-07 13:27:05 +03:00
dependabot[bot]
8ecb705550
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] <support@github.com>
2022-03-07 09:43:13 +00:00
dependabot[bot]
225887fef8
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] <support@github.com>
2022-03-07 09:43:09 +00:00
e4433a0257 update workflows
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-03-05 19:10:39 +03:00
4f94497f82
Merge pull request #37 from unistack-org/dependabot/go_modules/go.unistack.org/micro-proto/v3-3.2.7
Bump go.unistack.org/micro-proto/v3 from 3.2.5 to 3.2.7
2022-03-03 19:12:28 +03:00
3e1a0a83cf
Merge pull request #38 from unistack-org/dependabot/github_actions/actions/checkout-3
Bump actions/checkout from 2 to 3
2022-03-03 19:12:19 +03:00
41e32e36b3 fix for empty default response
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-03-03 19:11:57 +03:00
dependabot[bot]
91c4cba229
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] <support@github.com>
2022-03-02 15:27:38 +00:00
dependabot[bot]
76e6924d40
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] <support@github.com>
2022-03-01 15:20:08 +00:00
e6b8324395
Merge pull request #36 from unistack-org/master
merge master
2022-02-28 15:54:01 +03:00
2da3760acb
Merge pull request #34 from unistack-org/dependabot/github_actions/golangci/golangci-lint-action-3
Bump golangci/golangci-lint-action from 2 to 3
2022-02-28 15:51:30 +03:00
6e47e59542
Merge pull request #35 from unistack-org/protofix
allow to specify external types in ref openapi annotation
2022-02-28 15:51:19 +03:00
fc716500c4 allow to specify external types in ref openapi annotation
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-02-28 15:51:04 +03:00
dependabot[bot]
8d8d570880
Bump golangci/golangci-lint-action from 2 to 3
Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 2 to 3.
- [Release notes](https://github.com/golangci/golangci-lint-action/releases)
- [Commits](https://github.com/golangci/golangci-lint-action/compare/v2...v3)

---
updated-dependencies:
- dependency-name: golangci/golangci-lint-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-02-25 15:26:06 +00:00
ed7ae1c518
Merge pull request #33 from unistack-org/master
merge master
2022-02-18 00:59:16 +03:00
3e6e9eb469
Merge pull request #31 from unistack-org/dependabot/github_actions/actions/github-script-6
Bump actions/github-script from 5 to 6
2022-02-18 00:58:49 +03:00
26370e69f2
Merge pull request #32 from unistack-org/rework
fix swagger generator
2022-02-18 00:58:37 +03:00
c996b37985 Merge branch 'master' into rework 2022-02-18 00:58:04 +03:00
d63381e584 improve openapi support
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-02-18 00:54:47 +03:00
dependabot[bot]
a231083367
Bump actions/github-script from 5 to 6
Bumps [actions/github-script](https://github.com/actions/github-script) from 5 to 6.
- [Release notes](https://github.com/actions/github-script/releases)
- [Commits](https://github.com/actions/github-script/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/github-script
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-02-14 15:19:14 +00:00
e52e4b2e19
Merge pull request #30 from unistack-org/master
merge master
2022-02-02 02:38:03 +03:00
dependabot[bot]
752dee776a
Bump golang.org/x/tools from 0.1.8 to 0.1.9 (#28)
Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.1.8 to 0.1.9.
- [Release notes](https://github.com/golang/tools/releases)
- [Commits](https://github.com/golang/tools/compare/v0.1.8...v0.1.9)

---
updated-dependencies:
- dependency-name: golang.org/x/tools
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-02-02 02:36:59 +03:00
9cfdf9539f
update openapi generators (#29)
* improve openapi support

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-02-02 02:29:30 +03:00
a47e8c074b
Merge pull request #25 from unistack-org/dependabot/go_modules/go.unistack.org/micro-proto/v3-3.1.1
Bump go.unistack.org/micro-proto/v3 from 3.1.0 to 3.1.1
2022-01-12 15:31:21 +03:00
dependabot[bot]
67e5e64aa6
Bump go.unistack.org/micro-proto/v3 from 3.1.0 to 3.1.1
Bumps [go.unistack.org/micro-proto/v3](https://github.com/unistack-org/micro-proto) from 3.1.0 to 3.1.1.
- [Release notes](https://github.com/unistack-org/micro-proto/releases)
- [Commits](https://github.com/unistack-org/micro-proto/compare/v3.1.0...v3.1.1)

---
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] <support@github.com>
2021-12-30 15:20:27 +00:00
8afbf92aea add fieldaligment
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-12-26 01:09:11 +03:00
f6cfb2de1e avoid panic on empty swagger info element
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-11-25 23:10:54 +03:00
f814b489db update
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-10-27 15:29:48 +03:00
2ec1af2884 add support for cookie and header variables
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-10-24 00:52:39 +03:00
a63ea1ec4d fix import paths
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-10-23 23:34:05 +03:00
74fecbec12 cleanup deps
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-10-23 23:30:16 +03:00
506f19310f some fixes
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-10-23 23:21:10 +03:00
59ee7bc1de update to never micro-proto, generate openapi
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-10-23 02:55:43 +03:00
github-actions[bot]
763ca7ff90
Merge pull request #23 from unistack-org/dependabot/github_actions/actions/github-script-5
Bump actions/github-script from 4 to 5
2021-09-27 15:27:45 +00:00
dependabot[bot]
af4f014e20
Bump actions/github-script from 4 to 5
Bumps [actions/github-script](https://github.com/actions/github-script) from 4 to 5.
- [Release notes](https://github.com/actions/github-script/releases)
- [Commits](https://github.com/actions/github-script/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/github-script
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-27 15:26:58 +00:00
4329841a0b update workflow
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-09-21 21:48:24 +03:00
452b8de530 update workflows
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-09-17 07:49:57 +03:00
db8b8dbdd2 enable automerge
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-09-16 11:08:29 +03:00
dependabot[bot]
c69b0656a4
Bump github.com/unistack-org/micro-proto from 0.0.8 to 0.0.9 (#22) 2021-09-06 14:51:43 +00:00
3512d60b3a add github stuff
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-09-06 15:28:24 +03:00
2112172891 add github stuff
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-09-06 10:37:30 +03:00
5d13b84c7a add micro.codec.Frame special type handling
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-08-31 20:39:56 +03:00
ee4d83458f fix tag for nested messages
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-08-31 19:40:20 +03:00
dd62c380f2 lint fixes
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-08-20 23:03:11 +03:00
e4f2867419 update
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-08-17 00:58:23 +03:00
c5f68efd4c update with never micro-proto
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-08-17 00:10:01 +03:00
140c5fb90a update to latest micro-protoc
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-08-16 23:34:32 +03:00
25 changed files with 2258 additions and 235 deletions

19
.github/dependabot.yml vendored Normal file
View File

@ -0,0 +1,19 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
# Maintain dependencies for Golang
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "daily"

20
.github/renovate.json vendored
View File

@ -1,20 +0,0 @@
{
"extends": [
"config:base"
],
"postUpdateOptions": ["gomodTidy"],
"packageRules": [
{
"matchUpdateTypes": ["minor", "patch", "pin", "digest"],
"automerge": true
},
{
"groupName": "all deps",
"separateMajorMinor": true,
"groupSlug": "all",
"packagePatterns": [
"*"
]
}
]
}

20
.github/workflows/autoapprove.yml vendored Normal file
View File

@ -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@v3
if: github.actor == 'vtolstov' || github.actor == 'dependabot[bot]'
id: approve
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

21
.github/workflows/automerge.yml vendored Normal file
View File

@ -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}}

View File

@ -3,19 +3,20 @@ on:
push: push:
branches: branches:
- master - master
- v3
jobs: jobs:
test: test:
name: test name: test
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: setup - name: setup
uses: actions/setup-go@v2 uses: actions/setup-go@v3
with: with:
go-version: 1.16 go-version: 1.17
- name: checkout - name: checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: cache - name: cache
uses: actions/cache@v2 uses: actions/cache@v3
with: with:
path: ~/go/pkg/mod path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
@ -31,9 +32,9 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: checkout - name: checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: lint - name: lint
uses: golangci/golangci-lint-action@v2 uses: golangci/golangci-lint-action@v3.4.0
continue-on-error: true continue-on-error: true
with: with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.

78
.github/workflows/codeql-analysis.yml vendored Normal file
View File

@ -0,0 +1,78 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "codeql"
on:
workflow_run:
workflows: ["prbuild"]
types:
- completed
push:
branches: [ master, v3 ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master, v3 ]
schedule:
- cron: '34 1 * * 0'
jobs:
analyze:
name: analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'go' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# 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
uses: actions/checkout@v3
- name: setup
uses: actions/setup-go@v3
with:
go-version: 1.17
# Initializes the CodeQL tools for scanning.
- name: init
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.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# 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@v2
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: analyze
uses: github/codeql-action/analyze@v2

View File

@ -0,0 +1,27 @@
name: "dependabot-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 == 'dependabot[bot]'
steps:
- name: metadata
id: metadata
uses: dependabot/fetch-metadata@v1.3.6
with:
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}}

View File

@ -3,19 +3,20 @@ on:
pull_request: pull_request:
branches: branches:
- master - master
- v3
jobs: jobs:
test: test:
name: test name: test
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: setup - name: setup
uses: actions/setup-go@v2 uses: actions/setup-go@v3
with: with:
go-version: 1.16 go-version: 1.17
- name: checkout - name: checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: cache - name: cache
uses: actions/cache@v2 uses: actions/cache@v3
with: with:
path: ~/go/pkg/mod path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
@ -31,9 +32,9 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: checkout - name: checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: lint - name: lint
uses: golangci/golangci-lint-action@v2 uses: golangci/golangci-lint-action@v3.4.0
continue-on-error: true continue-on-error: true
with: with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.

2
.gitignore vendored
View File

@ -34,5 +34,5 @@ _cgo_export.*
*~ *~
*.swp *.swp
*.swo *.swo
/protoc-gen-micro /protoc-gen-go-micro

View File

@ -10,7 +10,7 @@ This project is a generator plugin for the Google Protocol Buffers compiler (`pr
## Usage ## Usage
```console ```console
$> protoc --micro_out=debug=true,components="micro|http":. input.proto $> protoc --go_micro_out=debug=true,components="micro|http":. input.proto
``` ```
| Option | Default Value | Accepted Values | Description | Option | Default Value | Accepted Values | Description
@ -22,5 +22,5 @@ $> protoc --micro_out=debug=true,components="micro|http":. input.proto
## Install ## Install
* Install the **go** compiler and tools from https://golang.org/doc/install * Install the **go** compiler and tools from https://golang.org/doc/install
* Install **protoc-gen-go**: `go get google.golang.org/protobuf/cmd/protoc-gen-go` * Install **protoc-gen-go**: `go install google.golang.org/protobuf/cmd/protoc-gen-go`
* Install **protoc-gen-go-micro**: `go get github.com/unistack-org/protoc-gen-go-micro/v3` * Install **protoc-gen-go-micro**: `go install go.unistack.org/protoc-gen-go-micro/v4`

39
ast.go
View File

@ -10,25 +10,14 @@ import (
"strings" "strings"
"github.com/fatih/structtag" "github.com/fatih/structtag"
tag_options "github.com/unistack-org/micro-proto/tag" tag_options "go.unistack.org/micro-proto/v4/tag"
"google.golang.org/protobuf/compiler/protogen" "google.golang.org/protobuf/compiler/protogen"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
var ( var astFields = make(map[string]map[string]map[string]*structtag.Tags) // map proto file with proto message ast struct
astFields = make(map[string]map[string]map[string]*structtag.Tags) // map proto file with proto message ast struct
)
func (g *Generator) astGenerate(plugin *protogen.Plugin) error { func (g *Generator) astFill(file *protogen.File, message *protogen.Message) error {
if g.tagPath == "" {
return nil
}
for _, file := range plugin.Files {
if !file.Generate {
continue
}
for _, message := range file.Messages {
for _, field := range message.Fields { for _, field := range message.Fields {
if field.Desc.Options() == nil { if field.Desc.Options() == nil {
continue continue
@ -57,6 +46,28 @@ func (g *Generator) astGenerate(plugin *protogen.Plugin) error {
astFields[fpath] = mp astFields[fpath] = mp
} }
} }
for _, nmessage := range message.Messages {
if err := g.astFill(file, nmessage); err != nil {
return err
}
}
return nil
}
func (g *Generator) astGenerate(plugin *protogen.Plugin) error {
if g.tagPath == "" {
return nil
}
for _, file := range plugin.Files {
if !file.Generate {
continue
}
for _, message := range file.Messages {
if err := g.astFill(file, message); err != nil {
return err
}
} }
} }

17
chi.go
View File

@ -4,9 +4,7 @@ import (
"google.golang.org/protobuf/compiler/protogen" "google.golang.org/protobuf/compiler/protogen"
) )
var ( var chiPackageFiles map[protogen.GoPackageName]struct{}
chiPackageFiles map[protogen.GoPackageName]struct{}
)
func (g *Generator) chiGenerate(component string, plugin *protogen.Plugin) error { func (g *Generator) chiGenerate(component string, plugin *protogen.Plugin) error {
chiPackageFiles = make(map[protogen.GoPackageName]struct{}) 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(stringsPackage)
gfile.Import(chiPackage) gfile.Import(chiPackage)
gfile.Import(chiMiddlewarePackage) gfile.Import(chiMiddlewarePackage)
gfile.Import(microApiPackage)
gfile.P("type routeKey struct{}") 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("return value, ok")
gfile.P("}") gfile.P("}")
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("v := ", reflectPackage.Ident("ValueOf"), "(h)")
gfile.P("if v.NumMethod() < 1 {") gfile.P("if v.NumMethod() < 1 {")
gfile.P(`return `, fmtPackage.Ident("Errorf"), `("handler has no methods: %T", h)`) gfile.P(`return `, fmtPackage.Ident("Errorf"), `("handler has no methods: %T", h)`)
gfile.P("}") gfile.P("}")
gfile.P("for _, ep := range eps {") gfile.P("for _, ep := range eps {")
gfile.P(`idx := `, stringsPackage.Ident("Index"), `(ep.Name, ".")`) gfile.P(`idx := `, stringsPackage.Ident("Index"), `(ep.Name, ".")`)
gfile.P("if idx < 1 || len(ep.Name) <= idx {") 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(`return `, fmtPackage.Ident("Errorf"), `("invalid endpoint name: %s", ep.Name)`)
gfile.P("}") gfile.P("}")
gfile.P("name := ep.Name[idx+1:]") gfile.P(`name := ep.Name[idx+1:]`)
gfile.P("m := v.MethodByName(name)") gfile.P("m := v.MethodByName(name)")
gfile.P("if !m.IsValid() || m.IsZero() {") gfile.P("if !m.IsValid() || m.IsZero() {")
gfile.P(`return `, fmtPackage.Ident("Errorf"), `("invalid handler, method %s not found", name)`) 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("if !ok {")
gfile.P(`return `, fmtPackage.Ident("Errorf"), `("invalid handler: %#+v", m.Interface())`) gfile.P(`return `, fmtPackage.Ident("Errorf"), `("invalid handler: %#+v", m.Interface())`)
gfile.P("}") gfile.P("}")
gfile.P("for _, method := range ep.Method {") gfile.P("r.With(", chiMiddlewarePackage.Ident("WithValue"), `(routeKey{}, ep.Name)).MethodFunc(ep.Method, ep.Path, rh)`)
gfile.P("r.With(", chiMiddlewarePackage.Ident("WithValue"), "(routeKey{}, ep.Name)).MethodFunc(method, ep.Path[0], rh)")
gfile.P("}")
gfile.P("}") gfile.P("}")
gfile.P("return nil") gfile.P("return nil")
gfile.P("}") gfile.P("}")

View File

@ -2,7 +2,7 @@ syntax = "proto3";
package example; package example;
option go_package = "github.com/unistack-org/protoc-gen-go-micro/v3/example;examplepb"; option go_package = "github.com/unistack-org/protoc-gen-go-micro/v4/example;examplepb";
import "tag/tag.proto"; import "tag/tag.proto";
import "api/annotations.proto"; import "api/annotations.proto";
@ -11,7 +11,7 @@ import "google/protobuf/wrappers.proto";
service Example { service Example {
rpc Call(CallReq) returns (CallRsp) { rpc Call(CallReq) returns (CallRsp) {
option (micro.openapiv2.openapiv2_operation) = { option (micro.openapiv3.openapiv3_operation) = {
operation_id: "Call"; operation_id: "Call";
responses: { responses: {
key: "default"; key: "default";
@ -26,7 +26,7 @@ service Example {
} }
}; };
option (micro.api.http) = { post: "/v1/example/call/{name}"; body: "*"; }; option (micro.api.http) = { post: "/v1/example/call/{name}"; body: "*"; };
option (micro.api.micro_method) = { timeout: 5; }; option (micro.api.micro_method) = { timeout: "5s"; };
}; };
}; };

24
fiealaligment.go Normal file
View File

@ -0,0 +1,24 @@
package main
import (
"log"
"os"
"golang.org/x/tools/go/analysis/passes/fieldalignment"
"golang.org/x/tools/go/analysis/singlechecker"
"google.golang.org/protobuf/compiler/protogen"
)
func (g *Generator) fieldAlign(plugin *protogen.Plugin) error {
if !g.fieldaligment {
return nil
}
log.Printf("%v\n", []string{"fieldalignment", "-fix", g.tagPath})
origArgs := os.Args
os.Args = []string{"fieldalignment", "-fix", g.tagPath}
singlechecker.Main(fieldalignment.Analyzer)
os.Args = origArgs
return nil
}

18
go.mod
View File

@ -1,12 +1,18 @@
module github.com/unistack-org/protoc-gen-go-micro/v3 module go.unistack.org/protoc-gen-go-micro/v4
go 1.16 go 1.19
require ( require (
github.com/fatih/structtag v1.2.0 github.com/fatih/structtag v1.2.0
github.com/unistack-org/micro-proto v0.0.2 go.unistack.org/micro-proto/v4 v4.0.1
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect golang.org/x/tools v0.11.0
google.golang.org/protobuf v1.26.0 google.golang.org/protobuf v1.31.0
) )
//replace github.com/unistack-org/micro-proto => ../micro-proto require (
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic v0.6.9 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/sys v0.10.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

90
go.sum
View File

@ -1,23 +1,47 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4= github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4=
github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94= github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94=
github.com/flowstack/go-jsonschema v0.1.1/go.mod h1:yL7fNggx1o8rm9RlgXv7hTBWxdBM0rVwpMwimd3F3N0=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
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.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.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
@ -25,29 +49,73 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs=
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/unistack-org/micro-proto v0.0.2 h1:mL1ZPRGPCWJOiMBiJrkk8Y513rPrJmhJWxyLceckAXU= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/unistack-org/micro-proto v0.0.2/go.mod h1:GYO53DWmeldRIo90cAdQx8bLr/WJMxW62W4ja74p1Ac= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
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=
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
go.unistack.org/micro-proto/v4 v4.0.1 h1:2RKHgtCOOcAFgKsnngGK5bqM/6MWXOjVCdw03dbuoF8=
go.unistack.org/micro-proto/v4 v4.0.1/go.mod h1:ArmK7o+uFvxSY3dbJhKBBX4Pm1rhWdLEFf3LxBrMtec=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 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/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= 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-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-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
golang.org/x/mod v0.12.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-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-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
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/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= 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-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-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-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 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-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
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.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 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/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-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-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-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-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.11.0 h1:EMCa6U9S2LtZXLAMoWiR/R8dAQFRqbAitmbJ2UKhoi8=
golang.org/x/tools v0.11.0/go.mod h1:anzJrxPjNtfgiYQYirP2CPGzGLxrH2u2QBhn6Bf3qY8=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/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 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
@ -55,10 +123,16 @@ google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9Ywl
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
google.golang.org/genproto v0.0.0-20220107163113-42d7afdf6368/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
@ -69,7 +143,17 @@ google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= 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-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= 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.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.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=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

View File

@ -4,9 +4,7 @@ import (
"google.golang.org/protobuf/compiler/protogen" "google.golang.org/protobuf/compiler/protogen"
) )
var ( var gorillaPackageFiles map[protogen.GoPackageName]struct{}
gorillaPackageFiles map[protogen.GoPackageName]struct{}
)
func (g *Generator) gorillaGenerate(component string, plugin *protogen.Plugin) error { func (g *Generator) gorillaGenerate(component string, plugin *protogen.Plugin) error {
gorillaPackageFiles = make(map[protogen.GoPackageName]struct{}) 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(httpPackage)
gfile.Import(reflectPackage) gfile.Import(reflectPackage)
gfile.Import(stringsPackage) gfile.Import(stringsPackage)
gfile.Import(microApiPackage)
gfile.Import(gorillaMuxPackage) 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("v := ", reflectPackage.Ident("ValueOf"), "(h)")
gfile.P("if v.NumMethod() < 1 {") gfile.P("if v.NumMethod() < 1 {")
gfile.P(`return `, fmtPackage.Ident("Errorf"), `("handler has no methods: %T", h)`) gfile.P(`return `, fmtPackage.Ident("Errorf"), `("handler has no methods: %T", h)`)
gfile.P("}") gfile.P("}")
gfile.P("for _, ep := range eps {") gfile.P("for _, ep := range eps {")
gfile.P(`idx := `, stringsPackage.Ident("Index"), `(ep.Name, ".")`) gfile.P(`idx := `, stringsPackage.Ident("Index"), `(ep.Name, ".")`)
gfile.P("if idx < 1 || len(ep.Name) <= idx {") 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(`return `, fmtPackage.Ident("Errorf"), `("invalid endpoint name: %s", ep.Name)`)
gfile.P("}") gfile.P("}")
gfile.P("name := ep.Name[idx+1:]") gfile.P(`name := ep.Name[idx+1:]`)
gfile.P("m := v.MethodByName(name)") gfile.P("m := v.MethodByName(name)")
gfile.P("if !m.IsValid() || m.IsZero() {") gfile.P("if !m.IsValid() || m.IsZero() {")
gfile.P(`return `, fmtPackage.Ident("Errorf"), `("invalid handler, method %s not found", name)`) 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("if !ok {")
gfile.P(`return `, fmtPackage.Ident("Errorf"), `("invalid handler: %#+v", m.Interface())`) gfile.P(`return `, fmtPackage.Ident("Errorf"), `("invalid handler: %#+v", m.Interface())`)
gfile.P("}") 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("}")
gfile.P("return nil") gfile.P("return nil")
gfile.P("}") gfile.P("}")

13
http.go
View File

@ -28,7 +28,7 @@ func (g *Generator) httpGenerate(component string, plugin *protogen.Plugin, genC
gfile.P() gfile.P()
gfile.Import(contextPackage) gfile.Import(contextPackage)
gfile.Import(microApiPackage)
if genClient { if genClient {
gfile.Import(microClientPackage) gfile.Import(microClientPackage)
gfile.Import(microClientHttpPackage) gfile.Import(microClientHttpPackage)
@ -38,14 +38,15 @@ func (g *Generator) httpGenerate(component string, plugin *protogen.Plugin, genC
} }
for _, service := range file.Services { for _, service := range file.Services {
g.generateServiceEndpoints(gfile, service, component)
if genClient { if genClient {
generateServiceClient(gfile, service) g.generateServiceClient(gfile, file, service)
generateServiceClientMethods(gfile, service, true) g.generateServiceClientMethods(gfile, service, component)
} }
if genServer { if genServer {
generateServiceServer(gfile, service) g.generateServiceServer(gfile, file, service)
generateServiceServerMethods(gfile, service) g.generateServiceServerMethods(gfile, service)
generateServiceRegister(gfile, service) g.generateServiceRegister(gfile, file, service, component)
} }
} }
} }

53
main.go
View File

@ -3,6 +3,7 @@ package main
import ( import (
"flag" "flag"
"fmt" "fmt"
"os"
"strings" "strings"
"google.golang.org/protobuf/compiler/protogen" "google.golang.org/protobuf/compiler/protogen"
@ -10,15 +11,27 @@ import (
) )
var ( var (
flagDebug = flag.Bool("debug", false, "") flagSet = flag.NewFlagSet(os.Args[0], flag.ExitOnError)
flagStandalone = flag.Bool("standalone", false, "") flagDebug = flagSet.Bool("debug", false, "debug output")
flagComponents = flag.String("components", "micro|rpc|http|client|server", "") flagStandalone = flagSet.Bool("standalone", false, "generate file to standalone dir")
flagTagPath = flag.String("tag_path", "", "") flagFieldaligment = flagSet.Bool("fieldaligment", false, "align struct fields in generated code")
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")
) )
func main() { func main() {
opts := &protogen.Options{ opts := &protogen.Options{
ParamFunc: flag.CommandLine.Set, ParamFunc: flagSet.Set,
}
flagSet.Parse(os.Args[1:])
if *flagHelp {
flagSet.PrintDefaults()
return
} }
g := &Generator{} g := &Generator{}
@ -30,20 +43,29 @@ type Generator struct {
components string components string
standalone bool standalone bool
debug bool debug bool
fieldaligment bool
tagPath string tagPath string
openapiFile string
reflection bool
plugin *protogen.Plugin
} }
func (g *Generator) Generate(plugin *protogen.Plugin) error { func (g *Generator) Generate(plugin *protogen.Plugin) error {
var err error var err error
g.plugin = plugin
g.standalone = *flagStandalone g.standalone = *flagStandalone
g.debug = *flagDebug g.debug = *flagDebug
g.components = *flagComponents g.components = *flagComponents
g.fieldaligment = *flagFieldaligment
g.tagPath = *flagTagPath g.tagPath = *flagTagPath
g.openapiFile = *flagOpenapiFile
g.reflection = *flagReflection
plugin.SupportedFeatures = uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL) plugin.SupportedFeatures = uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL)
var genClient bool var genClient bool
var genServer bool var genServer bool
var genNone bool
if strings.Contains(g.components, "server") { if strings.Contains(g.components, "server") {
genServer = true genServer = true
@ -51,8 +73,11 @@ func (g *Generator) Generate(plugin *protogen.Plugin) error {
if strings.Contains(g.components, "client") { if strings.Contains(g.components, "client") {
genClient = true genClient = true
} }
if strings.Contains(g.components, "none") {
genNone = true
}
if strings.Contains(g.components, "rpc") || strings.Contains(g.components, "http") { if strings.Contains(g.components, "rpc") || strings.Contains(g.components, "http") {
if !genServer && !genClient { if !genServer && !genClient && !genNone {
genServer = true genServer = true
genClient = true genClient = true
} }
@ -65,14 +90,21 @@ func (g *Generator) Generate(plugin *protogen.Plugin) error {
continue continue
case "micro": case "micro":
err = g.microGenerate(component, plugin, genClient, genServer) err = g.microGenerate(component, plugin, genClient, genServer)
if err == nil {
err = g.writeErrors(plugin)
}
case "http": case "http":
err = g.httpGenerate(component, plugin, genClient, genServer) err = g.httpGenerate(component, plugin, genClient, genServer)
case "grpc", "rpc": case "grpc", "drpc", "rpc":
err = g.rpcGenerate("rpc", plugin, genClient, genServer) err = g.rpcGenerate(component, plugin, genClient, genServer)
case "gorilla": case "gorilla":
err = g.gorillaGenerate(component, plugin) err = g.gorillaGenerate(component, plugin)
case "chi": case "chi":
err = g.chiGenerate(component, plugin) err = g.chiGenerate(component, plugin)
case "openapiv3":
err = g.openapiv3Generate(component, plugin)
case "none":
break
default: default:
err = fmt.Errorf("unknown component: %s", component) err = fmt.Errorf("unknown component: %s", component)
} }
@ -89,5 +121,10 @@ func (g *Generator) Generate(plugin *protogen.Plugin) error {
return err return err
} }
if err = g.fieldAlign(plugin); err != nil {
plugin.Error(err)
return err
}
return nil return nil
} }

View File

@ -1,6 +1,8 @@
package main package main
import ( import (
"fmt"
"google.golang.org/protobuf/compiler/protogen" "google.golang.org/protobuf/compiler/protogen"
) )
@ -22,27 +24,29 @@ func (g *Generator) microGenerate(component string, plugin *protogen.Plugin, gen
gfile := plugin.NewGeneratedFile(gname, path) gfile := plugin.NewGeneratedFile(gname, path)
gfile.P("// Code generated by protoc-gen-go-micro. DO NOT EDIT.") gfile.P("// Code generated by protoc-gen-go-micro. DO NOT EDIT.")
gfile.P("// protoc-gen-go-micro version: " + versionComment) gfile.P("// versions:")
gfile.P("// source: ", file.Proto.GetName()) gfile.P("// - protoc-gen-go-micro " + versionComment)
gfile.P("// - protoc ", protocVersion(plugin))
gfile.P("// source: ", file.Desc.Path())
gfile.P() gfile.P()
gfile.P("package ", file.GoPackageName) gfile.P("package ", file.GoPackageName)
gfile.P() gfile.P()
gfile.Import(contextPackage) gfile.Import(contextPackage)
gfile.Import(microApiPackage)
if genClient { if genClient {
gfile.Import(microClientPackage) gfile.Import(microClientPackage)
} }
// generate services // generate services
for _, service := range file.Services { for _, service := range file.Services {
generateServiceEndpoints(gfile, service) g.generateServiceName(gfile, service)
if genClient { if genClient {
generateServiceClientInterface(gfile, service) g.generateServiceClientInterface(gfile, service)
generateServiceClientStreamInterface(gfile, service) g.generateServiceClientStreamInterface(gfile, service)
} }
if genServer { if genServer {
generateServiceServerInterface(gfile, service) g.generateServiceServerInterface(gfile, service)
generateServiceServerStreamInterface(gfile, service) g.generateServiceServerStreamInterface(gfile, service)
} }
} }
@ -50,3 +54,15 @@ func (g *Generator) microGenerate(component string, plugin *protogen.Plugin, gen
return nil 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)
}

1207
openapiv3.go Normal file

File diff suppressed because it is too large Load Diff

39
openapiv3_util.go Normal file
View File

@ -0,0 +1,39 @@
package main
import v3 "go.unistack.org/micro-proto/v4/openapiv3"
func getMediaType(eopt interface{}) string {
ctype := "application/json"
if eopt == nil {
return ctype
}
if eopt == v3.E_Openapiv3Operation.InterfaceOf(v3.E_Openapiv3Operation.Zero()) {
return ctype
}
opt, ok := eopt.(*v3.Operation)
if !ok || opt.RequestBody == nil {
return ctype
}
if opt.GetRequestBody() == nil {
return ctype
}
if opt.GetRequestBody().GetRequestBody() == nil {
return ctype
}
c := opt.GetRequestBody().GetRequestBody().GetContent()
if c == nil {
return ctype
}
for _, prop := range c.GetAdditionalProperties() {
ctype = prop.Name
}
return ctype
}

15
rpc.go
View File

@ -28,7 +28,7 @@ func (g *Generator) rpcGenerate(component string, plugin *protogen.Plugin, genCl
gfile.P() gfile.P()
gfile.Import(contextPackage) gfile.Import(contextPackage)
gfile.Import(microApiPackage)
if genClient { if genClient {
gfile.Import(microClientPackage) gfile.Import(microClientPackage)
} }
@ -37,13 +37,16 @@ func (g *Generator) rpcGenerate(component string, plugin *protogen.Plugin, genCl
} }
for _, service := range file.Services { for _, service := range file.Services {
if genClient { if genClient {
generateServiceClient(gfile, service) g.generateServiceClient(gfile, file, service)
generateServiceClientMethods(gfile, service, false) g.generateServiceClientMethods(gfile, service, component)
} }
if genServer { if genServer {
generateServiceServer(gfile, service) g.generateServiceServer(gfile, file, service)
generateServiceServerMethods(gfile, service) g.generateServiceServerMethods(gfile, service)
generateServiceRegister(gfile, service) g.generateServiceRegister(gfile, file, service, component)
}
if component == "grpc" && g.reflection {
g.generateServiceDesc(gfile, file, service)
} }
} }
} }

638
util.go
View File

@ -2,35 +2,38 @@ package main
import ( import (
"fmt" "fmt"
"log"
"net/http"
"strconv"
"strings" "strings"
"time"
api_options "github.com/unistack-org/micro-proto/api" api_options "go.unistack.org/micro-proto/v4/api"
openapiv2_options "github.com/unistack-org/micro-proto/openapiv2" v2 "go.unistack.org/micro-proto/v4/openapiv2"
v3 "go.unistack.org/micro-proto/v4/openapiv3"
"google.golang.org/protobuf/compiler/protogen" "google.golang.org/protobuf/compiler/protogen"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
var ( var httpMethodMap = map[string]string{
httpMethodMap = map[string]string{ http.MethodGet: "MethodGet",
"GET": "MethodGet", http.MethodHead: "MethodHead",
"HEAD": "MethodHead", http.MethodPost: "MethodPost",
"POST": "MethodPost", http.MethodPut: "MethodPut",
"PUT": "MethodPut", http.MethodPatch: "MethodPatch",
"PATCH": "MethodPatch", http.MethodDelete: "MethodDelete",
"DELETE": "MethodDelete", http.MethodConnect: "MethodConnect",
"CONNECT": "MethodConnect", http.MethodOptions: "MethodOptions",
"OPTIONS": "MethodOptions", http.MethodTrace: "MethodTrace",
"TRACE": "MethodTrace", }
}
)
func unexport(s string) string { func unexport(s string) string {
return strings.ToLower(s[:1]) + s[1:] return strings.ToLower(s[:1]) + s[1:]
} }
func generateServiceClient(gfile *protogen.GeneratedFile, service *protogen.Service) { func (g *Generator) generateServiceClient(gfile *protogen.GeneratedFile, file *protogen.File, service *protogen.Service) {
serviceName := service.GoName serviceName := getServiceName(service)
//if rule, ok := getMicroApiService(service); ok { // if rule, ok := getMicroApiService(service); ok {
// gfile.P("// client wrappers ", strings.Join(rule.ClientWrappers, ", ")) // gfile.P("// client wrappers ", strings.Join(rule.ClientWrappers, ", "))
// } // }
gfile.P("type ", unexport(serviceName), "Client struct {") gfile.P("type ", unexport(serviceName), "Client struct {")
@ -38,39 +41,106 @@ func generateServiceClient(gfile *protogen.GeneratedFile, service *protogen.Serv
gfile.P("name string") gfile.P("name string")
gfile.P("}") gfile.P("}")
if g.standalone {
gfile.P("func New", serviceName, "Client(name string, c ", microClientPackage.Ident("Client"), ") ", file.GoImportPath.Ident(serviceName), "Client {")
} else {
gfile.P("func New", serviceName, "Client(name string, c ", microClientPackage.Ident("Client"), ") ", serviceName, "Client {") gfile.P("func New", serviceName, "Client(name string, c ", microClientPackage.Ident("Client"), ") ", serviceName, "Client {")
}
gfile.P("return &", unexport(serviceName), "Client{c: c, name: name}") gfile.P("return &", unexport(serviceName), "Client{c: c, name: name}")
gfile.P("}") gfile.P("}")
gfile.P() gfile.P()
} }
func generateServiceClientMethods(gfile *protogen.GeneratedFile, service *protogen.Service, http bool) { func (g *Generator) generateServiceClientMethods(gfile *protogen.GeneratedFile, service *protogen.Service, component string) {
serviceName := service.GoName serviceName := getServiceName(service)
for _, method := range service.Methods { for _, method := range service.Methods {
methodName := fmt.Sprintf("%s.%s", serviceName, method.GoName) methodName := fmt.Sprintf("%s.%s", serviceName, method.GoName)
generateClientFuncSignature(gfile, serviceName, method) 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(), openapiv2_options.E_Openapiv2Operation) { if proto.HasExtension(method.Desc.Options(), v2.E_Openapiv2Operation) {
opts := proto.GetExtension(method.Desc.Options(), openapiv2_options.E_Openapiv2Operation) opts := proto.GetExtension(method.Desc.Options(), v2.E_Openapiv2Operation)
if opts != nil { if opts != nil {
r := opts.(*openapiv2_options.Operation) r := opts.(*v2.Operation)
gfile.P("errmap := make(map[string]interface{}, ", len(r.Responses), ")") if r.Responses == nil {
for code, response := range r.Responses { goto labelMethod
if response.Schema != nil && response.Schema.JsonSchema != nil { }
ref := response.Schema.JsonSchema.Ref gfile.P("errmap := make(map[string]interface{}, ", len(r.Responses.ResponseCode), ")")
if strings.HasPrefix(ref, "."+string(service.Desc.ParentFile().Package())+".") { for _, rsp := range r.Responses.ResponseCode {
ref = strings.TrimPrefix(ref, "."+string(service.Desc.ParentFile().Package())+".") if schema := rsp.Value.GetJsonReference(); schema != nil {
xref := schema.XRef
if strings.HasPrefix(xref, "."+string(service.Desc.ParentFile().Package())+".") {
xref = strings.TrimPrefix(xref, "."+string(service.Desc.ParentFile().Package())+".")
}
if xref[0] == '.' {
xref = xref[1:]
}
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:
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), "{}")
} }
gfile.P(`errmap["`, code, `"] = &`, ref, "{}")
} }
} }
} }
gfile.P("opts = append(opts,") gfile.P("opts = append(opts,")
gfile.P(microClientHttpPackage.Ident("ErrorMap"), "(errmap),") gfile.P(microClientHttpPackage.Ident("ErrorMap"), "(errmap),")
gfile.P(")") gfile.P(")")
} }
if proto.HasExtension(method.Desc.Options(), v3.E_Openapiv3Operation) {
opts := proto.GetExtension(method.Desc.Options(), v3.E_Openapiv3Operation)
if opts != nil {
r := opts.(*v3.Operation)
if r.Responses == nil {
goto labelMethod
}
resps := r.Responses.ResponseOrReference
if r.Responses.GetDefault() != nil {
resps = append(resps, &v3.NamedResponseOrReference{Name: "default", Value: r.Responses.GetDefault()})
}
gfile.P("errmap := make(map[string]interface{}, ", len(resps), ")")
for _, rsp := range resps {
if schema := rsp.Value.GetReference(); schema != nil {
xref := schema.XRef
if strings.HasPrefix(xref, "."+string(service.Desc.ParentFile().Package())+".") {
xref = strings.TrimPrefix(xref, "."+string(service.Desc.ParentFile().Package())+".")
}
if xref[0] == '.' {
xref = xref[1:]
}
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:
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), "{}")
}
}
}
}
gfile.P("opts = append(opts,")
gfile.P(microClientHttpPackage.Ident("ErrorMap"), "(errmap),")
gfile.P(")")
}
labelMethod:
if proto.HasExtension(method.Desc.Options(), api_options.E_Http) { if proto.HasExtension(method.Desc.Options(), api_options.E_Http) {
gfile.P("opts = append(opts,") gfile.P("opts = append(opts,")
endpoints, _ := generateEndpoints(method) endpoints, _ := generateEndpoints(method)
@ -86,10 +156,77 @@ func generateServiceClientMethods(gfile *protogen.GeneratedFile, service *protog
} }
gfile.P(")") gfile.P(")")
} }
parameters := make(map[string]map[string]string)
// Build a list of header parameters.
e2opt := proto.GetExtension(method.Desc.Options(), v2.E_Openapiv2Operation)
if e2opt != nil && e2opt != v2.E_Openapiv2Operation.InterfaceOf(v2.E_Openapiv2Operation.Zero()) {
opt := e2opt.(*v2.Operation)
for _, paramOrRef := range opt.Parameters {
parameter := paramOrRef.GetParameter()
// NonBodyParameter()
if parameter == nil {
continue
} }
nonBodyParameter := parameter.GetNonBodyParameter()
if nonBodyParameter == nil {
continue
}
headerParameter := nonBodyParameter.GetHeaderParameterSubSchema()
if headerParameter.In != "header" && headerParameter.In != "cookie" {
continue
}
in, ok := parameters[headerParameter.In]
if !ok {
in = make(map[string]string)
parameters[headerParameter.In] = in
}
in[headerParameter.Name] = fmt.Sprintf("%v", headerParameter.Required)
}
}
e3opt := proto.GetExtension(method.Desc.Options(), v3.E_Openapiv3Operation)
if e3opt != nil && e3opt != v3.E_Openapiv3Operation.InterfaceOf(v3.E_Openapiv3Operation.Zero()) {
opt := e3opt.(*v3.Operation)
for _, paramOrRef := range opt.Parameters {
parameter := paramOrRef.GetParameter()
if parameter == nil {
continue
}
if parameter.In != "header" && parameter.In != "cookie" {
continue
}
in, ok := parameters[parameter.In]
if !ok {
in = make(map[string]string)
parameters[parameter.In] = in
}
in[parameter.Name] = fmt.Sprintf("%v", parameter.Required)
}
}
if len(parameters) > 0 {
gfile.P("opts = append(opts,")
for pk, pv := range parameters {
params := make([]string, 0, len(pv)/2)
for k, v := range pv {
params = append(params, k, v)
}
gfile.P(microClientHttpPackage.Ident(strings.Title(pk)), `("`, strings.Join(params, `" ,"`), `"),`)
}
gfile.P(")")
}
}
if rule, ok := getMicroApiMethod(method); ok { if rule, ok := getMicroApiMethod(method); ok {
if rule.Timeout > 0 { if rule.Timeout != "" {
gfile.P("opts = append(opts, ", microClientPackage.Ident("WithRequestTimeout"), "(", timePackage.Ident("Second"), "*", rule.Timeout, "))") td, err := time.ParseDuration(rule.Timeout)
if err != nil {
log.Printf("parse duration error %s\n", err.Error())
} else {
gfile.P("td := ", timePackage.Ident("Duration"), "(", td.Nanoseconds(), ")")
gfile.P("opts = append(opts, ", microClientPackage.Ident("WithRequestTimeout"), "(td))")
}
} }
} }
@ -126,7 +263,7 @@ func generateServiceClientMethods(gfile *protogen.GeneratedFile, service *protog
} }
if method.Desc.IsStreamingClient() && !method.Desc.IsStreamingServer() { if method.Desc.IsStreamingClient() && !method.Desc.IsStreamingServer() {
gfile.P("func (s *", unexport(serviceName), "Client", method.GoName, ") RecvAndClose() (*", gfile.QualifiedGoIdent(method.Output.GoIdent), ", error) {") gfile.P("func (s *", unexport(serviceName), "Client", method.GoName, ") CloseAndRecv() (*", gfile.QualifiedGoIdent(method.Output.GoIdent), ", error) {")
gfile.P("msg := &", gfile.QualifiedGoIdent(method.Output.GoIdent), "{}") gfile.P("msg := &", gfile.QualifiedGoIdent(method.Output.GoIdent), "{}")
gfile.P("err := s.RecvMsg(msg)") gfile.P("err := s.RecvMsg(msg)")
gfile.P("if err == nil {") gfile.P("if err == nil {")
@ -144,6 +281,10 @@ func generateServiceClientMethods(gfile *protogen.GeneratedFile, service *protog
gfile.P("return s.stream.Close()") gfile.P("return s.stream.Close()")
gfile.P("}") gfile.P("}")
gfile.P() gfile.P()
gfile.P("func (s *", unexport(serviceName), "Client", method.GoName, ") CloseSend() error {")
gfile.P("return s.stream.CloseSend()")
gfile.P("}")
gfile.P()
gfile.P("func (s *", unexport(serviceName), "Client", method.GoName, ") Context() ", contextPackage.Ident("Context"), " {") gfile.P("func (s *", unexport(serviceName), "Client", method.GoName, ") Context() ", contextPackage.Ident("Context"), " {")
gfile.P("return s.stream.Context()") gfile.P("return s.stream.Context()")
gfile.P("}") gfile.P("}")
@ -158,6 +299,11 @@ func generateServiceClientMethods(gfile *protogen.GeneratedFile, service *protog
gfile.P() gfile.P()
if method.Desc.IsStreamingClient() { 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("func (s *", unexport(serviceName), "Client", method.GoName, ") Send(msg *", gfile.QualifiedGoIdent(method.Input.GoIdent), ") error {")
gfile.P("return s.stream.Send(msg)") gfile.P("return s.stream.Send(msg)")
gfile.P("}") gfile.P("}")
@ -177,25 +323,35 @@ func generateServiceClientMethods(gfile *protogen.GeneratedFile, service *protog
} }
} }
func generateServiceServer(gfile *protogen.GeneratedFile, service *protogen.Service) { func (g *Generator) generateServiceServer(gfile *protogen.GeneratedFile, file *protogen.File, service *protogen.Service) {
serviceName := service.GoName serviceName := getServiceName(service)
gfile.P("type ", unexport(serviceName), "Server struct {") gfile.P("type ", unexport(serviceName), "Server struct {")
if g.standalone {
gfile.P(file.GoImportPath.Ident(serviceName), "Server")
} else {
gfile.P(serviceName, "Server") gfile.P(serviceName, "Server")
}
gfile.P("}") gfile.P("}")
gfile.P() gfile.P()
} }
func generateServiceServerMethods(gfile *protogen.GeneratedFile, service *protogen.Service) { func (g *Generator) generateServiceServerMethods(gfile *protogen.GeneratedFile, service *protogen.Service) {
serviceName := service.GoName serviceName := getServiceName(service)
for _, method := range service.Methods { for _, method := range service.Methods {
generateServerFuncSignature(gfile, serviceName, method, true) generateServerFuncSignature(gfile, serviceName, method, true)
if rule, ok := getMicroApiMethod(method); ok { if rule, ok := getMicroApiMethod(method); ok {
if rule.Timeout > 0 { 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("var cancel ", contextPackage.Ident("CancelFunc"))
gfile.P("ctx, cancel = ", contextPackage.Ident("WithTimeout"), "(ctx, ", timePackage.Ident("Second"), "*", rule.Timeout, ")") gfile.P("td := ", timePackage.Ident("Duration"), "(", td.Nanoseconds(), ")")
gfile.P("ctx, cancel = ", contextPackage.Ident("WithTimeout"), "(ctx, ", "td", ")")
gfile.P("defer cancel()") gfile.P("defer cancel()")
} }
} }
}
if method.Desc.IsStreamingClient() || method.Desc.IsStreamingServer() { if method.Desc.IsStreamingClient() || method.Desc.IsStreamingServer() {
if !method.Desc.IsStreamingClient() { if !method.Desc.IsStreamingClient() {
gfile.P("msg := &", gfile.QualifiedGoIdent(method.Input.GoIdent), "{}") gfile.P("msg := &", gfile.QualifiedGoIdent(method.Input.GoIdent), "{}")
@ -207,6 +363,64 @@ func generateServiceServerMethods(gfile *protogen.GeneratedFile, service *protog
gfile.P("return h.", serviceName, "Server.", method.GoName, "(ctx, &", unexport(serviceName), method.GoName, "Stream{stream})") gfile.P("return h.", serviceName, "Server.", method.GoName, "(ctx, &", unexport(serviceName), method.GoName, "Stream{stream})")
} }
} else { } else {
parameters := make(map[string]map[string]string)
// Build a list of header parameters.
e2opt := proto.GetExtension(method.Desc.Options(), v2.E_Openapiv2Operation)
if e2opt != nil && e2opt != v2.E_Openapiv2Operation.InterfaceOf(v2.E_Openapiv2Operation.Zero()) {
opt := e2opt.(*v2.Operation)
for _, paramOrRef := range opt.Parameters {
parameter := paramOrRef.GetParameter()
// NonBodyParameter()
if parameter == nil {
continue
}
nonBodyParameter := parameter.GetNonBodyParameter()
if nonBodyParameter == nil {
continue
}
headerParameter := nonBodyParameter.GetHeaderParameterSubSchema()
if headerParameter.In != "header" && headerParameter.In != "cookie" {
continue
}
in, ok := parameters[headerParameter.In]
if !ok {
in = make(map[string]string)
parameters[headerParameter.In] = in
}
in[headerParameter.Name] = fmt.Sprintf("%v", headerParameter.Required)
}
}
e3opt := proto.GetExtension(method.Desc.Options(), v3.E_Openapiv3Operation)
if e3opt != nil && e3opt != v3.E_Openapiv3Operation.InterfaceOf(v3.E_Openapiv3Operation.Zero()) {
opt := e3opt.(*v3.Operation)
for _, paramOrRef := range opt.Parameters {
parameter := paramOrRef.GetParameter()
if parameter == nil {
continue
}
if parameter.In != "header" && parameter.In != "cookie" {
continue
}
in, ok := parameters[parameter.In]
if !ok {
in = make(map[string]string)
parameters[parameter.In] = in
}
in[parameter.Name] = fmt.Sprintf("%v", parameter.Required)
}
}
if len(parameters) > 0 {
gfile.P(microServerHttpPackage.Ident("FillRequest"), `(ctx, req, `)
for pk, pv := range parameters {
params := make([]string, 0, len(pv)/2)
for k, v := range pv {
params = append(params, k, v)
}
gfile.P(microServerHttpPackage.Ident(strings.Title(pk)), `("`, strings.Join(params, `" ,"`), `"),`)
}
gfile.P(")")
}
gfile.P("return h.", serviceName, "Server.", method.GoName, "(ctx, req, rsp)") gfile.P("return h.", serviceName, "Server.", method.GoName, "(ctx, req, rsp)")
} }
gfile.P("}") gfile.P("}")
@ -271,9 +485,13 @@ func generateServiceServerMethods(gfile *protogen.GeneratedFile, service *protog
} }
} }
func generateServiceRegister(gfile *protogen.GeneratedFile, service *protogen.Service) { func (g *Generator) generateServiceRegister(gfile *protogen.GeneratedFile, file *protogen.File, service *protogen.Service, component string) {
serviceName := service.GoName serviceName := getServiceName(service)
gfile.P("func Register", serviceName, "Server(s ", microServerPackage.Ident("Server"), ", sh ", serviceName, "Server, opts ...", microServerPackage.Ident("HandlerOption"), ") error {") if g.standalone {
gfile.P("func Register", serviceName, "Server(s ", microServerPackage.Ident("Server"), ", sh ", file.GoImportPath.Ident(serviceName), "Server, opts ...", microOptionsPackage.Ident("Option"), ") error {")
} else {
gfile.P("func Register", serviceName, "Server(s ", microServerPackage.Ident("Server"), ", sh ", serviceName, "Server, opts ...", microOptionsPackage.Ident("Option"), ") error {")
}
gfile.P("type ", unexport(serviceName), " interface {") gfile.P("type ", unexport(serviceName), " interface {")
for _, method := range service.Methods { for _, method := range service.Methods {
generateServerSignature(gfile, serviceName, method, true) generateServerSignature(gfile, serviceName, method, true)
@ -283,11 +501,15 @@ func generateServiceRegister(gfile *protogen.GeneratedFile, service *protogen.Se
gfile.P(unexport(serviceName)) gfile.P(unexport(serviceName))
gfile.P("}") gfile.P("}")
gfile.P("h := &", unexport(serviceName), "Server{sh}") gfile.P("h := &", unexport(serviceName), "Server{sh}")
gfile.P("var nopts []", microServerPackage.Ident("HandlerOption")) gfile.P("var nopts []", microOptionsPackage.Ident("Option"))
gfile.P("for _, endpoint := range ", serviceName, "Endpoints {") if component == "http" {
gfile.P("nopts = append(nopts, ", microApiPackage.Ident("WithEndpoint"), "(&endpoint))") // if g.standalone {
gfile.P("}") // gfile.P("nopts = append(nopts, ", microServerHttpPackage.Ident("HandlerEndpoints"), "(", file.GoImportPath.Ident(serviceName), "ServerEndpoints))")
gfile.P("return s.Handle(s.NewHandler(&", serviceName, "{h}, append(nopts, opts...)...))") // } else {
gfile.P("nopts = append(nopts, ", microServerHttpPackage.Ident("HandlerEndpoints"), "(", serviceName, "ServerEndpoints))")
// }
}
gfile.P("return s.Handle(&", serviceName, "{h}, append(nopts, opts...)...)")
gfile.P("}") gfile.P("}")
} }
@ -335,7 +557,7 @@ func generateServerSignature(gfile *protogen.GeneratedFile, serviceName string,
gfile.P(args...) 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{}{}, args := append([]interface{}{},
"func (c *", "func (c *",
unexport(serviceName), unexport(serviceName),
@ -346,11 +568,11 @@ func generateClientFuncSignature(gfile *protogen.GeneratedFile, serviceName stri
if !method.Desc.IsStreamingClient() { if !method.Desc.IsStreamingClient() {
args = append(args, "req *", gfile.QualifiedGoIdent(method.Input.GoIdent), ", ") args = append(args, "req *", gfile.QualifiedGoIdent(method.Input.GoIdent), ", ")
} }
args = append(args, "opts ...", microClientPackage.Ident("CallOption"), ") (") args = append(args, "opts ...", microOptionsPackage.Ident("Option"), ") (")
if !method.Desc.IsStreamingClient() && !method.Desc.IsStreamingServer() { if !method.Desc.IsStreamingClient() && !method.Desc.IsStreamingServer() {
args = append(args, "*", gfile.QualifiedGoIdent(method.Output.GoIdent)) args = append(args, "*", gfile.QualifiedGoIdent(method.Output.GoIdent))
} else { } else {
args = append(args, serviceName, "_", method.GoName, "Client") args = append(args, gfile.QualifiedGoIdent(protogen.GoIdent{GoName: serviceName + "_" + method.GoName + "Client", GoImportPath: method.Output.GoIdent.GoImportPath}))
} }
args = append(args, ", error) {") args = append(args, ", error) {")
gfile.P(args...) gfile.P(args...)
@ -364,7 +586,7 @@ func generateClientSignature(gfile *protogen.GeneratedFile, serviceName string,
if !method.Desc.IsStreamingClient() { if !method.Desc.IsStreamingClient() {
args = append(args, "req *", gfile.QualifiedGoIdent(method.Input.GoIdent), ", ") args = append(args, "req *", gfile.QualifiedGoIdent(method.Input.GoIdent), ", ")
} }
args = append(args, "opts ...", microClientPackage.Ident("CallOption"), ") (") args = append(args, "opts ...", microOptionsPackage.Ident("Option"), ") (")
if !method.Desc.IsStreamingClient() && !method.Desc.IsStreamingServer() { if !method.Desc.IsStreamingClient() && !method.Desc.IsStreamingServer() {
args = append(args, "*", gfile.QualifiedGoIdent(method.Output.GoIdent)) args = append(args, "*", gfile.QualifiedGoIdent(method.Output.GoIdent))
} else { } else {
@ -374,8 +596,8 @@ func generateClientSignature(gfile *protogen.GeneratedFile, serviceName string,
gfile.P(args...) gfile.P(args...)
} }
func generateServiceClientInterface(gfile *protogen.GeneratedFile, service *protogen.Service) { func (g *Generator) generateServiceClientInterface(gfile *protogen.GeneratedFile, service *protogen.Service) {
serviceName := service.GoName serviceName := getServiceName(service)
gfile.P("type ", serviceName, "Client interface {") gfile.P("type ", serviceName, "Client interface {")
for _, method := range service.Methods { for _, method := range service.Methods {
generateClientSignature(gfile, serviceName, method) generateClientSignature(gfile, serviceName, method)
@ -384,8 +606,8 @@ func generateServiceClientInterface(gfile *protogen.GeneratedFile, service *prot
gfile.P() gfile.P()
} }
func generateServiceServerInterface(gfile *protogen.GeneratedFile, service *protogen.Service) { func (g *Generator) generateServiceServerInterface(gfile *protogen.GeneratedFile, service *protogen.Service) {
serviceName := service.GoName serviceName := getServiceName(service)
gfile.P("type ", serviceName, "Server interface {") gfile.P("type ", serviceName, "Server interface {")
for _, method := range service.Methods { for _, method := range service.Methods {
generateServerSignature(gfile, serviceName, method, false) generateServerSignature(gfile, serviceName, method, false)
@ -394,8 +616,8 @@ func generateServiceServerInterface(gfile *protogen.GeneratedFile, service *prot
gfile.P() gfile.P()
} }
func generateServiceClientStreamInterface(gfile *protogen.GeneratedFile, service *protogen.Service) { func (g *Generator) generateServiceClientStreamInterface(gfile *protogen.GeneratedFile, service *protogen.Service) {
serviceName := service.GoName serviceName := getServiceName(service)
for _, method := range service.Methods { for _, method := range service.Methods {
if !method.Desc.IsStreamingClient() && !method.Desc.IsStreamingServer() { if !method.Desc.IsStreamingClient() && !method.Desc.IsStreamingServer() {
continue continue
@ -406,10 +628,12 @@ func generateServiceClientStreamInterface(gfile *protogen.GeneratedFile, service
gfile.P("SendMsg(msg interface{}) error") gfile.P("SendMsg(msg interface{}) error")
gfile.P("RecvMsg(msg interface{}) error") gfile.P("RecvMsg(msg interface{}) error")
if method.Desc.IsStreamingClient() && !method.Desc.IsStreamingServer() { if method.Desc.IsStreamingClient() && !method.Desc.IsStreamingServer() {
gfile.P("RecvAndClose() (*", gfile.QualifiedGoIdent(method.Output.GoIdent), ", error)") gfile.P("CloseAndRecv() (*", gfile.QualifiedGoIdent(method.Output.GoIdent), ", error)")
gfile.P("CloseSend() error")
} }
gfile.P("Close() error") gfile.P("Close() error")
if method.Desc.IsStreamingClient() { if method.Desc.IsStreamingClient() {
gfile.P("Header() ", microMetadataPackage.Ident("Metadata"))
gfile.P("Send(msg *", gfile.QualifiedGoIdent(method.Input.GoIdent), ") error") gfile.P("Send(msg *", gfile.QualifiedGoIdent(method.Input.GoIdent), ") error")
} }
if method.Desc.IsStreamingServer() { if method.Desc.IsStreamingServer() {
@ -420,8 +644,8 @@ 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 serviceName := getServiceName(service)
for _, method := range service.Methods { for _, method := range service.Methods {
if !method.Desc.IsStreamingClient() && !method.Desc.IsStreamingServer() { if !method.Desc.IsStreamingClient() && !method.Desc.IsStreamingServer() {
continue continue
@ -433,6 +657,7 @@ func generateServiceServerStreamInterface(gfile *protogen.GeneratedFile, service
gfile.P("RecvMsg(msg interface{}) error") gfile.P("RecvMsg(msg interface{}) error")
if method.Desc.IsStreamingClient() && !method.Desc.IsStreamingServer() { if method.Desc.IsStreamingClient() && !method.Desc.IsStreamingServer() {
gfile.P("SendAndClose(msg *", gfile.QualifiedGoIdent(method.Output.GoIdent), ") error") gfile.P("SendAndClose(msg *", gfile.QualifiedGoIdent(method.Output.GoIdent), ") error")
// gfile.P("CloseSend() error")
} }
gfile.P("Close() error") gfile.P("Close() error")
if method.Desc.IsStreamingClient() { if method.Desc.IsStreamingClient() {
@ -446,35 +671,6 @@ func generateServiceServerStreamInterface(gfile *protogen.GeneratedFile, service
} }
} }
func 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(microApiPackage.Ident("Endpoint"), "{")
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) { func generateEndpoints(method *protogen.Method) ([]*api_options.HttpRule, bool) {
if method.Desc.Options() == nil { if method.Desc.Options() == nil {
return nil, false return nil, false
@ -579,6 +775,260 @@ func generateEndpoint(gfile *protogen.GeneratedFile, serviceName string, methodN
gfile.P("Stream: true,") gfile.P("Stream: true,")
} }
gfile.P(`Handler: "rpc",`) gfile.P(`Handler: "rpc",`)
}
return
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 (g *Generator) getMessageByXref(xref string) (*protogen.Message, 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 pmsg, err := getProtoMessage(file.Messages, msg); err == nil {
return pmsg, nil
}
}
return nil, fmt.Errorf("not found")
}
func getProtoMessage(messages []*protogen.Message, msg string) (*protogen.Message, error) {
for _, message := range messages {
if strings.Compare(msg, message.GoIdent.GoName) == 0 {
return message, nil
}
if len(message.Messages) > 0 {
if pmsg, err := getProtoMessage(message.Messages, msg); err == nil {
return pmsg, nil
}
}
}
return nil, 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")
}
func (g *Generator) generateServiceDesc(gfile *protogen.GeneratedFile, file *protogen.File, service *protogen.Service) {
serviceName := getServiceName(service)
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()
}
func (g *Generator) generateServiceName(gfile *protogen.GeneratedFile, service *protogen.Service) {
serviceName := getServiceName(service)
gfile.P("var (")
gfile.P(serviceName, "Name", "=", `"`, serviceName, `"`)
gfile.P(")")
}
func (g *Generator) generateServiceEndpoints(gfile *protogen.GeneratedFile, service *protogen.Service, component string) {
if component != "http" {
return
}
serviceName := getServiceName(service)
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(")")
}
func getServiceName(s *protogen.Service) string {
if strings.HasSuffix(s.GoName, "Service") {
return s.GoName
}
return s.GoName + "Service"
}
func (g *Generator) writeErrors(plugin *protogen.Plugin) error {
errorsMap := make(map[string]struct{})
for _, file := range plugin.Files {
for _, service := range file.Services {
for _, method := range service.Methods {
if 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 {
r := opts.(*v2.Operation)
if r.Responses == nil {
continue
}
for _, rsp := range r.Responses.ResponseCode {
if schema := rsp.Value.GetJsonReference(); schema != nil {
xref := schema.XRef
if xref[0] == '.' {
xref = xref[1:]
}
errorsMap[xref] = struct{}{}
}
}
}
}
if proto.HasExtension(method.Desc.Options(), v3.E_Openapiv3Operation) {
opts := proto.GetExtension(method.Desc.Options(), v3.E_Openapiv3Operation)
if opts != nil {
r := opts.(*v3.Operation)
if r.Responses == nil {
continue
}
resps := r.Responses.ResponseOrReference
if r.Responses.GetDefault() != nil {
resps = append(resps, &v3.NamedResponseOrReference{Name: "default", Value: r.Responses.GetDefault()})
}
for _, rsp := range resps {
if schema := rsp.Value.GetReference(); schema != nil {
xref := schema.XRef
if xref[0] == '.' {
xref = xref[1:]
}
errorsMap[xref] = struct{}{}
}
}
}
}
}
}
}
}
var gfile *protogen.GeneratedFile
var importPath protogen.GoImportPath
if len(errorsMap) > 0 {
var packageName string
for _, file := range plugin.Files {
if !file.Generate {
continue
}
if len(file.Services) == 0 {
continue
}
packageName = string(file.GoPackageName)
importPath = file.GoImportPath
break
}
if g.standalone {
importPath = "."
}
gfile = plugin.NewGeneratedFile("micro_errors.pb.go", importPath)
gfile.P("// Code generated by protoc-gen-go-micro. DO NOT EDIT.")
gfile.P("// protoc-gen-go-micro version: " + versionComment)
gfile.P()
gfile.P("package ", packageName)
gfile.P()
gfile.Import(protojsonPackage)
gfile.P("var (")
gfile.P("marshaler = ", protojsonPackage.Ident("MarshalOptions"), "{}")
gfile.P(")")
}
for xref := range errorsMap {
msg, err := g.getMessageByXref(xref)
if err != nil {
return err
}
for _, field := range msg.Fields {
if field.GoName == "Error" {
return fmt.Errorf("failed generate Error() string interface for %s message %s already have Error field", field.Location.SourceFile, msg.Desc.Name())
}
}
gfile.P(`func (m *`, msg.GoIdent.GoName, `) Error() string {`)
gfile.P(`buf, _ := marshaler.Marshal(m)`)
gfile.P("return string(buf)")
gfile.P(`}`)
// log.Printf("xref %#+v %v\n", msg.GoIdent.GoName, err)
}
return nil
} }

View File

@ -11,11 +11,17 @@ var (
gorillaMuxPackage = protogen.GoImportPath("github.com/gorilla/mux") gorillaMuxPackage = protogen.GoImportPath("github.com/gorilla/mux")
chiPackage = protogen.GoImportPath("github.com/go-chi/chi/v5") chiPackage = protogen.GoImportPath("github.com/go-chi/chi/v5")
chiMiddlewarePackage = protogen.GoImportPath("github.com/go-chi/chi/v5/middleware") chiMiddlewarePackage = protogen.GoImportPath("github.com/go-chi/chi/v5/middleware")
microApiPackage = protogen.GoImportPath("github.com/unistack-org/micro/v3/api") microMetadataPackage = protogen.GoImportPath("go.unistack.org/micro/v4/metadata")
microClientPackage = protogen.GoImportPath("github.com/unistack-org/micro/v3/client") microClientPackage = protogen.GoImportPath("go.unistack.org/micro/v4/client")
microServerPackage = protogen.GoImportPath("github.com/unistack-org/micro/v3/server") microServerPackage = protogen.GoImportPath("go.unistack.org/micro/v4/server")
microClientHttpPackage = protogen.GoImportPath("github.com/unistack-org/micro-client-http/v3") microClientHttpPackage = protogen.GoImportPath("go.unistack.org/micro-client-http/v4")
microServerHttpPackage = protogen.GoImportPath("go.unistack.org/micro-server-http/v4")
microCodecPackage = protogen.GoImportPath("go.unistack.org/micro-proto/v4/codec")
microErrorsPackage = protogen.GoImportPath("go.unistack.org/micro/v4/errors")
microOptionsPackage = protogen.GoImportPath("go.unistack.org/micro/v4/options")
grpcPackage = protogen.GoImportPath("google.golang.org/grpc")
protojsonPackage = protogen.GoImportPath("google.golang.org/protobuf/encoding/protojson")
timePackage = protogen.GoImportPath("time") timePackage = protogen.GoImportPath("time")
deprecationComment = "// Deprecated: Do not use." deprecationComment = "// Deprecated: Do not use."
versionComment = "v3.4.2" versionComment = "v4.0.2"
) )