Compare commits
166 Commits
Author | SHA1 | Date | |
---|---|---|---|
8110e3eca0 | |||
|
f5431602e6 | ||
2ee753ce9c | |||
|
7a8e486002 | ||
0e275e896c | |||
|
c314697513 | ||
d6e9837613 | |||
|
72d31b0c22 | ||
eb3f47f273 | |||
|
db0ef25162 | ||
c977d4e88a | |||
|
8ea50f09f8 | ||
7ad0e1fb5f | |||
|
5c743ac765 | ||
|
0895c16e9e | ||
0dce09bbc1 | |||
|
04835e738a | ||
|
47e41da89a | ||
7d6611040d | |||
|
03f104982b | ||
a89bab9769 | |||
|
33c27cdb76 | ||
c59d8bee0e | |||
|
3426ab340f | ||
80637a6f1a | |||
|
b5956a4d80 | ||
da34467802 | |||
|
6c44288ca1 | ||
8080c4c7e5 | |||
|
e40127a2d6 | ||
|
a146546591 | ||
6e69c34e7e | |||
|
d025221beb | ||
|
a4dc440c1b | ||
|
998e718f26 | ||
|
2c6b735306 | ||
|
32b86bfcc6 | ||
770a93f53b | |||
|
9248fa2aa9 | ||
46e5f466ad | |||
|
6511d2111e | ||
|
033a950af4 | ||
d22bab4341 | |||
|
3e828b370e | ||
|
763bd5cd19 | ||
|
fc299d215b | ||
|
87f2a381a1 | ||
660486b10c | |||
|
e177ad8b0f | ||
7814e3925c | |||
|
c9e255ec85 | ||
e8d7203f5c | |||
|
ec4e26669f | ||
|
65caeba527 | ||
8fb534f565 | |||
|
1dda5d2190 | ||
083b0b48f3 | |||
|
5d3ed5d836 | ||
408733564e | |||
6427876723 | |||
|
0c22fdea49 | ||
|
a3d8297684 | ||
d46c84c502 | |||
|
dcd8270e6e | ||
5cd0347e90 | |||
|
f109335e48 | ||
d6afc30b2d | |||
|
6487527f43 | ||
56a8f7ce08 | |||
|
766e7466c2 | ||
e8550c076f | |||
|
ad3b1b5b1e | ||
fb7e40caa3 | |||
|
684a9f3978 | ||
d40ee20fe0 | |||
|
a6778f2031 | ||
da17e70e2c | |||
|
56d8347698 | ||
beb0dacdc2 | |||
|
692b2cabde | ||
8be2d3d735 | |||
|
cf4028bc02 | ||
ebb08d9163 | |||
|
6b0ecc935d | ||
|
ecd2b885ed | ||
|
ce4563214a | ||
|
76942cd850 | ||
f9663788d7 | |||
|
b63e4317f4 | ||
afb1f3f605 | |||
178a225e48 | |||
4b4ccd9c0a | |||
|
8755d9cec9 | ||
|
65b1b8355d | ||
|
3a4b62af6f | ||
|
afa9b4a0b2 | ||
|
79b27506f6 | ||
|
483fa44f10 | ||
|
7160f03141 | ||
|
d9562f5d17 | ||
|
a03bbacc11 | ||
|
9d189012c9 | ||
|
fcd95481e1 | ||
|
e487b9116b | ||
|
947fafe789 | ||
|
209aed7408 | ||
|
8e31a12336 | ||
|
1de9e45197 | ||
|
ffa4d138f1 | ||
|
755b5f3fe7 | ||
|
64aecfe459 | ||
|
b428a372c1 | ||
|
2306203947 | ||
|
ede88f07d8 | ||
|
924093b09f | ||
|
d1b9e38542 | ||
|
52b88b8d2d | ||
|
c5175e135a | ||
|
8f21c67ad4 | ||
|
e711caa512 | ||
|
b9caafd52a | ||
|
4af16c4513 | ||
|
6e3fab8254 | ||
|
c758382594 | ||
|
635ec3c6f3 | ||
|
3b72f6dbef | ||
|
993fbaf547 | ||
|
0a7091f2e4 | ||
|
b117da3e1f | ||
|
b84e323701 | ||
|
98e114d765 | ||
|
2e1259f911 | ||
|
e5d19a6f00 | ||
|
8f0d21f27a | ||
|
b9e9d2056d | ||
|
e03f148d4c | ||
|
fac54c87a9 | ||
|
45be43bb46 | ||
|
dc4aea649a | ||
|
7b0026a5dd | ||
|
955eb13410 | ||
|
6b406d9802 | ||
|
2a76506cee | ||
|
59740f4862 | ||
|
c04fc8b726 | ||
|
0378376c68 | ||
|
a327b236c5 | ||
9d414c0fb0 | |||
2a4db2e332 | |||
|
594923b6bf | ||
ef8d92366b | |||
|
3452c17b14 | ||
|
67596e0c9c | ||
469bcba7e0 | |||
2459caec45 | |||
170eec7d1b | |||
|
65d8d09b7f | ||
|
1b92bb9906 | ||
8fd5c99f6a | |||
6f5ebe9f3d | |||
|
4ff823104d | ||
fa4476f965 | |||
9233924315 | |||
f4ab3cbb40 | |||
bf27264d70 | |||
5a602b5818 |
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.
|
8
go.mod
Normal file
8
go.mod
Normal file
@ -0,0 +1,8 @@
|
||||
module go.unistack.org/micro-network-transport-http/v3
|
||||
|
||||
go 1.16
|
||||
|
||||
require (
|
||||
go.unistack.org/micro/v3 v3.10.14
|
||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f
|
||||
)
|
16
go.sum
Normal file
16
go.sum
Normal file
@ -0,0 +1,16 @@
|
||||
github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg=
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
|
||||
github.com/silas/dag v0.0.0-20211117232152-9d50aa809f35/go.mod h1:7RTUFBdIRC9nZ7/3RyRNH1bdqIShrDejd1YbLwgPS+I=
|
||||
go.unistack.org/micro/v3 v3.10.14 h1:7fgLpwGlCN67twhwtngJDEQvrMkUBDSA5vzZqxIDqNE=
|
||||
go.unistack.org/micro/v3 v3.10.14/go.mod h1:uMAc0U/x7dmtICCrblGf0ZLgYegu3VwQAquu+OFCw1Q=
|
||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3KG69V2UGQWPBxujDmc=
|
||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
76
http.go
76
http.go
@ -1,8 +1,9 @@
|
||||
package http
|
||||
package http // import "go.unistack.org/micro-network-transport-http/v3"
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"io"
|
||||
@ -13,11 +14,9 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/micro/go-micro/v3/network/transport"
|
||||
maddr "github.com/micro/go-micro/v3/util/addr"
|
||||
"github.com/micro/go-micro/v3/util/buf"
|
||||
mnet "github.com/micro/go-micro/v3/util/net"
|
||||
mls "github.com/micro/go-micro/v3/util/tls"
|
||||
"go.unistack.org/micro/v3/network/transport"
|
||||
"go.unistack.org/micro/v3/util/buf"
|
||||
mnet "go.unistack.org/micro/v3/util/net"
|
||||
"golang.org/x/net/http2"
|
||||
"golang.org/x/net/http2/h2c"
|
||||
)
|
||||
@ -469,7 +468,7 @@ func (h *httpTransportListener) Accept(fn func(transport.Socket)) error {
|
||||
}
|
||||
|
||||
// insecure connection use h2c
|
||||
if !(h.ht.opts.Secure || h.ht.opts.TLSConfig != nil) {
|
||||
if h.ht.opts.TLSConfig == nil {
|
||||
srv.Handler = h2c.NewHandler(mux, &http2.Server{})
|
||||
}
|
||||
|
||||
@ -477,20 +476,14 @@ func (h *httpTransportListener) Accept(fn func(transport.Socket)) error {
|
||||
return srv.Serve(h.listener)
|
||||
}
|
||||
|
||||
func (h *httpTransport) Dial(addr string, opts ...transport.DialOption) (transport.Client, error) {
|
||||
dopts := transport.DialOptions{
|
||||
Timeout: transport.DefaultDialTimeout,
|
||||
}
|
||||
|
||||
for _, opt := range opts {
|
||||
opt(&dopts)
|
||||
}
|
||||
|
||||
func (h *httpTransport) Dial(ctx context.Context, addr string, opts ...transport.DialOption) (transport.Client, error) {
|
||||
var conn net.Conn
|
||||
var err error
|
||||
|
||||
dopts := transport.NewDialOptions(opts...)
|
||||
|
||||
// TODO: support dial option here rather than using internal config
|
||||
if h.opts.Secure || h.opts.TLSConfig != nil {
|
||||
if h.opts.TLSConfig != nil {
|
||||
config := h.opts.TLSConfig
|
||||
if config == nil {
|
||||
config = &tls.Config{
|
||||
@ -503,7 +496,7 @@ func (h *httpTransport) Dial(addr string, opts ...transport.DialOption) (transpo
|
||||
})(addr)
|
||||
} else {
|
||||
conn, err = newConn(func(addr string) (net.Conn, error) {
|
||||
return net.DialTimeout("tcp", addr, dopts.Timeout)
|
||||
return (&net.Dialer{Timeout: dopts.Timeout}).DialContext(ctx, "tcp", addr)
|
||||
})(addr)
|
||||
}
|
||||
|
||||
@ -523,40 +516,17 @@ func (h *httpTransport) Dial(addr string, opts ...transport.DialOption) (transpo
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (h *httpTransport) Listen(addr string, opts ...transport.ListenOption) (transport.Listener, error) {
|
||||
var options transport.ListenOptions
|
||||
for _, o := range opts {
|
||||
o(&options)
|
||||
}
|
||||
|
||||
func (h *httpTransport) Listen(ctx context.Context, addr string, opts ...transport.ListenOption) (transport.Listener, error) {
|
||||
var l net.Listener
|
||||
var err error
|
||||
|
||||
options := transport.NewListenOptions(opts...)
|
||||
_ = options
|
||||
|
||||
// TODO: support use of listen options
|
||||
if h.opts.Secure || h.opts.TLSConfig != nil {
|
||||
config := h.opts.TLSConfig
|
||||
|
||||
if h.opts.TLSConfig != nil {
|
||||
fn := func(addr string) (net.Listener, error) {
|
||||
if config == nil {
|
||||
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
|
||||
}
|
||||
config = &tls.Config{Certificates: []tls.Certificate{cert}}
|
||||
}
|
||||
return tls.Listen("tcp", addr, config)
|
||||
return tls.Listen("tcp", addr, h.opts.TLSConfig)
|
||||
}
|
||||
|
||||
l, err = mnet.Listen(addr, fn)
|
||||
@ -593,10 +563,10 @@ func (h *httpTransport) String() string {
|
||||
return "http"
|
||||
}
|
||||
|
||||
func NewTransport(opts ...transport.Option) transport.Transport {
|
||||
var options transport.Options
|
||||
for _, o := range opts {
|
||||
o(&options)
|
||||
}
|
||||
return &httpTransport{opts: options}
|
||||
func (h *httpTransport) Name() string {
|
||||
return h.opts.Name
|
||||
}
|
||||
|
||||
func NewTransport(opts ...transport.Option) transport.Transport {
|
||||
return &httpTransport{opts: transport.NewOptions(opts...)}
|
||||
}
|
||||
|
10
http_test.go
10
http_test.go
@ -1,19 +1,21 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/micro/go-micro/v3/network/transport"
|
||||
"go.unistack.org/micro/v3/network/transport"
|
||||
)
|
||||
|
||||
func call(b *testing.B, c int) {
|
||||
b.StopTimer()
|
||||
|
||||
ctx := context.Background()
|
||||
tr := NewTransport()
|
||||
|
||||
// server listen
|
||||
l, err := tr.Listen("localhost:0")
|
||||
l, err := tr.Listen(ctx, "localhost:0")
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
@ -56,7 +58,7 @@ func call(b *testing.B, c int) {
|
||||
}
|
||||
|
||||
// client connection
|
||||
client, err := tr.Dial(l.Addr())
|
||||
client, err := tr.Dial(ctx, l.Addr())
|
||||
if err != nil {
|
||||
b.Fatalf("Unexpected dial err: %v", err)
|
||||
}
|
||||
@ -88,7 +90,7 @@ func call(b *testing.B, c int) {
|
||||
|
||||
for i := 0; i < c; i++ {
|
||||
go func() {
|
||||
cl, err := tr.Dial(l.Addr())
|
||||
cl, err := tr.Dial(ctx, l.Addr())
|
||||
if err != nil {
|
||||
b.Fatalf("Unexpected dial err: %v", err)
|
||||
}
|
||||
|
@ -1,12 +1,13 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"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) {
|
||||
@ -23,20 +24,20 @@ func expectedPort(t *testing.T, expected string, lsn transport.Listener) {
|
||||
|
||||
func TestHTTPTransportPortRange(t *testing.T) {
|
||||
tp := NewTransport()
|
||||
|
||||
lsn1, err := tp.Listen(":44444-44448")
|
||||
ctx := context.Background()
|
||||
lsn1, err := tp.Listen(ctx, ":44444-44448")
|
||||
if err != nil {
|
||||
t.Errorf("Did not expect an error, got %s", err)
|
||||
}
|
||||
expectedPort(t, "44444", lsn1)
|
||||
|
||||
lsn2, err := tp.Listen(":44444-44448")
|
||||
lsn2, err := tp.Listen(ctx, ":44444-44448")
|
||||
if err != nil {
|
||||
t.Errorf("Did not expect an error, got %s", err)
|
||||
}
|
||||
expectedPort(t, "44445", lsn2)
|
||||
|
||||
lsn, err := tp.Listen("127.0.0.1:0")
|
||||
lsn, err := tp.Listen(ctx, "127.0.0.1:0")
|
||||
if err != nil {
|
||||
t.Errorf("Did not expect an error, got %s", err)
|
||||
}
|
||||
@ -48,8 +49,8 @@ func TestHTTPTransportPortRange(t *testing.T) {
|
||||
|
||||
func TestHTTPTransportCommunication(t *testing.T) {
|
||||
tr := NewTransport()
|
||||
|
||||
l, err := tr.Listen("127.0.0.1:0")
|
||||
ctx := context.Background()
|
||||
l, err := tr.Listen(ctx, "127.0.0.1:0")
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected listen err: %v", err)
|
||||
}
|
||||
@ -82,7 +83,7 @@ func TestHTTPTransportCommunication(t *testing.T) {
|
||||
}
|
||||
}()
|
||||
|
||||
c, err := tr.Dial(l.Addr())
|
||||
c, err := tr.Dial(ctx, l.Addr())
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected dial err: %v", err)
|
||||
}
|
||||
@ -114,8 +115,9 @@ func TestHTTPTransportCommunication(t *testing.T) {
|
||||
|
||||
func TestHTTPTransportError(t *testing.T) {
|
||||
tr := NewTransport()
|
||||
ctx := context.Background()
|
||||
|
||||
l, err := tr.Listen("127.0.0.1:0")
|
||||
l, err := tr.Listen(ctx, "127.0.0.1:0")
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected listen err: %v", err)
|
||||
}
|
||||
@ -151,7 +153,7 @@ func TestHTTPTransportError(t *testing.T) {
|
||||
}
|
||||
}()
|
||||
|
||||
c, err := tr.Dial(l.Addr())
|
||||
c, err := tr.Dial(ctx, l.Addr())
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected dial err: %v", err)
|
||||
}
|
||||
@ -184,8 +186,8 @@ func TestHTTPTransportError(t *testing.T) {
|
||||
|
||||
func TestHTTPTransportTimeout(t *testing.T) {
|
||||
tr := NewTransport(transport.Timeout(time.Millisecond * 100))
|
||||
|
||||
l, err := tr.Listen("127.0.0.1:0")
|
||||
ctx := context.Background()
|
||||
l, err := tr.Listen(ctx, "127.0.0.1:0")
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected listen err: %v", err)
|
||||
}
|
||||
@ -227,7 +229,7 @@ func TestHTTPTransportTimeout(t *testing.T) {
|
||||
}
|
||||
}()
|
||||
|
||||
c, err := tr.Dial(l.Addr())
|
||||
c, err := tr.Dial(ctx, l.Addr())
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected dial err: %v", err)
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/micro/go-micro/v3/network/transport"
|
||||
"go.unistack.org/micro/v3/network/transport"
|
||||
)
|
||||
|
||||
// Handle registers the handler for the given pattern.
|
||||
|
Loading…
Reference in New Issue
Block a user