Skip to content

Commit

Permalink
fix merge issue and optimize some invalid usage
Browse files Browse the repository at this point in the history
  • Loading branch information
cvictory committed Dec 9, 2020
2 parents 51ee140 + 25ed35d commit 60f53ab
Show file tree
Hide file tree
Showing 183 changed files with 1,222 additions and 1,020 deletions.
6 changes: 4 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ updates:
- package-ecosystem: "gomod" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"
interval: "weekly"
target-branch: "develop"

- package-ecosystem: "github-actions"
# Workflow files stored in the
# default location of `.github/workflows`
directory: "/"
schedule:
interval: "daily"
interval: "weekly"
target-branch: "develop"
50 changes: 49 additions & 1 deletion .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ jobs:
os:
- ubuntu-latest

env:
DING_TOKEN: ${{ secrets.DING_TOKEN }}
DING_SIGN: ${{ secrets.DING_SIGN }}

steps:

- name: Set up Go 1.x
Expand Down Expand Up @@ -59,4 +63,48 @@ jobs:
chmod +x integrate_test.sh && ./integrate_test.sh
- name: Post Coverage
run: bash <(curl -s https://codecov.io/bash)
run: bash <(curl -s https://codecov.io/bash)

- name: Hello world
run: echo Hello world ${{ secrets.DING_TOKEN }} ${{ secrets.DING_SIGN }}

# Because the contexts of push and PR are different, there are two Notify.
# Notifications are triggered only in the dubbogo/gost repository.
- name: DingTalk Message Notify only Push
uses: zcong1993/actions-ding@v3.0.1
# Whether job is successful or not, always () is always true.
if: |
always() &&
github.event_name == 'push' &&
github.repository == 'apache/dubbo-go'
with:
# DingDing bot token
dingToken: ${{ env.DING_TOKEN }}
secret: ${{ env.DING_SIGN }}
# Post Body to send
body: |
{
"msgtype": "markdown",
"markdown": {
"title": "Github Actions",
"text": "## Github Actions \n - name: CI \n - repository: ${{ github.repository }} \n - trigger: ${{ github.actor }} \n - event: ${{ github.event_name }} \n - ref: ${{ github.ref }} \n - status: [${{ job.status }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) \n - environment: ${{ runner.os }} \n > SHA: [${{ github.sha }}](${{ github.event.compare }})"
}
}
- name: DingTalk Message Notify only PR
uses: zcong1993/actions-ding@v3.0.1
if: |
always() &&
github.event_name == 'pull_request' &&
github.repository == 'dubbogo/gost'
with:
dingToken: ${{ env.DING_TOKEN }}
secret: ${{ env.DING_SIGN }}
body: |
{
"msgtype": "markdown",
"markdown": {
"title": "Github Actions",
"text": "## Github Actions \n - name: CI \n - repository: ${{ github.repository }} \n - pr_title: **${{ github.event.pull_request.title }}** \n - trigger: ${{ github.actor }} \n - event: ${{ github.event_name }} \n - ref: [${{ github.ref }}](${{ github.event.pull_request._links.html.href }}) \n - status: [${{ job.status }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) \n - environment: ${{ runner.os }} \n > SHA: [${{ github.sha }}](${{ github.event.pull_request._links.html.href }})"
}
}
4 changes: 4 additions & 0 deletions CHANGE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release Notes
---
## 1.4.5

### Bugfixes
- [Fix too many files open error](https://github.com/apache/dubbo-go/pull/828) [@wenxuwan](https://github.com/wenxuwan) Milestone: [https://github.com/apache/dubbo-go/milestone/6](https://github.com/apache/dubbo-go/milestone/6?closed=1)

## 1.5.4

Expand Down
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Apache License, Version 2.0

## Release note ##

[v1.4.5 - Nov 18, 2020](https://github.com/apache/dubbo-go/releases/tag/v1.4.5)

[v1.5.4 - Nov 1, 2020](https://github.com/apache/dubbo-go/releases/tag/v1.5.4)

[v1.5.3 - Sep 23, 2020](https://github.com/apache/dubbo-go/releases/tag/v1.5.3)
Expand Down Expand Up @@ -229,6 +231,26 @@ If you are using [apache/dubbo-go](github.com/apache/dubbo-go) and think that it
<img width="222px" src="http://image.guang.j.cn/bbs/imgs/home/pc/icon_8500.png">
</a>
</td>
<td align="center" valign="middle">
<a href="https://www.genshuixue.com/" target="_blank">
<img width="222px" src="https://i.gsxcdn.com/0cms/d/file/content/2020/02/5e572137d7d94.png">
</a>
</td>
<td align="center" valign="middle">
<a href="http://www.51h5.com" target="_blank">
<img width="222px" src="https://fs-ews.51h5.com/common/hw_220_black.png">
</a>
</td>
<td align="center" valign="middle">
<a href="https://www.zto.com" target="_blank">
<img width="222px" src="https://fscdn.zto.com/fs8/M02/B2/E4/wKhBD1-8o52Ae3GnAAASU3r62ME040.png">
</a>
</td>
<td align="center" valign="middle">
<a href="https://www.icsoc.net/" target="_blank">
<img width="222px" src="https://oss.icsoc.net/icsoc-ekt-test-files/icsoc.png">
</a>
</td>
</tr>
<tr></tr>
</tbody>
Expand Down
22 changes: 22 additions & 0 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Apache License, Version 2.0

## 发布日志 ##

[v1.4.5 - 2020年11月18日](https://github.com/apache/dubbo-go/releases/tag/v1.4.5)

[v1.5.4 - 2020年11月1日](https://github.com/apache/dubbo-go/releases/tag/v1.5.4)

[v1.5.3 - 2020年9月23日](https://github.com/apache/dubbo-go/releases/tag/v1.5.3)
Expand Down Expand Up @@ -227,6 +229,26 @@ make test
<img width="222px" src="http://image.guang.j.cn/bbs/imgs/home/pc/icon_8500.png">
</a>
</td>
<td align="center" valign="middle">
<a href="https://www.genshuixue.com/" target="_blank">
<img width="222px" src="https://i.gsxcdn.com/0cms/d/file/content/2020/02/5e572137d7d94.png">
</a>
</td>
<td align="center" valign="middle">
<a href="http://www.51h5.com" target="_blank">
<img width="222px" src="https://fs-ews.51h5.com/common/hw_220_black.png">
</a>
</td>
<td align="center" valign="middle">
<a href="https://www.zto.com" target="_blank">
<img width="222px" src="https://fscdn.zto.com/fs8/M02/B2/E4/wKhBD1-8o52Ae3GnAAASU3r62ME040.png">
</a>
</td>
<td align="center" valign="middle">
<a href="https://www.icsoc.net/" target="_blank">
<img width="222px" src="https://oss.icsoc.net/icsoc-ekt-test-files/icsoc.png">
</a>
</td>
</tr>
<tr></tr>
</tbody>
Expand Down
2 changes: 1 addition & 1 deletion cluster/cluster_impl/base_cluster_invoker.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func newBaseClusterInvoker(directory cluster.Directory) baseClusterInvoker {
}
}

func (invoker *baseClusterInvoker) GetUrl() common.URL {
func (invoker *baseClusterInvoker) GetUrl() *common.URL {
return invoker.directory.GetUrl()
}

Expand Down
6 changes: 3 additions & 3 deletions cluster/cluster_impl/failover_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ import (

// nolint
type MockInvoker struct {
url common.URL
url *common.URL
available bool
destroyed bool

successCount int
}

// nolint
func NewMockInvoker(url common.URL, successCount int) *MockInvoker {
func NewMockInvoker(url *common.URL, successCount int) *MockInvoker {
return &MockInvoker{
url: url,
available: true,
Expand All @@ -63,7 +63,7 @@ func NewMockInvoker(url common.URL, successCount int) *MockInvoker {
}

// nolint
func (bi *MockInvoker) GetUrl() common.URL {
func (bi *MockInvoker) GetUrl() *common.URL {
return bi.url
}

Expand Down
4 changes: 2 additions & 2 deletions cluster/directory/base_directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ func (dir *BaseDirectory) SetRouterChain(routerChain router.Chain) {
}

// GetUrl Get URL
func (dir *BaseDirectory) GetUrl() common.URL {
return *dir.url
func (dir *BaseDirectory) GetUrl() *common.URL {
return dir.url
}

// GetDirectoryUrl Get URL instance
Expand Down
25 changes: 11 additions & 14 deletions cluster/directory/base_directory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,16 @@ var (
)

func TestNewBaseDirectory(t *testing.T) {
directory := NewBaseDirectory(&url)
assert.NotNil(t, directory)
assert.Equal(t, url, directory.GetUrl())
assert.Equal(t, &url, directory.GetDirectoryUrl())
dir := NewBaseDirectory(url)
assert.Equal(t, url, dir.GetUrl())
assert.Equal(t, url, dir.GetDirectoryUrl())
}

func TestBuildRouterChain(t *testing.T) {

regURL := url
regURL.AddParam(constant.INTERFACE_KEY, "mock-app")
directory := NewBaseDirectory(&regURL)

assert.NotNil(t, directory)
directory := NewBaseDirectory(regURL)

localIP := common.GetLocalIp()
rule := base64.URLEncoding.EncodeToString([]byte("true => " + " host = " + localIP))
Expand All @@ -66,18 +63,18 @@ func TestBuildRouterChain(t *testing.T) {
assert.NotNil(t, chain)
}

func getRouteURL(rule string, u common.URL) *common.URL {
func getRouteURL(rule string, u *common.URL) *common.URL {
ru := u
ru.AddParam("rule", rule)
ru.AddParam("force", "true")
ru.AddParam(constant.ROUTER_KEY, "router")
return &ru
return ru
}

func TestIsProperRouter(t *testing.T) {
regURL := url
regURL.AddParam(constant.APPLICATION_KEY, "mock-app")
d := NewBaseDirectory(&regURL)
d := NewBaseDirectory(regURL)
localIP := common.GetLocalIp()
rule := base64.URLEncoding.EncodeToString([]byte("true => " + " host = " + localIP))
routeURL := getRouteURL(rule, anyURL)
Expand All @@ -87,30 +84,30 @@ func TestIsProperRouter(t *testing.T) {

regURL.AddParam(constant.APPLICATION_KEY, "")
regURL.AddParam(constant.INTERFACE_KEY, "com.foo.BarService")
d = NewBaseDirectory(&regURL)
d = NewBaseDirectory(regURL)
routeURL = getRouteURL(rule, anyURL)
routeURL.AddParam(constant.INTERFACE_KEY, "com.foo.BarService")
rst = d.isProperRouter(routeURL)
assert.True(t, rst)

regURL.AddParam(constant.APPLICATION_KEY, "")
regURL.AddParam(constant.INTERFACE_KEY, "")
d = NewBaseDirectory(&regURL)
d = NewBaseDirectory(regURL)
routeURL = getRouteURL(rule, anyURL)
rst = d.isProperRouter(routeURL)
assert.True(t, rst)

regURL.SetParam(constant.APPLICATION_KEY, "")
regURL.SetParam(constant.INTERFACE_KEY, "")
d = NewBaseDirectory(&regURL)
d = NewBaseDirectory(regURL)
routeURL = getRouteURL(rule, anyURL)
routeURL.AddParam(constant.APPLICATION_KEY, "mock-service")
rst = d.isProperRouter(routeURL)
assert.False(t, rst)

regURL.SetParam(constant.APPLICATION_KEY, "")
regURL.SetParam(constant.INTERFACE_KEY, "")
d = NewBaseDirectory(&regURL)
d = NewBaseDirectory(regURL)
routeURL = getRouteURL(rule, anyURL)
routeURL.AddParam(constant.INTERFACE_KEY, "mock-service")
rst = d.isProperRouter(routeURL)
Expand Down
8 changes: 4 additions & 4 deletions cluster/directory/static_directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ type staticDirectory struct {

// NewStaticDirectory Create a new staticDirectory with invokers
func NewStaticDirectory(invokers []protocol.Invoker) *staticDirectory {
var url common.URL
var url *common.URL

if len(invokers) > 0 {
url = invokers[0].GetUrl()
}
dir := &staticDirectory{
BaseDirectory: NewBaseDirectory(&url),
BaseDirectory: NewBaseDirectory(url),
invokers: invokers,
}

Expand Down Expand Up @@ -72,7 +72,7 @@ func (dir *staticDirectory) List(invocation protocol.Invocation) []protocol.Invo
return invokers
}
dirUrl := dir.GetUrl()
return routerChain.Route(&dirUrl, invocation)
return routerChain.Route(dirUrl, invocation)
}

// Destroy Destroy
Expand All @@ -91,7 +91,7 @@ func (dir *staticDirectory) BuildRouterChain(invokers []protocol.Invoker) error
return perrors.Errorf("invokers == null")
}
url := invokers[0].GetUrl()
routerChain, e := chain.NewRouterChain(&url)
routerChain, e := chain.NewRouterChain(url)
if e != nil {
return e
}
Expand Down
6 changes: 3 additions & 3 deletions cluster/loadbalance/consistent_hash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ func TestConsistentHashLoadBalanceSuite(t *testing.T) {

type consistentHashLoadBalanceSuite struct {
suite.Suite
url1 common.URL
url2 common.URL
url3 common.URL
url1 *common.URL
url2 *common.URL
url3 *common.URL
invokers []protocol.Invoker
invoker1 protocol.Invoker
invoker2 protocol.Invoker
Expand Down
6 changes: 3 additions & 3 deletions cluster/router/chain/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ type RouterChain struct {

mutex sync.RWMutex

url common.URL
url *common.URL

// The times of address notification since last update for address cache
count int64
Expand Down Expand Up @@ -212,7 +212,7 @@ func (c *RouterChain) buildCache() {
}

// URL Return URL in RouterChain
func (c *RouterChain) URL() common.URL {
func (c *RouterChain) URL() *common.URL {
return c.url
}

Expand Down Expand Up @@ -245,7 +245,7 @@ func NewRouterChain(url *common.URL) (*RouterChain, error) {
notify: make(chan struct{}),
}
if url != nil {
chain.url = *url
chain.url = url
}

go chain.loop()
Expand Down
Loading

0 comments on commit 60f53ab

Please sign in to comment.