From c6ff95a3f49e6f7134344b9a9accdbc571b14025 Mon Sep 17 00:00:00 2001 From: John Guo Date: Wed, 15 Jun 2022 21:42:12 +0800 Subject: [PATCH] README update for contrib/registry etcd/polaris --- cmd/gf/internal/cmd/cmd_gen_service.go | 2 +- contrib/registry/etcd/README.MD | 79 ++++++++++++++++++++++++++ contrib/registry/polaris/README.MD | 9 +-- contrib/registry/polaris/README_ZH.MD | 2 +- 4 files changed, 82 insertions(+), 10 deletions(-) create mode 100644 contrib/registry/etcd/README.MD diff --git a/cmd/gf/internal/cmd/cmd_gen_service.go b/cmd/gf/internal/cmd/cmd_gen_service.go index 2de983ec310..e9e265bf8ea 100644 --- a/cmd/gf/internal/cmd/cmd_gen_service.go +++ b/cmd/gf/internal/cmd/cmd_gen_service.go @@ -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"` diff --git a/contrib/registry/etcd/README.MD b/contrib/registry/etcd/README.MD new file mode 100644 index 00000000000..a1cac769363 --- /dev/null +++ b/contrib/registry/etcd/README.MD @@ -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. + diff --git a/contrib/registry/polaris/README.MD b/contrib/registry/polaris/README.MD index 9fd2927abb9..c60572b210e 100644 --- a/contrib/registry/polaris/README.MD +++ b/contrib/registry/polaris/README.MD @@ -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 diff --git a/contrib/registry/polaris/README_ZH.MD b/contrib/registry/polaris/README_ZH.MD index 47ab34ced22..587da4eadb1 100644 --- a/contrib/registry/polaris/README_ZH.MD +++ b/contrib/registry/polaris/README_ZH.MD @@ -2,7 +2,7 @@ [English](README.MD) | 简体中文 -使用Polarismesh作为服务注册、发现管理和心跳上报 +使用`PolarisMesh`作为服务注册、发现管理和心跳上报。 ## Installation