mirror of
https://gitee.com/johng/gf.git
synced 2024-11-30 11:18:02 +08:00
README update for contrib/registry etcd/polaris
This commit is contained in:
parent
17ab0e2ced
commit
c6ff95a3f4
@ -23,7 +23,7 @@ type (
|
||||
SrcFolder string `short:"s" name:"srcFolder" brief:"source folder path to be parsed. default: internal/logic" d:"internal/logic"`
|
||||
DstFolder string `short:"d" name:"dstFolder" brief:"destination folder path storing automatically generated go files. default: internal/service" d:"internal/service"`
|
||||
WatchFile string `short:"w" name:"watchFile" brief:"used in file watcher, it generates service go files only if given file is under srcFolder"`
|
||||
StPattern string `short:"a" name:"stPattern" brief:"regular expression matching struct name for generating service. default: s([A-Z]\\w+)" d:"s([A-Z]\\w+)"`
|
||||
StPattern string `short:"a" name:"stPattern" brief:"regular expression matching struct name for generating service. default: s([A-Z]\\\w+)" d:"s([A-Z]\\w+)"`
|
||||
Packages string `short:"p" name:"packages" brief:"produce go files only for given source packages, multiple packages joined with char ','"`
|
||||
ImportPrefix string `short:"i" name:"importPrefix" brief:"custom import prefix to calculate import path for generated importing go file of logic"`
|
||||
OverWrite bool `short:"o" name:"overwrite" brief:"overwrite service go files that already exist in generating folder. default: true" d:"true" orphan:"true"`
|
||||
|
79
contrib/registry/etcd/README.MD
Normal file
79
contrib/registry/etcd/README.MD
Normal file
@ -0,0 +1,79 @@
|
||||
# GoFrame Etcd Registry
|
||||
|
||||
|
||||
Use `etcd` as service registration and discovery management.
|
||||
|
||||
|
||||
## Installation
|
||||
```
|
||||
go get -u -v github.com/gogf/gf/contrib/registry/etcd/v2
|
||||
```
|
||||
suggested using `go.mod`:
|
||||
```
|
||||
require github.com/gogf/gf/contrib/registry/etcd/v2 latest
|
||||
```
|
||||
|
||||
|
||||
## Example
|
||||
|
||||
### Reference example
|
||||
|
||||
[server](example/registry/etcd/server/main.go)
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/contrib/registry/etcd/v2"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
"github.com/gogf/gf/v2/net/gsvc"
|
||||
)
|
||||
|
||||
func main() {
|
||||
gsvc.SetRegistry(etcd.New(`127.0.0.1:2379`))
|
||||
|
||||
s := g.Server(`hello.svc`)
|
||||
s.BindHandler("/", func(r *ghttp.Request) {
|
||||
g.Log().Info(r.Context(), `request received`)
|
||||
r.Response.Write(`Hello world`)
|
||||
})
|
||||
s.Run()
|
||||
}
|
||||
```
|
||||
|
||||
[client](example/registry/etcd/client/main.go)
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/contrib/registry/etcd/v2"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/net/gsel"
|
||||
"github.com/gogf/gf/v2/net/gsvc"
|
||||
"github.com/gogf/gf/v2/os/gctx"
|
||||
)
|
||||
|
||||
func main() {
|
||||
gsvc.SetRegistry(etcd.New(`127.0.0.1:2379`))
|
||||
gsel.SetBuilder(gsel.NewBuilderRoundRobin())
|
||||
|
||||
client := g.Client()
|
||||
for i := 0; i < 100; i++ {
|
||||
res, err := client.Get(gctx.New(), `http://hello.svc/`)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println(res.ReadAllString())
|
||||
res.Close()
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
`GoFrame etcd` is licensed under the [MIT License](../../../LICENSE), 100% free and open-source, forever.
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
English | [简体中文](README_ZH.MD)
|
||||
|
||||
Use Polaris mesh as service registration, discovery management and heartbeat reporting
|
||||
Use `PolarisMesh` as service registration, discovery management and heartbeat reporting.
|
||||
|
||||
|
||||
## Installation
|
||||
@ -14,11 +14,6 @@ suggested using `go.mod`:
|
||||
require github.com/gogf/gf/contrib/registry/polaris/v2 latest
|
||||
```
|
||||
|
||||
## Limitation
|
||||
```
|
||||
golang version >= 1.15
|
||||
```
|
||||
|
||||
|
||||
## Example
|
||||
|
||||
@ -50,7 +45,6 @@ func main() {
|
||||
})
|
||||
s.Run()
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
[client](example/registry/polaris/client/main.go)
|
||||
@ -85,7 +79,6 @@ func main() {
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## License
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
[English](README.MD) | 简体中文
|
||||
|
||||
使用Polarismesh作为服务注册、发现管理和心跳上报
|
||||
使用`PolarisMesh`作为服务注册、发现管理和心跳上报。
|
||||
|
||||
|
||||
## Installation
|
||||
|
Loading…
Reference in New Issue
Block a user