feat: support third party orm to interact with go-zero (#1286)

* fixes #987

* chore: fix test failure

* chore: add comments

* feat: support third party orm to interact with go-zero

* chore: refactor
This commit is contained in:
Kevin Wan
2021-12-01 20:22:15 +08:00
committed by GitHub
parent 543d590710
commit 9d528dddd6
24 changed files with 55 additions and 38 deletions

View File

@@ -4,7 +4,6 @@ import (
"log"
"time"
"github.com/tal-tech/go-zero/core/discov"
"github.com/tal-tech/go-zero/zrpc/internal"
"github.com/tal-tech/go-zero/zrpc/internal/auth"
"github.com/tal-tech/go-zero/zrpc/internal/clientinterceptors"
@@ -64,22 +63,9 @@ func NewClient(c RpcClientConf, options ...ClientOption) (Client, error) {
opts = append(opts, options...)
var target string
var err error
if len(c.Endpoints) > 0 {
target = internal.BuildDirectTarget(c.Endpoints)
} else if len(c.Target) > 0 {
target = c.Target
} else {
if err = c.Etcd.Validate(); err != nil {
return nil, err
}
if c.Etcd.HasAccount() {
discov.RegisterAccount(c.Etcd.Hosts, c.Etcd.User, c.Etcd.Pass)
}
target = internal.BuildDiscovTarget(c.Etcd.Hosts, c.Etcd.Key)
target, err := c.BuildTarget()
if err != nil {
return nil, err
}
client, err := internal.NewClient(target, opts...)