Compare commits
160 Commits
Author | SHA1 | Date | |
---|---|---|---|
39e7d36be4 | |||
|
f79c5a382a | ||
0f3c61a8cd | |||
|
9c575e9eb9 | ||
241eb81fec | |||
|
0d2e93e1a7 | ||
b9c812fd72 | |||
|
9419c353b8 | ||
ab6c7cfd73 | |||
|
47f422206d | ||
a435d2f9ca | |||
|
be85a5e007 | ||
46c724e932 | |||
|
e67a42d47d | ||
7aecc5a1e2 | |||
|
b419d57572 | ||
|
c78234b992 | ||
|
ab855cb5d7 | ||
eb802439ba | |||
|
d2f23d8141 | ||
|
b081ad4b2d | ||
|
67315900cc | ||
01d1e72a77 | |||
|
0f37a1feb0 | ||
8bdc2f4229 | |||
|
801d579e0b | ||
8c42785186 | |||
|
e6cfaf1085 | ||
e3a664387d | |||
|
3285aca161 | ||
104995bb20 | |||
|
573fd97bc8 | ||
e9ee07599b | |||
|
462d9afa3a | ||
|
f53a391887 | ||
|
11608e29b6 | ||
0681a32ea9 | |||
|
7daf179c8e | ||
|
3214e6f923 | ||
|
f605b1b985 | ||
|
0c0fa1ba03 | ||
|
50982e4395 | ||
|
c8e5e599ae | ||
|
680d13002d | ||
|
2886304c9f | ||
ce5136690d | |||
|
a26853398a | ||
a03c9d8f74 | |||
|
6db918f045 | ||
|
4369505adf | ||
|
c66bd9e9e2 | ||
a089fd1b88 | |||
|
8d822efee3 | ||
|
cebd424e33 | ||
|
4c51aa50cc | ||
|
600419e27e | ||
|
b69c8198b3 | ||
69c1bf2770 | |||
|
624049c381 | ||
48bdae912e | |||
|
93d2dab4ca | ||
|
c7673063bc | ||
|
da804cd9a8 | ||
|
a82ee215ef | ||
622fecc215 | |||
|
691070af56 | ||
2180b54169 | |||
|
d49ba05c4b | ||
|
e766c17b87 | ||
7ea764b23c | |||
14a0f8b340 | |||
|
36b2a25a6b | ||
|
c393b0599a | ||
|
ae3f68e2c1 | ||
e35c3741d2 | |||
|
6dc7f85108 | ||
7fc1fa1e88 | |||
|
3f752b4e54 | ||
db983d88e0 | |||
|
944b6d2bc8 | ||
55b73ae3f9 | |||
|
a6e18d7f08 | ||
f25cdff909 | |||
|
e7b206b7df | ||
8bd41294b1 | |||
|
c68a1054b2 | ||
|
c2c2c115ab | ||
72fce7d617 | |||
|
d59d9b43d0 | ||
bf46017149 | |||
|
45ccde3416 | ||
|
e74ae82615 | ||
ff8668191c | |||
|
5ee80e790f | ||
4cc9a9e6ef | |||
|
858225f436 | ||
d08506e115 | |||
|
9cb8aad9b5 | ||
|
99041deb03 | ||
|
55c9d4d10b | ||
|
25b69db7ea | ||
e0e59148e0 | |||
|
e49652e11e | ||
fdfc9b852d | |||
8319e5e492 | |||
|
06648b238b | ||
|
fd9203e8d5 | ||
|
a86061b4de | ||
2f23e61a6c | |||
|
0070a60981 | ||
|
4ebbadcfac | ||
|
1cb6a3cc54 | ||
|
a65a135565 | ||
|
172f723f5e | ||
|
706a55e14f | ||
|
816eccce77 | ||
|
e592c9c14f | ||
|
05be01c203 | ||
|
26db29b52e | ||
|
f836cc86a5 | ||
|
5f19014ccd | ||
|
62261703a4 | ||
|
77a1d5df7e | ||
|
9ee22bd3a0 | ||
|
4439a534e1 | ||
|
329341f2ed | ||
|
d81ce4dcff | ||
49c6d3cf45 | |||
14a624e4d5 | |||
|
56ea269a78 | ||
|
c77e9721ef | ||
|
59b4d24f92 | ||
|
929c908711 | ||
|
f9e1ab7d04 | ||
|
c4f786e3c6 | ||
|
63dba4235f | ||
|
28f895bc92 | ||
|
8cf0d18ac9 | ||
|
ddfe70ccb8 | ||
0643409994 | |||
641ed8949a | |||
|
61d779d84d | ||
cfc442c584 | |||
|
f332f747ca | ||
270bb1d226 | |||
df5ae7f45a | |||
6b98d16022 | |||
|
ade8c4c0f8 | ||
|
566bf0f4fb | ||
72304939e6 | |||
69a2c07c54 | |||
|
f6634a93ba | ||
5bfb672b78 | |||
b7d3573ad2 | |||
932636f4d5 | |||
1bef92eefa | |||
fc9a87d827 | |||
a4e79970be | |||
e796c5aa07 | |||
aaf64c52d9 |
24
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
24
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: For reporting bugs in go-micro
|
||||||
|
title: "[BUG]"
|
||||||
|
labels: ''
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Describe the bug**
|
||||||
|
|
||||||
|
1. What are you trying to do?
|
||||||
|
2. What did you expect to happen?
|
||||||
|
3. What happens instead?
|
||||||
|
|
||||||
|
**How to reproduce the bug:**
|
||||||
|
|
||||||
|
If possible, please include a minimal code snippet here.
|
||||||
|
|
||||||
|
**Environment:**
|
||||||
|
Go Version: please paste `go version` output here
|
||||||
|
```
|
||||||
|
please paste `go env` output here
|
||||||
|
```
|
17
.github/ISSUE_TEMPLATE/feature-request---enhancement.md
vendored
Normal file
17
.github/ISSUE_TEMPLATE/feature-request---enhancement.md
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
name: Feature request / Enhancement
|
||||||
|
about: If you have a need not served by go-micro
|
||||||
|
title: "[FEATURE]"
|
||||||
|
labels: ''
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Is your feature request related to a problem? Please describe.**
|
||||||
|
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||||
|
|
||||||
|
**Describe the solution you'd like**
|
||||||
|
A clear and concise description of what you want to happen.
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context or screenshots about the feature request here.
|
14
.github/ISSUE_TEMPLATE/question.md
vendored
Normal file
14
.github/ISSUE_TEMPLATE/question.md
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
name: Question
|
||||||
|
about: Ask a question about go-micro
|
||||||
|
title: ''
|
||||||
|
labels: ''
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Before asking, please check if your question has already been answered:
|
||||||
|
|
||||||
|
1. Check the documentation - https://micro.mu/docs/
|
||||||
|
2. Check the examples and plugins - https://github.com/micro/examples & https://github.com/micro/go-plugins
|
||||||
|
3. Search existing issues
|
9
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
9
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
## Pull Request template
|
||||||
|
Please, go through these steps before clicking submit on this PR.
|
||||||
|
|
||||||
|
1. Give a descriptive title to your PR.
|
||||||
|
2. Provide a description of your changes.
|
||||||
|
3. Make sure you have some relevant tests.
|
||||||
|
4. Put `closes #XXXX` in your comment to auto-close the issue that your PR fixes (if applicable).
|
||||||
|
|
||||||
|
**PLEASE REMOVE THIS TEMPLATE BEFORE SUBMITTING**
|
19
.github/dependabot.yml
vendored
Normal file
19
.github/dependabot.yml
vendored
Normal 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/workflows/autoapprove.yml
vendored
Normal file
20
.github/workflows/autoapprove.yml
vendored
Normal 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
21
.github/workflows/automerge.yml
vendored
Normal 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}}
|
47
.github/workflows/build.yml
vendored
Normal file
47
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
name: build
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- v3
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
name: test
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: setup
|
||||||
|
uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: 1.17
|
||||||
|
- name: checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: ~/go/pkg/mod
|
||||||
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||||
|
restore-keys: ${{ runner.os }}-go-
|
||||||
|
- name: deps
|
||||||
|
run: go get -v -t -d ./...
|
||||||
|
- name: test
|
||||||
|
env:
|
||||||
|
INTEGRATION_TESTS: yes
|
||||||
|
run: go test -mod readonly -v ./...
|
||||||
|
lint:
|
||||||
|
name: lint
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: lint
|
||||||
|
uses: golangci/golangci-lint-action@v3.4.0
|
||||||
|
continue-on-error: true
|
||||||
|
with:
|
||||||
|
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
|
||||||
|
version: v1.30
|
||||||
|
# Optional: working directory, useful for monorepos
|
||||||
|
# working-directory: somedir
|
||||||
|
# Optional: golangci-lint command line arguments.
|
||||||
|
# args: --issues-exit-code=0
|
||||||
|
# Optional: show only new issues if it's a pull request. The default value is `false`.
|
||||||
|
# only-new-issues: true
|
78
.github/workflows/codeql-analysis.yml
vendored
Normal file
78
.github/workflows/codeql-analysis.yml
vendored
Normal 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
|
27
.github/workflows/dependabot-automerge.yml
vendored
Normal file
27
.github/workflows/dependabot-automerge.yml
vendored
Normal 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}}
|
47
.github/workflows/pr.yml
vendored
Normal file
47
.github/workflows/pr.yml
vendored
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
name: prbuild
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- v3
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
name: test
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: setup
|
||||||
|
uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: 1.17
|
||||||
|
- name: checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: ~/go/pkg/mod
|
||||||
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||||
|
restore-keys: ${{ runner.os }}-go-
|
||||||
|
- name: deps
|
||||||
|
run: go get -v -t -d ./...
|
||||||
|
- name: test
|
||||||
|
env:
|
||||||
|
INTEGRATION_TESTS: yes
|
||||||
|
run: go test -mod readonly -v ./...
|
||||||
|
lint:
|
||||||
|
name: lint
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: lint
|
||||||
|
uses: golangci/golangci-lint-action@v3.4.0
|
||||||
|
continue-on-error: true
|
||||||
|
with:
|
||||||
|
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
|
||||||
|
version: v1.30
|
||||||
|
# Optional: working directory, useful for monorepos
|
||||||
|
# working-directory: somedir
|
||||||
|
# Optional: golangci-lint command line arguments.
|
||||||
|
# args: --issues-exit-code=0
|
||||||
|
# Optional: show only new issues if it's a pull request. The default value is `false`.
|
||||||
|
# only-new-issues: true
|
201
LICENSE
Normal file
201
LICENSE
Normal file
@ -0,0 +1,201 @@
|
|||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright [yyyy] [name of copyright owner]
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
3
generate.go
Normal file
3
generate.go
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
package grpc
|
||||||
|
|
||||||
|
//go:generate protoc -I./proto -I. --go-grpc_out=paths=source_relative:./proto --go_out=paths=source_relative:./proto proto/transport.proto
|
9
go.mod
Normal file
9
go.mod
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
module go.unistack.org/micro-network-transport-grpc/v3
|
||||||
|
|
||||||
|
go 1.16
|
||||||
|
|
||||||
|
require (
|
||||||
|
go.unistack.org/micro/v3 v3.10.14
|
||||||
|
google.golang.org/grpc v1.52.3
|
||||||
|
google.golang.org/protobuf v1.28.1
|
||||||
|
)
|
80
grpc.go
80
grpc.go
@ -1,20 +1,16 @@
|
|||||||
// Package grpc provides a grpc transport
|
// Package grpc provides a grpc transport
|
||||||
package grpc
|
package grpc // import "go.unistack.org/micro-network-transport-grpc/v3"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/micro/go-micro/v3/network/transport"
|
pb "go.unistack.org/micro-network-transport-grpc/v3/proto"
|
||||||
maddr "github.com/micro/go-micro/v3/util/addr"
|
"go.unistack.org/micro/v3/network/transport"
|
||||||
mnet "github.com/micro/go-micro/v3/util/net"
|
mnet "go.unistack.org/micro/v3/util/net"
|
||||||
mls "github.com/micro/go-micro/v3/util/tls"
|
|
||||||
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/credentials"
|
"google.golang.org/grpc/credentials"
|
||||||
|
|
||||||
pb "github.com/micro/go-micro/v3/network/transport/grpc/proto"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type grpcTransport struct {
|
type grpcTransport struct {
|
||||||
@ -23,29 +19,8 @@ type grpcTransport struct {
|
|||||||
|
|
||||||
type grpcTransportListener struct {
|
type grpcTransportListener struct {
|
||||||
listener net.Listener
|
listener net.Listener
|
||||||
secure bool
|
|
||||||
tls *tls.Config
|
tls *tls.Config
|
||||||
}
|
opts transport.ListenOptions
|
||||||
|
|
||||||
func getTLSConfig(addr string) (*tls.Config, error) {
|
|
||||||
hosts := []string{addr}
|
|
||||||
|
|
||||||
// check if its a valid host:port
|
|
||||||
if host, _, err := net.SplitHostPort(addr); err == nil {
|
|
||||||
if len(host) == 0 {
|
|
||||||
hosts = maddr.IPs()
|
|
||||||
} else {
|
|
||||||
hosts = []string{host}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// generate a certificate
|
|
||||||
cert, err := mls.Certificate(hosts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &tls.Config{Certificates: []tls.Certificate{cert}}, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *grpcTransportListener) Addr() string {
|
func (t *grpcTransportListener) Addr() string {
|
||||||
@ -60,18 +35,8 @@ func (t *grpcTransportListener) Accept(fn func(transport.Socket)) error {
|
|||||||
var opts []grpc.ServerOption
|
var opts []grpc.ServerOption
|
||||||
|
|
||||||
// setup tls if specified
|
// setup tls if specified
|
||||||
if t.secure || t.tls != nil {
|
if t.tls != nil {
|
||||||
config := t.tls
|
creds := credentials.NewTLS(t.tls)
|
||||||
if config == nil {
|
|
||||||
var err error
|
|
||||||
addr := t.listener.Addr().String()
|
|
||||||
config, err = getTLSConfig(addr)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
creds := credentials.NewTLS(config)
|
|
||||||
opts = append(opts, grpc.Creds(creds))
|
opts = append(opts, grpc.Creds(creds))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,32 +50,20 @@ func (t *grpcTransportListener) Accept(fn func(transport.Socket)) error {
|
|||||||
return srv.Serve(t.listener)
|
return srv.Serve(t.listener)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *grpcTransport) Dial(addr string, opts ...transport.DialOption) (transport.Client, error) {
|
func (t *grpcTransport) Dial(ctx context.Context, addr string, opts ...transport.DialOption) (transport.Client, error) {
|
||||||
dopts := transport.DialOptions{
|
dopts := transport.NewDialOptions(opts...)
|
||||||
Timeout: transport.DefaultDialTimeout,
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, opt := range opts {
|
|
||||||
opt(&dopts)
|
|
||||||
}
|
|
||||||
|
|
||||||
options := []grpc.DialOption{}
|
options := []grpc.DialOption{}
|
||||||
|
|
||||||
if t.opts.Secure || t.opts.TLSConfig != nil {
|
if t.opts.TLSConfig != nil {
|
||||||
config := t.opts.TLSConfig
|
creds := credentials.NewTLS(t.opts.TLSConfig)
|
||||||
if config == nil {
|
|
||||||
config = &tls.Config{
|
|
||||||
InsecureSkipVerify: true,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
creds := credentials.NewTLS(config)
|
|
||||||
options = append(options, grpc.WithTransportCredentials(creds))
|
options = append(options, grpc.WithTransportCredentials(creds))
|
||||||
} else {
|
} else {
|
||||||
options = append(options, grpc.WithInsecure())
|
options = append(options, grpc.WithInsecure())
|
||||||
}
|
}
|
||||||
|
|
||||||
// dial the server
|
// dial the server
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), dopts.Timeout)
|
ctx, cancel := context.WithTimeout(ctx, dopts.Timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
conn, err := grpc.DialContext(ctx, addr, options...)
|
conn, err := grpc.DialContext(ctx, addr, options...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -132,11 +85,8 @@ func (t *grpcTransport) Dial(addr string, opts ...transport.DialOption) (transpo
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *grpcTransport) Listen(addr string, opts ...transport.ListenOption) (transport.Listener, error) {
|
func (t *grpcTransport) Listen(ctx context.Context, addr string, opts ...transport.ListenOption) (transport.Listener, error) {
|
||||||
var options transport.ListenOptions
|
options := transport.NewListenOptions(opts...)
|
||||||
for _, o := range opts {
|
|
||||||
o(&options)
|
|
||||||
}
|
|
||||||
|
|
||||||
ln, err := mnet.Listen(addr, func(addr string) (net.Listener, error) {
|
ln, err := mnet.Listen(addr, func(addr string) (net.Listener, error) {
|
||||||
return net.Listen("tcp", addr)
|
return net.Listen("tcp", addr)
|
||||||
@ -148,7 +98,7 @@ func (t *grpcTransport) Listen(addr string, opts ...transport.ListenOption) (tra
|
|||||||
return &grpcTransportListener{
|
return &grpcTransportListener{
|
||||||
listener: ln,
|
listener: ln,
|
||||||
tls: t.opts.TLSConfig,
|
tls: t.opts.TLSConfig,
|
||||||
secure: t.opts.Secure,
|
opts: options,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
19
grpc_test.go
19
grpc_test.go
@ -1,10 +1,11 @@
|
|||||||
package grpc
|
package grpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"net"
|
"net"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/micro/go-micro/v3/network/transport"
|
"go.unistack.org/micro/v3/network/transport"
|
||||||
)
|
)
|
||||||
|
|
||||||
func expectedPort(t *testing.T, expected string, lsn transport.Listener) {
|
func expectedPort(t *testing.T, expected string, lsn transport.Listener) {
|
||||||
@ -21,20 +22,20 @@ func expectedPort(t *testing.T, expected string, lsn transport.Listener) {
|
|||||||
|
|
||||||
func TestGRPCTransportPortRange(t *testing.T) {
|
func TestGRPCTransportPortRange(t *testing.T) {
|
||||||
tp := NewTransport()
|
tp := NewTransport()
|
||||||
|
ctx := context.TODO()
|
||||||
lsn1, err := tp.Listen(":44444-44448")
|
lsn1, err := tp.Listen(ctx, ":44444-44448")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Did not expect an error, got %s", err)
|
t.Errorf("Did not expect an error, got %s", err)
|
||||||
}
|
}
|
||||||
expectedPort(t, "44444", lsn1)
|
expectedPort(t, "44444", lsn1)
|
||||||
|
|
||||||
lsn2, err := tp.Listen(":44444-44448")
|
lsn2, err := tp.Listen(ctx, ":44444-44448")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Did not expect an error, got %s", err)
|
t.Errorf("Did not expect an error, got %s", err)
|
||||||
}
|
}
|
||||||
expectedPort(t, "44445", lsn2)
|
expectedPort(t, "44445", lsn2)
|
||||||
|
|
||||||
lsn, err := tp.Listen(":0")
|
lsn, err := tp.Listen(ctx, ":0")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Did not expect an error, got %s", err)
|
t.Errorf("Did not expect an error, got %s", err)
|
||||||
}
|
}
|
||||||
@ -46,8 +47,8 @@ func TestGRPCTransportPortRange(t *testing.T) {
|
|||||||
|
|
||||||
func TestGRPCTransportCommunication(t *testing.T) {
|
func TestGRPCTransportCommunication(t *testing.T) {
|
||||||
tr := NewTransport()
|
tr := NewTransport()
|
||||||
|
ctx := context.Background()
|
||||||
l, err := tr.Listen(":0")
|
l, err := tr.Listen(ctx, ":0")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Unexpected listen err: %v", err)
|
t.Errorf("Unexpected listen err: %v", err)
|
||||||
}
|
}
|
||||||
@ -80,9 +81,9 @@ func TestGRPCTransportCommunication(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
c, err := tr.Dial(l.Addr())
|
c, err := tr.Dial(ctx, l.Addr())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Unexpected dial err: %v", err)
|
t.Fatalf("Unexpected dial err: %v", err)
|
||||||
}
|
}
|
||||||
defer c.Close()
|
defer c.Close()
|
||||||
|
|
||||||
|
13
handler.go
13
handler.go
@ -3,21 +3,21 @@ package grpc
|
|||||||
import (
|
import (
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
|
|
||||||
"github.com/micro/go-micro/v3/errors"
|
pb "go.unistack.org/micro-network-transport-grpc/v3/proto"
|
||||||
"github.com/micro/go-micro/v3/logger"
|
"go.unistack.org/micro/v3/errors"
|
||||||
"github.com/micro/go-micro/v3/network/transport"
|
"go.unistack.org/micro/v3/logger"
|
||||||
pb "github.com/micro/go-micro/v3/network/transport/grpc/proto"
|
"go.unistack.org/micro/v3/network/transport"
|
||||||
"google.golang.org/grpc/peer"
|
"google.golang.org/grpc/peer"
|
||||||
)
|
)
|
||||||
|
|
||||||
// microTransport satisfies the pb.TransportServer inteface
|
// microTransport satisfies the pb.TransportServer inteface
|
||||||
type microTransport struct {
|
type microTransport struct {
|
||||||
|
pb.UnimplementedTransportServer
|
||||||
addr string
|
addr string
|
||||||
fn func(transport.Socket)
|
fn func(transport.Socket)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *microTransport) Stream(ts pb.Transport_StreamServer) (err error) {
|
func (m *microTransport) Stream(ts pb.Transport_StreamServer) (err error) {
|
||||||
|
|
||||||
sock := &grpcTransportSocket{
|
sock := &grpcTransportSocket{
|
||||||
stream: ts,
|
stream: ts,
|
||||||
local: m.addr,
|
local: m.addr,
|
||||||
@ -30,7 +30,8 @@ func (m *microTransport) Stream(ts pb.Transport_StreamServer) (err error) {
|
|||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
logger.Error(r, string(debug.Stack()))
|
logger.Error(ts.Context(), "panic recovered: ", r)
|
||||||
|
logger.Error(ts.Context(), string(debug.Stack()))
|
||||||
sock.Close()
|
sock.Close()
|
||||||
err = errors.InternalServerError("go.micro.transport", "panic recovered: %v", r)
|
err = errors.InternalServerError("go.micro.transport", "panic recovered: %v", r)
|
||||||
}
|
}
|
||||||
|
@ -1,211 +1,169 @@
|
|||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
// source: transport/grpc/proto/transport.proto
|
// versions:
|
||||||
|
// protoc-gen-go v1.26.0
|
||||||
|
// protoc v3.6.1
|
||||||
|
// source: transport.proto
|
||||||
|
|
||||||
package go_micro_transport_grpc
|
package transport
|
||||||
|
|
||||||
import (
|
import (
|
||||||
context "context"
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
fmt "fmt"
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
proto "github.com/golang/protobuf/proto"
|
reflect "reflect"
|
||||||
grpc "google.golang.org/grpc"
|
sync "sync"
|
||||||
codes "google.golang.org/grpc/codes"
|
|
||||||
status "google.golang.org/grpc/status"
|
|
||||||
math "math"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Reference imports to suppress errors if they are not otherwise used.
|
const (
|
||||||
var _ = proto.Marshal
|
// Verify that this generated code is sufficiently up-to-date.
|
||||||
var _ = fmt.Errorf
|
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||||
var _ = math.Inf
|
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||||
|
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||||
// This is a compile-time assertion to ensure that this generated file
|
)
|
||||||
// is compatible with the proto package it is being compiled against.
|
|
||||||
// A compilation error at this line likely means your copy of the
|
|
||||||
// proto package needs to be updated.
|
|
||||||
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
|
||||||
|
|
||||||
type Message struct {
|
type Message struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
Header map[string]string `protobuf:"bytes,1,rep,name=header,proto3" json:"header,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
Header map[string]string `protobuf:"bytes,1,rep,name=header,proto3" json:"header,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||||
Body []byte `protobuf:"bytes,2,opt,name=body,proto3" json:"body,omitempty"`
|
Body []byte `protobuf:"bytes,2,opt,name=body,proto3" json:"body,omitempty"`
|
||||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
|
||||||
XXX_unrecognized []byte `json:"-"`
|
|
||||||
XXX_sizecache int32 `json:"-"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Message) Reset() { *m = Message{} }
|
func (x *Message) Reset() {
|
||||||
func (m *Message) String() string { return proto.CompactTextString(m) }
|
*x = Message{}
|
||||||
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_transport_proto_msgTypes[0]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *Message) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
func (*Message) ProtoMessage() {}
|
func (*Message) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *Message) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_transport_proto_msgTypes[0]
|
||||||
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use Message.ProtoReflect.Descriptor instead.
|
||||||
func (*Message) Descriptor() ([]byte, []int) {
|
func (*Message) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_651718cd7c7ae974, []int{0}
|
return file_transport_proto_rawDescGZIP(), []int{0}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Message) XXX_Unmarshal(b []byte) error {
|
func (x *Message) GetHeader() map[string]string {
|
||||||
return xxx_messageInfo_Message.Unmarshal(m, b)
|
if x != nil {
|
||||||
}
|
return x.Header
|
||||||
func (m *Message) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
|
||||||
return xxx_messageInfo_Message.Marshal(b, m, deterministic)
|
|
||||||
}
|
|
||||||
func (m *Message) XXX_Merge(src proto.Message) {
|
|
||||||
xxx_messageInfo_Message.Merge(m, src)
|
|
||||||
}
|
|
||||||
func (m *Message) XXX_Size() int {
|
|
||||||
return xxx_messageInfo_Message.Size(m)
|
|
||||||
}
|
|
||||||
func (m *Message) XXX_DiscardUnknown() {
|
|
||||||
xxx_messageInfo_Message.DiscardUnknown(m)
|
|
||||||
}
|
|
||||||
|
|
||||||
var xxx_messageInfo_Message proto.InternalMessageInfo
|
|
||||||
|
|
||||||
func (m *Message) GetHeader() map[string]string {
|
|
||||||
if m != nil {
|
|
||||||
return m.Header
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Message) GetBody() []byte {
|
func (x *Message) GetBody() []byte {
|
||||||
if m != nil {
|
if x != nil {
|
||||||
return m.Body
|
return x.Body
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
var File_transport_proto protoreflect.FileDescriptor
|
||||||
proto.RegisterType((*Message)(nil), "go.micro.transport.grpc.Message")
|
|
||||||
proto.RegisterMapType((map[string]string)(nil), "go.micro.transport.grpc.Message.HeaderEntry")
|
var file_transport_proto_rawDesc = []byte{
|
||||||
|
0x0a, 0x0f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||||
|
0x6f, 0x12, 0x09, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x22, 0x90, 0x01, 0x0a,
|
||||||
|
0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x36, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64,
|
||||||
|
0x65, 0x72, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73,
|
||||||
|
0x70, 0x6f, 0x72, 0x74, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x48, 0x65, 0x61,
|
||||||
|
0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72,
|
||||||
|
0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04,
|
||||||
|
0x62, 0x6f, 0x64, 0x79, 0x1a, 0x39, 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e,
|
||||||
|
0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
|
||||||
|
0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02,
|
||||||
|
0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x32,
|
||||||
|
0x43, 0x0a, 0x09, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x36, 0x0a, 0x06,
|
||||||
|
0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x12, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f,
|
||||||
|
0x72, 0x74, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x12, 0x2e, 0x74, 0x72, 0x61,
|
||||||
|
0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x00,
|
||||||
|
0x28, 0x01, 0x30, 0x01, 0x42, 0x49, 0x5a, 0x47, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63,
|
||||||
|
0x6f, 0x6d, 0x2f, 0x75, 0x6e, 0x69, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x2d, 0x6f, 0x72, 0x67, 0x2f,
|
||||||
|
0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2d, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2d, 0x74, 0x72,
|
||||||
|
0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2d, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x76, 0x33, 0x2f,
|
||||||
|
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x62,
|
||||||
|
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
var (
|
||||||
proto.RegisterFile("transport/grpc/proto/transport.proto", fileDescriptor_651718cd7c7ae974)
|
file_transport_proto_rawDescOnce sync.Once
|
||||||
|
file_transport_proto_rawDescData = file_transport_proto_rawDesc
|
||||||
|
)
|
||||||
|
|
||||||
|
func file_transport_proto_rawDescGZIP() []byte {
|
||||||
|
file_transport_proto_rawDescOnce.Do(func() {
|
||||||
|
file_transport_proto_rawDescData = protoimpl.X.CompressGZIP(file_transport_proto_rawDescData)
|
||||||
|
})
|
||||||
|
return file_transport_proto_rawDescData
|
||||||
}
|
}
|
||||||
|
|
||||||
var fileDescriptor_651718cd7c7ae974 = []byte{
|
var file_transport_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||||
// 209 bytes of a gzipped FileDescriptorProto
|
var file_transport_proto_goTypes = []interface{}{
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x29, 0x29, 0x4a, 0xcc,
|
(*Message)(nil), // 0: transport.Message
|
||||||
0x2b, 0x2e, 0xc8, 0x2f, 0x2a, 0xd1, 0x4f, 0x2f, 0x2a, 0x48, 0xd6, 0x2f, 0x28, 0xca, 0x2f, 0xc9,
|
nil, // 1: transport.Message.HeaderEntry
|
||||||
0xd7, 0x87, 0x0b, 0xea, 0x81, 0xf9, 0x42, 0xe2, 0xe9, 0xf9, 0x7a, 0xb9, 0x99, 0xc9, 0x45, 0xf9,
|
}
|
||||||
0x7a, 0x08, 0x19, 0x90, 0x72, 0xa5, 0x79, 0x8c, 0x5c, 0xec, 0xbe, 0xa9, 0xc5, 0xc5, 0x89, 0xe9,
|
var file_transport_proto_depIdxs = []int32{
|
||||||
0xa9, 0x42, 0x2e, 0x5c, 0x6c, 0x19, 0xa9, 0x89, 0x29, 0xa9, 0x45, 0x12, 0x8c, 0x0a, 0xcc, 0x1a,
|
1, // 0: transport.Message.header:type_name -> transport.Message.HeaderEntry
|
||||||
0xdc, 0x46, 0x3a, 0x7a, 0x38, 0x74, 0xe9, 0x41, 0x75, 0xe8, 0x79, 0x80, 0x95, 0xbb, 0xe6, 0x95,
|
0, // 1: transport.Transport.Stream:input_type -> transport.Message
|
||||||
0x14, 0x55, 0x06, 0x41, 0xf5, 0x0a, 0x09, 0x71, 0xb1, 0x24, 0xe5, 0xa7, 0x54, 0x4a, 0x30, 0x29,
|
0, // 2: transport.Transport.Stream:output_type -> transport.Message
|
||||||
0x30, 0x6a, 0xf0, 0x04, 0x81, 0xd9, 0x52, 0x96, 0x5c, 0xdc, 0x48, 0x4a, 0x85, 0x04, 0xb8, 0x98,
|
2, // [2:3] is the sub-list for method output_type
|
||||||
0xb3, 0x53, 0x2b, 0x25, 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0x40, 0x4c, 0x21, 0x11, 0x2e, 0xd6,
|
1, // [1:2] is the sub-list for method input_type
|
||||||
0xb2, 0xc4, 0x9c, 0xd2, 0x54, 0xb0, 0x2e, 0xce, 0x20, 0x08, 0xc7, 0x8a, 0xc9, 0x82, 0xd1, 0x28,
|
1, // [1:1] is the sub-list for extension type_name
|
||||||
0x9e, 0x8b, 0x33, 0x04, 0x66, 0xb9, 0x50, 0x10, 0x17, 0x5b, 0x70, 0x49, 0x51, 0x6a, 0x62, 0xae,
|
1, // [1:1] is the sub-list for extension extendee
|
||||||
0x90, 0x02, 0x21, 0xb7, 0x49, 0x11, 0x54, 0xa1, 0xc4, 0xa0, 0xc1, 0x68, 0xc0, 0x98, 0xc4, 0x06,
|
0, // [0:1] is the sub-list for field type_name
|
||||||
0x0e, 0x21, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd4, 0xd0, 0x4b, 0x4b, 0x49, 0x01, 0x00,
|
|
||||||
0x00,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reference imports to suppress errors if they are not otherwise used.
|
func init() { file_transport_proto_init() }
|
||||||
var _ context.Context
|
func file_transport_proto_init() {
|
||||||
var _ grpc.ClientConn
|
if File_transport_proto != nil {
|
||||||
|
return
|
||||||
// This is a compile-time assertion to ensure that this generated file
|
|
||||||
// is compatible with the grpc package it is being compiled against.
|
|
||||||
const _ = grpc.SupportPackageIsVersion4
|
|
||||||
|
|
||||||
// TransportClient is the client API for Transport service.
|
|
||||||
//
|
|
||||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
|
|
||||||
type TransportClient interface {
|
|
||||||
Stream(ctx context.Context, opts ...grpc.CallOption) (Transport_StreamClient, error)
|
|
||||||
}
|
}
|
||||||
|
if !protoimpl.UnsafeEnabled {
|
||||||
type transportClient struct {
|
file_transport_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||||
cc *grpc.ClientConn
|
switch v := v.(*Message); i {
|
||||||
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTransportClient(cc *grpc.ClientConn) TransportClient {
|
|
||||||
return &transportClient{cc}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *transportClient) Stream(ctx context.Context, opts ...grpc.CallOption) (Transport_StreamClient, error) {
|
|
||||||
stream, err := c.cc.NewStream(ctx, &_Transport_serviceDesc.Streams[0], "/go.micro.transport.grpc.Transport/Stream", opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
}
|
||||||
x := &transportStreamClient{stream}
|
type x struct{}
|
||||||
return x, nil
|
out := protoimpl.TypeBuilder{
|
||||||
}
|
File: protoimpl.DescBuilder{
|
||||||
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
type Transport_StreamClient interface {
|
RawDescriptor: file_transport_proto_rawDesc,
|
||||||
Send(*Message) error
|
NumEnums: 0,
|
||||||
Recv() (*Message, error)
|
NumMessages: 2,
|
||||||
grpc.ClientStream
|
NumExtensions: 0,
|
||||||
}
|
NumServices: 1,
|
||||||
|
|
||||||
type transportStreamClient struct {
|
|
||||||
grpc.ClientStream
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *transportStreamClient) Send(m *Message) error {
|
|
||||||
return x.ClientStream.SendMsg(m)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *transportStreamClient) Recv() (*Message, error) {
|
|
||||||
m := new(Message)
|
|
||||||
if err := x.ClientStream.RecvMsg(m); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return m, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// TransportServer is the server API for Transport service.
|
|
||||||
type TransportServer interface {
|
|
||||||
Stream(Transport_StreamServer) error
|
|
||||||
}
|
|
||||||
|
|
||||||
// UnimplementedTransportServer can be embedded to have forward compatible implementations.
|
|
||||||
type UnimplementedTransportServer struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*UnimplementedTransportServer) Stream(srv Transport_StreamServer) error {
|
|
||||||
return status.Errorf(codes.Unimplemented, "method Stream not implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
func RegisterTransportServer(s *grpc.Server, srv TransportServer) {
|
|
||||||
s.RegisterService(&_Transport_serviceDesc, srv)
|
|
||||||
}
|
|
||||||
|
|
||||||
func _Transport_Stream_Handler(srv interface{}, stream grpc.ServerStream) error {
|
|
||||||
return srv.(TransportServer).Stream(&transportStreamServer{stream})
|
|
||||||
}
|
|
||||||
|
|
||||||
type Transport_StreamServer interface {
|
|
||||||
Send(*Message) error
|
|
||||||
Recv() (*Message, error)
|
|
||||||
grpc.ServerStream
|
|
||||||
}
|
|
||||||
|
|
||||||
type transportStreamServer struct {
|
|
||||||
grpc.ServerStream
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *transportStreamServer) Send(m *Message) error {
|
|
||||||
return x.ServerStream.SendMsg(m)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *transportStreamServer) Recv() (*Message, error) {
|
|
||||||
m := new(Message)
|
|
||||||
if err := x.ServerStream.RecvMsg(m); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return m, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
var _Transport_serviceDesc = grpc.ServiceDesc{
|
|
||||||
ServiceName: "go.micro.transport.grpc.Transport",
|
|
||||||
HandlerType: (*TransportServer)(nil),
|
|
||||||
Methods: []grpc.MethodDesc{},
|
|
||||||
Streams: []grpc.StreamDesc{
|
|
||||||
{
|
|
||||||
StreamName: "Stream",
|
|
||||||
Handler: _Transport_Stream_Handler,
|
|
||||||
ServerStreams: true,
|
|
||||||
ClientStreams: true,
|
|
||||||
},
|
},
|
||||||
},
|
GoTypes: file_transport_proto_goTypes,
|
||||||
Metadata: "transport/grpc/proto/transport.proto",
|
DependencyIndexes: file_transport_proto_depIdxs,
|
||||||
|
MessageInfos: file_transport_proto_msgTypes,
|
||||||
|
}.Build()
|
||||||
|
File_transport_proto = out.File
|
||||||
|
file_transport_proto_rawDesc = nil
|
||||||
|
file_transport_proto_goTypes = nil
|
||||||
|
file_transport_proto_depIdxs = nil
|
||||||
}
|
}
|
||||||
|
@ -1,175 +0,0 @@
|
|||||||
// Code generated by protoc-gen-micro. DO NOT EDIT.
|
|
||||||
// source: transport/grpc/proto/transport.proto
|
|
||||||
|
|
||||||
package go_micro_transport_grpc
|
|
||||||
|
|
||||||
import (
|
|
||||||
fmt "fmt"
|
|
||||||
proto "github.com/golang/protobuf/proto"
|
|
||||||
math "math"
|
|
||||||
)
|
|
||||||
|
|
||||||
import (
|
|
||||||
context "context"
|
|
||||||
api "github.com/micro/go-micro/v3/api"
|
|
||||||
client "github.com/micro/go-micro/v3/client"
|
|
||||||
server "github.com/micro/go-micro/v3/server"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Reference imports to suppress errors if they are not otherwise used.
|
|
||||||
var _ = proto.Marshal
|
|
||||||
var _ = fmt.Errorf
|
|
||||||
var _ = math.Inf
|
|
||||||
|
|
||||||
// This is a compile-time assertion to ensure that this generated file
|
|
||||||
// is compatible with the proto package it is being compiled against.
|
|
||||||
// A compilation error at this line likely means your copy of the
|
|
||||||
// proto package needs to be updated.
|
|
||||||
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
|
||||||
|
|
||||||
// Reference imports to suppress errors if they are not otherwise used.
|
|
||||||
var _ api.Endpoint
|
|
||||||
var _ context.Context
|
|
||||||
var _ client.Option
|
|
||||||
var _ server.Option
|
|
||||||
|
|
||||||
// Api Endpoints for Transport service
|
|
||||||
|
|
||||||
func NewTransportEndpoints() []*api.Endpoint {
|
|
||||||
return []*api.Endpoint{}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Client API for Transport service
|
|
||||||
|
|
||||||
type TransportService interface {
|
|
||||||
Stream(ctx context.Context, opts ...client.CallOption) (Transport_StreamService, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type transportService struct {
|
|
||||||
c client.Client
|
|
||||||
name string
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewTransportService(name string, c client.Client) TransportService {
|
|
||||||
return &transportService{
|
|
||||||
c: c,
|
|
||||||
name: name,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *transportService) Stream(ctx context.Context, opts ...client.CallOption) (Transport_StreamService, error) {
|
|
||||||
req := c.c.NewRequest(c.name, "Transport.Stream", &Message{})
|
|
||||||
stream, err := c.c.Stream(ctx, req, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &transportServiceStream{stream}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type Transport_StreamService interface {
|
|
||||||
Context() context.Context
|
|
||||||
SendMsg(interface{}) error
|
|
||||||
RecvMsg(interface{}) error
|
|
||||||
Close() error
|
|
||||||
Send(*Message) error
|
|
||||||
Recv() (*Message, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type transportServiceStream struct {
|
|
||||||
stream client.Stream
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *transportServiceStream) Close() error {
|
|
||||||
return x.stream.Close()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *transportServiceStream) Context() context.Context {
|
|
||||||
return x.stream.Context()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *transportServiceStream) SendMsg(m interface{}) error {
|
|
||||||
return x.stream.Send(m)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *transportServiceStream) RecvMsg(m interface{}) error {
|
|
||||||
return x.stream.Recv(m)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *transportServiceStream) Send(m *Message) error {
|
|
||||||
return x.stream.Send(m)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *transportServiceStream) Recv() (*Message, error) {
|
|
||||||
m := new(Message)
|
|
||||||
err := x.stream.Recv(m)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return m, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Server API for Transport service
|
|
||||||
|
|
||||||
type TransportHandler interface {
|
|
||||||
Stream(context.Context, Transport_StreamStream) error
|
|
||||||
}
|
|
||||||
|
|
||||||
func RegisterTransportHandler(s server.Server, hdlr TransportHandler, opts ...server.HandlerOption) error {
|
|
||||||
type transport interface {
|
|
||||||
Stream(ctx context.Context, stream server.Stream) error
|
|
||||||
}
|
|
||||||
type Transport struct {
|
|
||||||
transport
|
|
||||||
}
|
|
||||||
h := &transportHandler{hdlr}
|
|
||||||
return s.Handle(s.NewHandler(&Transport{h}, opts...))
|
|
||||||
}
|
|
||||||
|
|
||||||
type transportHandler struct {
|
|
||||||
TransportHandler
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *transportHandler) Stream(ctx context.Context, stream server.Stream) error {
|
|
||||||
return h.TransportHandler.Stream(ctx, &transportStreamStream{stream})
|
|
||||||
}
|
|
||||||
|
|
||||||
type Transport_StreamStream interface {
|
|
||||||
Context() context.Context
|
|
||||||
SendMsg(interface{}) error
|
|
||||||
RecvMsg(interface{}) error
|
|
||||||
Close() error
|
|
||||||
Send(*Message) error
|
|
||||||
Recv() (*Message, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type transportStreamStream struct {
|
|
||||||
stream server.Stream
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *transportStreamStream) Close() error {
|
|
||||||
return x.stream.Close()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *transportStreamStream) Context() context.Context {
|
|
||||||
return x.stream.Context()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *transportStreamStream) SendMsg(m interface{}) error {
|
|
||||||
return x.stream.Send(m)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *transportStreamStream) RecvMsg(m interface{}) error {
|
|
||||||
return x.stream.Recv(m)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *transportStreamStream) Send(m *Message) error {
|
|
||||||
return x.stream.Send(m)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *transportStreamStream) Recv() (*Message, error) {
|
|
||||||
m := new(Message)
|
|
||||||
if err := x.stream.Recv(m); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return m, nil
|
|
||||||
}
|
|
@ -1,6 +1,7 @@
|
|||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
|
|
||||||
package go.micro.transport.grpc;
|
package transport;
|
||||||
|
option go_package = "github.com/unistack-org/micro-network-transport-grpc/v3/proto;transport";
|
||||||
|
|
||||||
service Transport {
|
service Transport {
|
||||||
rpc Stream(stream Message) returns (stream Message) {}
|
rpc Stream(stream Message) returns (stream Message) {}
|
||||||
|
133
proto/transport_grpc.pb.go
Normal file
133
proto/transport_grpc.pb.go
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||||
|
|
||||||
|
package transport
|
||||||
|
|
||||||
|
import (
|
||||||
|
context "context"
|
||||||
|
grpc "google.golang.org/grpc"
|
||||||
|
codes "google.golang.org/grpc/codes"
|
||||||
|
status "google.golang.org/grpc/status"
|
||||||
|
)
|
||||||
|
|
||||||
|
// This is a compile-time assertion to ensure that this generated file
|
||||||
|
// is compatible with the grpc package it is being compiled against.
|
||||||
|
// Requires gRPC-Go v1.32.0 or later.
|
||||||
|
const _ = grpc.SupportPackageIsVersion7
|
||||||
|
|
||||||
|
// TransportClient is the client API for Transport service.
|
||||||
|
//
|
||||||
|
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||||
|
type TransportClient interface {
|
||||||
|
Stream(ctx context.Context, opts ...grpc.CallOption) (Transport_StreamClient, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type transportClient struct {
|
||||||
|
cc grpc.ClientConnInterface
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewTransportClient(cc grpc.ClientConnInterface) TransportClient {
|
||||||
|
return &transportClient{cc}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *transportClient) Stream(ctx context.Context, opts ...grpc.CallOption) (Transport_StreamClient, error) {
|
||||||
|
stream, err := c.cc.NewStream(ctx, &Transport_ServiceDesc.Streams[0], "/transport.Transport/Stream", opts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
x := &transportStreamClient{stream}
|
||||||
|
return x, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type Transport_StreamClient interface {
|
||||||
|
Send(*Message) error
|
||||||
|
Recv() (*Message, error)
|
||||||
|
grpc.ClientStream
|
||||||
|
}
|
||||||
|
|
||||||
|
type transportStreamClient struct {
|
||||||
|
grpc.ClientStream
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *transportStreamClient) Send(m *Message) error {
|
||||||
|
return x.ClientStream.SendMsg(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *transportStreamClient) Recv() (*Message, error) {
|
||||||
|
m := new(Message)
|
||||||
|
if err := x.ClientStream.RecvMsg(m); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// TransportServer is the server API for Transport service.
|
||||||
|
// All implementations must embed UnimplementedTransportServer
|
||||||
|
// for forward compatibility
|
||||||
|
type TransportServer interface {
|
||||||
|
Stream(Transport_StreamServer) error
|
||||||
|
mustEmbedUnimplementedTransportServer()
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnimplementedTransportServer must be embedded to have forward compatible implementations.
|
||||||
|
type UnimplementedTransportServer struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (UnimplementedTransportServer) Stream(Transport_StreamServer) error {
|
||||||
|
return status.Errorf(codes.Unimplemented, "method Stream not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedTransportServer) mustEmbedUnimplementedTransportServer() {}
|
||||||
|
|
||||||
|
// UnsafeTransportServer may be embedded to opt out of forward compatibility for this service.
|
||||||
|
// Use of this interface is not recommended, as added methods to TransportServer will
|
||||||
|
// result in compilation errors.
|
||||||
|
type UnsafeTransportServer interface {
|
||||||
|
mustEmbedUnimplementedTransportServer()
|
||||||
|
}
|
||||||
|
|
||||||
|
func RegisterTransportServer(s grpc.ServiceRegistrar, srv TransportServer) {
|
||||||
|
s.RegisterService(&Transport_ServiceDesc, srv)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _Transport_Stream_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||||
|
return srv.(TransportServer).Stream(&transportStreamServer{stream})
|
||||||
|
}
|
||||||
|
|
||||||
|
type Transport_StreamServer interface {
|
||||||
|
Send(*Message) error
|
||||||
|
Recv() (*Message, error)
|
||||||
|
grpc.ServerStream
|
||||||
|
}
|
||||||
|
|
||||||
|
type transportStreamServer struct {
|
||||||
|
grpc.ServerStream
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *transportStreamServer) Send(m *Message) error {
|
||||||
|
return x.ServerStream.SendMsg(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *transportStreamServer) Recv() (*Message, error) {
|
||||||
|
m := new(Message)
|
||||||
|
if err := x.ServerStream.RecvMsg(m); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transport_ServiceDesc is the grpc.ServiceDesc for Transport service.
|
||||||
|
// It's only intended for direct use with grpc.RegisterService,
|
||||||
|
// and not to be introspected or modified (even as a copy)
|
||||||
|
var Transport_ServiceDesc = grpc.ServiceDesc{
|
||||||
|
ServiceName: "transport.Transport",
|
||||||
|
HandlerType: (*TransportServer)(nil),
|
||||||
|
Methods: []grpc.MethodDesc{},
|
||||||
|
Streams: []grpc.StreamDesc{
|
||||||
|
{
|
||||||
|
StreamName: "Stream",
|
||||||
|
Handler: _Transport_Stream_Handler,
|
||||||
|
ServerStreams: true,
|
||||||
|
ClientStreams: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Metadata: "transport.proto",
|
||||||
|
}
|
@ -1,8 +1,8 @@
|
|||||||
package grpc
|
package grpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/micro/go-micro/v3/network/transport"
|
pb "go.unistack.org/micro-network-transport-grpc/v3/proto"
|
||||||
pb "github.com/micro/go-micro/v3/network/transport/grpc/proto"
|
"go.unistack.org/micro/v3/network/transport"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user