Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/polaris feat: Add Polaris support #1797

Merged
merged 79 commits into from
May 18, 2022
Merged
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
9683ee1
feat: ID is the unique instance ID as registered.
houseme Apr 9, 2022
03eea91
improve
houseme Apr 11, 2022
8b593de
Merge pull request #3 from gogf/master
houseme Apr 18, 2022
934fb58
feat:create polarismesh
houseme Apr 18, 2022
1219bd9
up
houseme Apr 20, 2022
8d7a4c2
Merge branch 'gogf:master' into feature/polaris
houseme May 3, 2022
2495e8b
feat: upgrade dependent package version
houseme May 3, 2022
2b35d06
action
houseme May 3, 2022
bfa829e
fix
houseme May 3, 2022
8181cf1
improve code
houseme May 3, 2022
582120f
feat: New ID ID is the unique instance ID as registered.
houseme May 3, 2022
3c9ac20
fix: Remove repeatedly introduced packages
houseme May 3, 2022
9b481bd
feat: Add Polaris service
houseme May 3, 2022
68c49d7
feat: improve
houseme May 3, 2022
0801fc8
Merge branch 'gogf:master' into feature/polaris
houseme May 6, 2022
02ca024
improve package ghttp
gqcn May 6, 2022
559c1d0
add WhereBuilder feature for package gdb
gqcn Apr 30, 2022
cb63a0e
comment updates for package clilckhouse
gqcn May 6, 2022
bcf0622
improve WhereBuilder for package gdb
gqcn May 6, 2022
87506af
improve WhereBuilder feature for package gdb
gqcn May 7, 2022
547cff8
improve WhereBuilder feature for package gdb
gqcn May 7, 2022
d647107
remove Sharding feature
gqcn May 7, 2022
b51cb53
merge
houseme May 11, 2022
1eb7501
remove debug info for UT of package gdb
gqcn May 7, 2022
ea54d42
merge
houseme May 11, 2022
af89376
improve hook feature for package gdb
gqcn May 9, 2022
489698d
fix timezone bug when persisting *gtime.Time to db #1714
Apr 3, 2022
7b2f449
fix issue #1714, #1727
gqcn May 9, 2022
e6a9515
remove octal number converting for gconv.Int*/Uint* functions; fix is…
gqcn May 9, 2022
89acc92
merge
houseme May 11, 2022
c1f7a17
merge
houseme May 7, 2022
d7985f1
merge
houseme May 7, 2022
8fb3fc0
feat:create polaris example
houseme May 4, 2022
8f290f4
improve code
houseme May 4, 2022
a459f15
fix
houseme May 5, 2022
9190a21
merge
houseme May 7, 2022
962a8bf
fix
houseme May 6, 2022
29c3f3d
upgrade polaris-go version
houseme May 7, 2022
a5200f8
upgrade polaris-go version
houseme May 9, 2022
7361d4f
fix
houseme May 11, 2022
f56f0fd
fix
houseme May 11, 2022
8e41142
test
houseme May 11, 2022
2467c0e
fix
houseme May 11, 2022
bde610b
test
houseme May 11, 2022
8b4e0f3
test
houseme May 11, 2022
37a93a5
test
houseme May 11, 2022
ce20f33
improve code
houseme May 12, 2022
c60ee80
fix
houseme May 12, 2022
c0b7e92
Merge branch 'master' into feature/polaris
houseme May 12, 2022
defc46a
up
houseme May 12, 2022
2ac6b48
feat: #1826
houseme May 12, 2022
6cf3bab
Merge branch 'master' into feature/polaris
houseme May 12, 2022
9424f11
up
houseme May 12, 2022
84dbb3b
up
houseme May 12, 2022
734f85c
improve comment for gclient
houseme May 12, 2022
30a3d36
up
houseme May 12, 2022
17ed325
fix
houseme May 12, 2022
5508da4
improve code
houseme May 12, 2022
a8bd6e9
fix
houseme May 12, 2022
1b78300
fix
houseme May 12, 2022
53871b6
fix
houseme May 12, 2022
9985103
up
houseme May 12, 2022
405c52f
up
houseme May 12, 2022
39e7f46
fix
houseme May 12, 2022
b75815a
Update gvalid_validator_check_value.go
houseme May 12, 2022
82c33c9
up
houseme May 12, 2022
81f2c98
up golangci-lint config file
houseme May 12, 2022
3fb4256
feat:add readme.md
houseme May 13, 2022
53e0543
fix
houseme May 13, 2022
edba701
Merge branch 'master' into feature/polaris
houseme May 13, 2022
d929cbe
Merge branch 'gogf:master' into feature/polaris
houseme May 13, 2022
7959531
fix
houseme May 13, 2022
4513d02
Merge branch 'gogf:master' into feature/polaris
houseme May 13, 2022
d1f1a39
Merge remote-tracking branch 'upstream/master' into feature/polaris
houseme May 13, 2022
8450dea
feat:modify package
houseme May 15, 2022
4eeb876
improve code
houseme May 16, 2022
0863498
fix
houseme May 16, 2022
fc77c0d
improve stop heartbeat
houseme May 18, 2022
dc6dc31
fix:Set to no cached channel
houseme May 18, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/gf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
- develop
- feature/**
- fix/**

pull_request:
branches:
- master
Expand Down Expand Up @@ -89,7 +90,11 @@ jobs:
- 9000:9000
- 8123:8123
- 9001:9001

polaris:
image: huyuanxin/polaris-server-with-config:latest
ports:
- 8090:8090
- 8091:8091

strategy:
matrix:
Expand Down
9 changes: 8 additions & 1 deletion contrib/registry/etcd/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,21 @@ package etcd
import (
"time"

etcd3 "go.etcd.io/etcd/client/v3"

"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/net/gsvc"
"github.com/gogf/gf/v2/os/glog"
"github.com/gogf/gf/v2/text/gstr"
etcd3 "go.etcd.io/etcd/client/v3"
)

var (
_ gsvc.Registry = &Registry{}
)

// Registry implements gsvc.Registry interface.
type Registry struct {
client *etcd3.Client
kv etcd3.KV
Expand All @@ -31,15 +33,19 @@ type Registry struct {
logger *glog.Logger
}

// Option is the option for the etcd registry.
type Option struct {
Logger *glog.Logger
KeepaliveTTL time.Duration
}

const (
// DefaultKeepAliveTTL is the default keepalive TTL.
DefaultKeepAliveTTL = 10 * time.Second
separator = "/"
)

// New creates and returns a new etcd registry.
func New(address string, option ...Option) *Registry {
endpoints := gstr.SplitAndTrim(address, ",")
if len(endpoints) == 0 {
Expand All @@ -54,6 +60,7 @@ func New(address string, option ...Option) *Registry {
return NewWithClient(client, option...)
}

// NewWithClient creates and returns a new etcd registry with the given client.
func NewWithClient(client *etcd3.Client, option ...Option) *Registry {
r := &Registry{
client: client,
Expand Down
6 changes: 4 additions & 2 deletions contrib/registry/etcd/etcd_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ package etcd
import (
"context"

etcd3 "go.etcd.io/etcd/client/v3"

"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/net/gsvc"
etcd3 "go.etcd.io/etcd/client/v3"
)

func (r *Registry) Register(ctx context.Context, service *gsvc.Service) error {
Expand Down Expand Up @@ -42,6 +43,7 @@ func (r *Registry) Register(ctx context.Context, service *gsvc.Service) error {
return err
}
go r.doKeepAlive(grant.ID, keepAliceCh)
service.Separator = separator
return nil
}

Expand All @@ -64,7 +66,7 @@ func (r *Registry) doKeepAlive(leaseID etcd3.LeaseID, keepAliceCh <-chan *etcd3.

case res, ok := <-keepAliceCh:
if res != nil {
//r.logger.Debugf(ctx, `keepalive loop: %v, %s`, ok, res.String())
// r.logger.Debugf(ctx, `keepalive loop: %v, %s`, ok, res.String())
}
if !ok {
r.logger.Noticef(ctx, `keepalive exit, lease id: %d`, leaseID)
Expand Down
11 changes: 11 additions & 0 deletions contrib/registry/polaris/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
### Example user template template
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请删除该文件。

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

### Example user template

# IntelliJ project files
.idea
*.iml
out
gen

*.log
*.json
8 changes: 8 additions & 0 deletions contrib/registry/polaris/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://github.com/gogf/gf.

// Package polaris implements service Registry and Discovery using polaris.
package polaris
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

去掉该文件,文件命名请参考同目录下etcd组件的命名方式,保持框架整体文件命名方式统一。

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

10 changes: 10 additions & 0 deletions contrib/registry/polaris/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module github.com/gogf/gf/contrib/registry/polaris/v2

go 1.15

require (
github.com/gogf/gf/v2 v2.0.0
github.com/polarismesh/polaris-go v1.1.0
)

replace github.com/gogf/gf/v2 => ../../../
645 changes: 645 additions & 0 deletions contrib/registry/polaris/go.sum

Large diffs are not rendered by default.

Loading