Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
9 changes: 5 additions & 4 deletions contrib/registry/nacos/README.MD
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
# GoFrame Nacos Registry


Use `nacos` as service registration and discovery management.


## Installation

```
go get -u -v github.com/gogf/gf/contrib/registry/nacos/v2
```

suggested using `go.mod`:

```
require github.com/gogf/gf/contrib/registry/nacos/v2 latest
```


## Example

### Reference example

[server](../../../example/registry/nacos/http/server/main.go)

```go
package main

Expand All @@ -44,6 +45,7 @@ func main() {
```

[client](../../../example/registry/nacos/http/client/main.go)

```go
package main

Expand Down Expand Up @@ -78,4 +80,3 @@ func main() {
## License

`GoFrame Nacos` is licensed under the [MIT License](../../../LICENSE), 100% free and open-source, forever.

2 changes: 1 addition & 1 deletion contrib/registry/nacos/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.23.0

require (
github.com/gogf/gf/v2 v2.9.8
github.com/nacos-group/nacos-sdk-go/v2 v2.3.3
github.com/nacos-group/nacos-sdk-go/v2 v2.3.5
)

require (
Expand Down
2 changes: 2 additions & 0 deletions contrib/registry/nacos/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/nacos-group/nacos-sdk-go/v2 v2.3.3 h1:lvkBZcYkKENLVR1ubO+vGxTP2L4VtVSArLvYZKuu4Pk=
github.com/nacos-group/nacos-sdk-go/v2 v2.3.3/go.mod h1:ygUBdt7eGeYBt6Lz2HO3wx7crKXk25Mp80568emGMWU=
github.com/nacos-group/nacos-sdk-go/v2 v2.3.5 h1:Hux7C4N4rWhwBF5Zm4yyYskrs9VTgrRTA8DZjoEhQTs=
github.com/nacos-group/nacos-sdk-go/v2 v2.3.5/go.mod h1:ygUBdt7eGeYBt6Lz2HO3wx7crKXk25Mp80568emGMWU=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/olekukonko/errors v1.1.0 h1:RNuGIh15QdDenh+hNvKrJkmxxjV4hcS50Db478Ou5sM=
github.com/olekukonko/errors v1.1.0/go.mod h1:ppzxA5jBKcO1vIpCXQ9ZqgDh8iwODz6OXIGKU8r5m4Y=
Expand Down
2 changes: 1 addition & 1 deletion contrib/registry/nacos/nacos.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func New(address string, opts ...constant.ClientOption) (reg *Registry) {
return
}

// New creates and returns registry with Config.
// NewWithConfig new creates and returns registry with Config.
Comment thread
hailaz marked this conversation as resolved.
Outdated
func NewWithConfig(ctx context.Context, config Config) (reg *Registry, err error) {
// Data validation.
err = g.Validator().Data(config).Run(ctx)
Expand Down
2 changes: 1 addition & 1 deletion contrib/registry/nacos/nacos_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
)

// Search searches and returns services with specified condition.
func (reg *Registry) Search(ctx context.Context, in gsvc.SearchInput) (result []gsvc.Service, err error) {
func (reg *Registry) Search(_ context.Context, in gsvc.SearchInput) (result []gsvc.Service, err error) {
if in.Prefix == "" && in.Name != "" {
in.Prefix = gsvc.NewServiceWithName(in.Name).GetPrefix()
}
Expand Down
4 changes: 2 additions & 2 deletions contrib/registry/nacos/nacos_register.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

// Register registers `service` to Registry.
// Note that it returns a new Service if it changes the input Service with custom one.
func (reg *Registry) Register(ctx context.Context, service gsvc.Service) (registered gsvc.Service, err error) {
func (reg *Registry) Register(_ context.Context, service gsvc.Service) (registered gsvc.Service, err error) {
metadata := map[string]string{}
endpoints := service.GetEndpoints()

Expand Down Expand Up @@ -67,7 +67,7 @@ func (reg *Registry) Register(ctx context.Context, service gsvc.Service) (regist
}

// Deregister off-lines and removes `service` from the Registry.
func (reg *Registry) Deregister(ctx context.Context, service gsvc.Service) (err error) {
func (reg *Registry) Deregister(_ context.Context, service gsvc.Service) (err error) {
c := reg.client

for _, endpoint := range service.GetEndpoints() {
Expand Down
Loading