Compare commits

...

3 Commits

Author SHA1 Message Date
kevin
0b1ee79d3a rename rpcx to zrpc 2020-09-18 11:41:52 +08:00
Zhang Hao
26e16107ce fix example tracing edge config (#76) 2020-09-18 08:53:06 +08:00
kevin
1e5e9d63bd update wechat qrcode 2020-09-17 10:28:33 +08:00
112 changed files with 171 additions and 156 deletions

View File

@@ -347,8 +347,8 @@ you can change the listening port in file `etc/add.yaml`.
```go ```go
type Config struct { type Config struct {
rest.RestConf rest.RestConf
Add rpcx.RpcClientConf // manual code Add zrpc.RpcClientConf // manual code
Check rpcx.RpcClientConf // manual code Check zrpc.RpcClientConf // manual code
} }
``` ```
@@ -364,8 +364,8 @@ you can change the listening port in file `etc/add.yaml`.
func NewServiceContext(c config.Config) *ServiceContext { func NewServiceContext(c config.Config) *ServiceContext {
return &ServiceContext{ return &ServiceContext{
Config: c, Config: c,
Adder: adder.NewAdder(rpcx.MustNewClient(c.Add)), // manual code Adder: adder.NewAdder(zrpc.MustNewClient(c.Add)), // manual code
Checker: checker.NewChecker(rpcx.MustNewClient(c.Check)), // manual code Checker: checker.NewChecker(zrpc.MustNewClient(c.Check)), // manual code
} }
} }
``` ```
@@ -477,7 +477,7 @@ Till now, weve done the modification of API Gateway. All the manually added c
```go ```go
type Config struct { type Config struct {
rpcx.RpcServerConf zrpc.RpcServerConf
DataSource string // manual code DataSource string // manual code
Table string // manual code Table string // manual code
Cache cache.CacheConf // manual code Cache cache.CacheConf // manual code

View File

@@ -349,8 +349,8 @@
```go ```go
type Config struct { type Config struct {
rest.RestConf rest.RestConf
Add rpcx.RpcClientConf // 手动代码 Add zrpc.RpcClientConf // 手动代码
Check rpcx.RpcClientConf // 手动代码 Check zrpc.RpcClientConf // 手动代码
} }
``` ```
@@ -366,8 +366,8 @@
func NewServiceContext(c config.Config) *ServiceContext { func NewServiceContext(c config.Config) *ServiceContext {
return &ServiceContext{ return &ServiceContext{
Config: c, Config: c,
Adder: adder.NewAdder(rpcx.MustNewClient(c.Add)), // 手动代码 Adder: adder.NewAdder(zrpc.MustNewClient(c.Add)), // 手动代码
Checker: checker.NewChecker(rpcx.MustNewClient(c.Check)), // 手动代码 Checker: checker.NewChecker(zrpc.MustNewClient(c.Check)), // 手动代码
} }
} }
``` ```
@@ -477,7 +477,7 @@
```go ```go
type Config struct { type Config struct {
rpcx.RpcServerConf zrpc.RpcServerConf
DataSource string // 手动代码 DataSource string // 手动代码
Table string // 手动代码 Table string // 手动代码
Cache cache.CacheConf // 手动代码 Cache cache.CacheConf // 手动代码

View File

@@ -221,11 +221,11 @@ OPTIONS:
*rrBalanced does not implement Picker (wrong type for Pick method) *rrBalanced does not implement Picker (wrong type for Pick method)
have Pick(context.Context, balancer.PickInfo) (balancer.SubConn, func(balancer.DoneInfo), error) have Pick(context.Context, balancer.PickInfo) (balancer.SubConn, func(balancer.DoneInfo), error)
want Pick(balancer.PickInfo) (balancer.PickResult, error) want Pick(balancer.PickInfo) (balancer.PickResult, error)
#github.com/tal-tech/go-zero/rpcx/internal/balancer/p2c #github.com/tal-tech/go-zero/zrpc/internal/balancer/p2c
../../../go/pkg/mod/github.com/tal-tech/go-zero@v1.0.12/rpcx/internal/balancer/p2c/p2c.go:41:32: not enough arguments in call to base.NewBalancerBuilder ../../../go/pkg/mod/github.com/tal-tech/go-zero@v1.0.12/zrpc/internal/balancer/p2c/p2c.go:41:32: not enough arguments in call to base.NewBalancerBuilder
have (string, *p2cPickerBuilder) have (string, *p2cPickerBuilder)
want (string, base.PickerBuilder, base.Config) want (string, base.PickerBuilder, base.Config)
../../../go/pkg/mod/github.com/tal-tech/go-zero@v1.0.12/rpcx/internal/balancer/p2c/p2c.go:58:9: cannot use &p2cPicker literal (type *p2cPicker) as type balancer.Picker in return argument: ../../../go/pkg/mod/github.com/tal-tech/go-zero@v1.0.12/zrpc/internal/balancer/p2c/p2c.go:58:9: cannot use &p2cPicker literal (type *p2cPicker) as type balancer.Picker in return argument:
*p2cPicker does not implement balancer.Picker (wrong type for Pick method) *p2cPicker does not implement balancer.Picker (wrong type for Pick method)
have Pick(context.Context, balancer.PickInfo) (balancer.SubConn, func(balancer.DoneInfo), error) have Pick(context.Context, balancer.PickInfo) (balancer.SubConn, func(balancer.DoneInfo), error)
want Pick(balancer.PickInfo) (balancer.PickResult, error) want Pick(balancer.PickInfo) (balancer.PickResult, error)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 KiB

After

Width:  |  Height:  |  Size: 191 KiB

View File

@@ -284,7 +284,7 @@ And now, lets walk through the complete flow of quickly create a microservice
```go ```go
type Config struct { type Config struct {
rest.RestConf rest.RestConf
Transform rpcx.RpcClientConf // manual code Transform zrpc.RpcClientConf // manual code
} }
``` ```
@@ -299,7 +299,7 @@ And now, lets walk through the complete flow of quickly create a microservice
func NewServiceContext(c config.Config) *ServiceContext { func NewServiceContext(c config.Config) *ServiceContext {
return &ServiceContext{ return &ServiceContext{
Config: c, Config: c,
Transformer: transformer.NewTransformer(rpcx.MustNewClient(c.Transform)), // manual code Transformer: transformer.NewTransformer(zrpc.MustNewClient(c.Transform)), // manual code
} }
} }
``` ```
@@ -409,7 +409,7 @@ Till now, weve done the modification of API Gateway. All the manually added c
```go ```go
type Config struct { type Config struct {
rpcx.RpcServerConf zrpc.RpcServerConf
DataSource string // manual code DataSource string // manual code
Table string // manual code Table string // manual code
Cache cache.CacheConf // manual code Cache cache.CacheConf // manual code

View File

@@ -280,7 +280,7 @@
```go ```go
type Config struct { type Config struct {
rest.RestConf rest.RestConf
Transform rpcx.RpcClientConf // 手动代码 Transform zrpc.RpcClientConf // 手动代码
} }
``` ```
@@ -295,7 +295,7 @@
func NewServiceContext(c config.Config) *ServiceContext { func NewServiceContext(c config.Config) *ServiceContext {
return &ServiceContext{ return &ServiceContext{
Config: c, Config: c,
Transformer: transformer.NewTransformer(rpcx.MustNewClient(c.Transform)), // 手动代码 Transformer: transformer.NewTransformer(zrpc.MustNewClient(c.Transform)), // 手动代码
} }
} }
``` ```
@@ -405,7 +405,7 @@
```go ```go
type Config struct { type Config struct {
rpcx.RpcServerConf zrpc.RpcServerConf
DataSource string // 手动代码 DataSource string // 手动代码
Table string // 手动代码 Table string // 手动代码
Cache cache.CacheConf // 手动代码 Cache cache.CacheConf // 手动代码

View File

@@ -2,11 +2,11 @@ package config
import ( import (
"github.com/tal-tech/go-zero/rest" "github.com/tal-tech/go-zero/rest"
"github.com/tal-tech/go-zero/rpcx" "github.com/tal-tech/go-zero/zrpc"
) )
type Config struct { type Config struct {
rest.RestConf rest.RestConf
Add rpcx.RpcClientConf Add zrpc.RpcClientConf
Check rpcx.RpcClientConf Check zrpc.RpcClientConf
} }

View File

@@ -5,7 +5,7 @@ import (
"bookstore/rpc/add/adder" "bookstore/rpc/add/adder"
"bookstore/rpc/check/checker" "bookstore/rpc/check/checker"
"github.com/tal-tech/go-zero/rpcx" "github.com/tal-tech/go-zero/zrpc"
) )
type ServiceContext struct { type ServiceContext struct {
@@ -17,7 +17,7 @@ type ServiceContext struct {
func NewServiceContext(c config.Config) *ServiceContext { func NewServiceContext(c config.Config) *ServiceContext {
return &ServiceContext{ return &ServiceContext{
Config: c, Config: c,
Adder: adder.NewAdder(rpcx.MustNewClient(c.Add)), Adder: adder.NewAdder(zrpc.MustNewClient(c.Add)),
Checker: checker.NewChecker(rpcx.MustNewClient(c.Check)), Checker: checker.NewChecker(zrpc.MustNewClient(c.Check)),
} }
} }

View File

@@ -14,7 +14,7 @@ import (
"github.com/tal-tech/go-zero/core/conf" "github.com/tal-tech/go-zero/core/conf"
"github.com/tal-tech/go-zero/core/logx" "github.com/tal-tech/go-zero/core/logx"
"github.com/tal-tech/go-zero/rpcx" "github.com/tal-tech/go-zero/zrpc"
"google.golang.org/grpc" "google.golang.org/grpc"
) )
@@ -28,7 +28,7 @@ func main() {
ctx := svc.NewServiceContext(c) ctx := svc.NewServiceContext(c)
adderSrv := server.NewAdderServer(ctx) adderSrv := server.NewAdderServer(ctx)
s, err := rpcx.NewServer(c.RpcServerConf, func(grpcServer *grpc.Server) { s, err := zrpc.NewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
add.RegisterAdderServer(grpcServer, adderSrv) add.RegisterAdderServer(grpcServer, adderSrv)
}) })
logx.Must(err) logx.Must(err)

View File

@@ -10,7 +10,7 @@ import (
"context" "context"
"github.com/tal-tech/go-zero/core/jsonx" "github.com/tal-tech/go-zero/core/jsonx"
"github.com/tal-tech/go-zero/rpcx" "github.com/tal-tech/go-zero/zrpc"
) )
type ( type (
@@ -19,11 +19,11 @@ type (
} }
defaultAdder struct { defaultAdder struct {
cli rpcx.Client cli zrpc.Client
} }
) )
func NewAdder(cli rpcx.Client) Adder { func NewAdder(cli zrpc.Client) Adder {
return &defaultAdder{ return &defaultAdder{
cli: cli, cli: cli,
} }

View File

@@ -2,12 +2,12 @@ package config
import ( import (
"github.com/tal-tech/go-zero/core/stores/cache" "github.com/tal-tech/go-zero/core/stores/cache"
"github.com/tal-tech/go-zero/rpcx" "github.com/tal-tech/go-zero/zrpc"
) )
type Config struct { type Config struct {
rpcx.RpcServerConf zrpc.RpcServerConf
DataSource string DataSource string
Table string Table string
Cache cache.CacheConf Cache cache.CacheConf
} }

View File

@@ -14,7 +14,7 @@ import (
"github.com/tal-tech/go-zero/core/conf" "github.com/tal-tech/go-zero/core/conf"
"github.com/tal-tech/go-zero/core/logx" "github.com/tal-tech/go-zero/core/logx"
"github.com/tal-tech/go-zero/rpcx" "github.com/tal-tech/go-zero/zrpc"
"google.golang.org/grpc" "google.golang.org/grpc"
) )
@@ -28,7 +28,7 @@ func main() {
ctx := svc.NewServiceContext(c) ctx := svc.NewServiceContext(c)
checkerSrv := server.NewCheckerServer(ctx) checkerSrv := server.NewCheckerServer(ctx)
s, err := rpcx.NewServer(c.RpcServerConf, func(grpcServer *grpc.Server) { s, err := zrpc.NewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
check.RegisterCheckerServer(grpcServer, checkerSrv) check.RegisterCheckerServer(grpcServer, checkerSrv)
}) })
logx.Must(err) logx.Must(err)

View File

@@ -10,7 +10,7 @@ import (
"context" "context"
"github.com/tal-tech/go-zero/core/jsonx" "github.com/tal-tech/go-zero/core/jsonx"
"github.com/tal-tech/go-zero/rpcx" "github.com/tal-tech/go-zero/zrpc"
) )
type ( type (
@@ -19,11 +19,11 @@ type (
} }
defaultChecker struct { defaultChecker struct {
cli rpcx.Client cli zrpc.Client
} }
) )
func NewChecker(cli rpcx.Client) Checker { func NewChecker(cli zrpc.Client) Checker {
return &defaultChecker{ return &defaultChecker{
cli: cli, cli: cli,
} }

View File

@@ -2,12 +2,12 @@ package config
import ( import (
"github.com/tal-tech/go-zero/core/stores/cache" "github.com/tal-tech/go-zero/core/stores/cache"
"github.com/tal-tech/go-zero/rpcx" "github.com/tal-tech/go-zero/zrpc"
) )
type Config struct { type Config struct {
rpcx.RpcServerConf zrpc.RpcServerConf
DataSource string DataSource string
Table string Table string
Cache cache.CacheConf Cache cache.CacheConf
} }

View File

@@ -2,10 +2,10 @@ package config
import ( import (
"github.com/tal-tech/go-zero/rest" "github.com/tal-tech/go-zero/rest"
"github.com/tal-tech/go-zero/rpcx" "github.com/tal-tech/go-zero/zrpc"
) )
type Config struct { type Config struct {
rest.RestConf rest.RestConf
Rpc rpcx.RpcClientConf Rpc zrpc.RpcClientConf
} }

View File

@@ -8,7 +8,7 @@ import (
"github.com/tal-tech/go-zero/example/graceful/dns/api/handler" "github.com/tal-tech/go-zero/example/graceful/dns/api/handler"
"github.com/tal-tech/go-zero/example/graceful/dns/api/svc" "github.com/tal-tech/go-zero/example/graceful/dns/api/svc"
"github.com/tal-tech/go-zero/rest" "github.com/tal-tech/go-zero/rest"
"github.com/tal-tech/go-zero/rpcx" "github.com/tal-tech/go-zero/zrpc"
) )
var configFile = flag.String("f", "etc/graceful-api.json", "the config file") var configFile = flag.String("f", "etc/graceful-api.json", "the config file")
@@ -19,7 +19,7 @@ func main() {
var c config.Config var c config.Config
conf.MustLoad(*configFile, &c) conf.MustLoad(*configFile, &c)
client := rpcx.MustNewClient(c.Rpc) client := zrpc.MustNewClient(c.Rpc)
ctx := &svc.ServiceContext{ ctx := &svc.ServiceContext{
Client: client, Client: client,
} }

View File

@@ -1,7 +1,7 @@
package svc package svc
import "github.com/tal-tech/go-zero/rpcx" import "github.com/tal-tech/go-zero/zrpc"
type ServiceContext struct { type ServiceContext struct {
Client rpcx.Client Client zrpc.Client
} }

View File

@@ -9,7 +9,7 @@ import (
"github.com/tal-tech/go-zero/core/conf" "github.com/tal-tech/go-zero/core/conf"
"github.com/tal-tech/go-zero/example/graceful/dns/rpc/graceful" "github.com/tal-tech/go-zero/example/graceful/dns/rpc/graceful"
"github.com/tal-tech/go-zero/rpcx" "github.com/tal-tech/go-zero/zrpc"
"google.golang.org/grpc" "google.golang.org/grpc"
) )
@@ -39,10 +39,10 @@ func (gs *GracefulServer) Grace(ctx context.Context, req *graceful.Request) (*gr
func main() { func main() {
flag.Parse() flag.Parse()
var c rpcx.RpcServerConf var c zrpc.RpcServerConf
conf.MustLoad(*configFile, &c) conf.MustLoad(*configFile, &c)
server := rpcx.MustNewServer(c, func(grpcServer *grpc.Server) { server := zrpc.MustNewServer(c, func(grpcServer *grpc.Server) {
graceful.RegisterGraceServiceServer(grpcServer, NewGracefulServer()) graceful.RegisterGraceServiceServer(grpcServer, NewGracefulServer())
}) })
defer server.Stop() defer server.Stop()

View File

@@ -2,10 +2,10 @@ package config
import ( import (
"github.com/tal-tech/go-zero/rest" "github.com/tal-tech/go-zero/rest"
"github.com/tal-tech/go-zero/rpcx" "github.com/tal-tech/go-zero/zrpc"
) )
type Config struct { type Config struct {
rest.RestConf rest.RestConf
Rpc rpcx.RpcClientConf Rpc zrpc.RpcClientConf
} }

View File

@@ -6,7 +6,7 @@
"Rpc": { "Rpc": {
"Etcd": { "Etcd": {
"Hosts": ["etcd.discov:2379"], "Hosts": ["etcd.discov:2379"],
"Key": "rpcx" "Key": "zrpc"
} }
} }
} }

View File

@@ -8,7 +8,7 @@ import (
"github.com/tal-tech/go-zero/example/graceful/etcd/api/handler" "github.com/tal-tech/go-zero/example/graceful/etcd/api/handler"
"github.com/tal-tech/go-zero/example/graceful/etcd/api/svc" "github.com/tal-tech/go-zero/example/graceful/etcd/api/svc"
"github.com/tal-tech/go-zero/rest" "github.com/tal-tech/go-zero/rest"
"github.com/tal-tech/go-zero/rpcx" "github.com/tal-tech/go-zero/zrpc"
) )
var configFile = flag.String("f", "etc/graceful-api.json", "the config file") var configFile = flag.String("f", "etc/graceful-api.json", "the config file")
@@ -19,7 +19,7 @@ func main() {
var c config.Config var c config.Config
conf.MustLoad(*configFile, &c) conf.MustLoad(*configFile, &c)
client := rpcx.MustNewClient(c.Rpc) client := zrpc.MustNewClient(c.Rpc)
ctx := &svc.ServiceContext{ ctx := &svc.ServiceContext{
Client: client, Client: client,
} }

View File

@@ -1,7 +1,7 @@
package svc package svc
import "github.com/tal-tech/go-zero/rpcx" import "github.com/tal-tech/go-zero/zrpc"
type ServiceContext struct { type ServiceContext struct {
Client rpcx.Client Client zrpc.Client
} }

View File

@@ -3,6 +3,6 @@
"ListenOn": "0.0.0.0:3456", "ListenOn": "0.0.0.0:3456",
"Etcd": { "Etcd": {
"Hosts": ["etcd.discov:2379"], "Hosts": ["etcd.discov:2379"],
"Key": "rpcx" "Key": "zrpc"
} }
} }

View File

@@ -9,7 +9,7 @@ import (
"github.com/tal-tech/go-zero/core/conf" "github.com/tal-tech/go-zero/core/conf"
"github.com/tal-tech/go-zero/example/graceful/etcd/rpc/graceful" "github.com/tal-tech/go-zero/example/graceful/etcd/rpc/graceful"
"github.com/tal-tech/go-zero/rpcx" "github.com/tal-tech/go-zero/zrpc"
"google.golang.org/grpc" "google.golang.org/grpc"
) )
@@ -39,10 +39,10 @@ func (gs *GracefulServer) Grace(ctx context.Context, req *graceful.Request) (*gr
func main() { func main() {
flag.Parse() flag.Parse()
var c rpcx.RpcServerConf var c zrpc.RpcServerConf
conf.MustLoad(*configFile, &c) conf.MustLoad(*configFile, &c)
server := rpcx.MustNewServer(c, func(grpcServer *grpc.Server) { server := zrpc.MustNewServer(c, func(grpcServer *grpc.Server) {
graceful.RegisterGraceServiceServer(grpcServer, NewGracefulServer()) graceful.RegisterGraceServiceServer(grpcServer, NewGracefulServer())
}) })
defer server.Stop() defer server.Stop()

View File

@@ -8,7 +8,7 @@ import (
"github.com/tal-tech/go-zero/core/discov" "github.com/tal-tech/go-zero/core/discov"
"github.com/tal-tech/go-zero/example/rpc/remote/unary" "github.com/tal-tech/go-zero/example/rpc/remote/unary"
"github.com/tal-tech/go-zero/rpcx" "github.com/tal-tech/go-zero/zrpc"
) )
const timeFormat = "15:04:05" const timeFormat = "15:04:05"
@@ -16,10 +16,10 @@ const timeFormat = "15:04:05"
func main() { func main() {
flag.Parse() flag.Parse()
client := rpcx.MustNewClient(rpcx.RpcClientConf{ client := zrpc.MustNewClient(zrpc.RpcClientConf{
Etcd: discov.EtcdConf{ Etcd: discov.EtcdConf{
Hosts: []string{"localhost:2379"}, Hosts: []string{"localhost:2379"},
Key: "rpcx", Key: "zrpc",
}, },
}) })

View File

@@ -9,7 +9,7 @@ import (
"github.com/tal-tech/go-zero/core/discov" "github.com/tal-tech/go-zero/core/discov"
"github.com/tal-tech/go-zero/example/rpc/remote/unary" "github.com/tal-tech/go-zero/example/rpc/remote/unary"
"github.com/tal-tech/go-zero/rpcx" "github.com/tal-tech/go-zero/zrpc"
) )
var lb = flag.String("t", "direct", "the load balancer type") var lb = flag.String("t", "direct", "the load balancer type")
@@ -17,20 +17,20 @@ var lb = flag.String("t", "direct", "the load balancer type")
func main() { func main() {
flag.Parse() flag.Parse()
var cli rpcx.Client var cli zrpc.Client
switch *lb { switch *lb {
case "direct": case "direct":
cli = rpcx.MustNewClient(rpcx.RpcClientConf{ cli = zrpc.MustNewClient(zrpc.RpcClientConf{
Endpoints: []string{ Endpoints: []string{
"localhost:3456", "localhost:3456",
"localhost:3457", "localhost:3457",
}, },
}) })
case "discov": case "discov":
cli = rpcx.MustNewClient(rpcx.RpcClientConf{ cli = zrpc.MustNewClient(zrpc.RpcClientConf{
Etcd: discov.EtcdConf{ Etcd: discov.EtcdConf{
Hosts: []string{"localhost:2379"}, Hosts: []string{"localhost:2379"},
Key: "rpcx", Key: "zrpc",
}, },
}) })
default: default:

View File

@@ -8,17 +8,17 @@ import (
"github.com/tal-tech/go-zero/core/discov" "github.com/tal-tech/go-zero/core/discov"
"github.com/tal-tech/go-zero/example/rpc/remote/stream" "github.com/tal-tech/go-zero/example/rpc/remote/stream"
"github.com/tal-tech/go-zero/rpcx" "github.com/tal-tech/go-zero/zrpc"
) )
const name = "kevin" const name = "kevin"
var key = flag.String("key", "rpcx", "the key on etcd") var key = flag.String("key", "zrpc", "the key on etcd")
func main() { func main() {
flag.Parse() flag.Parse()
client, err := rpcx.NewClientNoAuth(discov.EtcdConf{ client, err := zrpc.NewClientNoAuth(discov.EtcdConf{
Hosts: []string{"localhost:2379"}, Hosts: []string{"localhost:2379"},
Key: *key, Key: *key,
}) })

View File

@@ -8,7 +8,7 @@ import (
"github.com/tal-tech/go-zero/core/conf" "github.com/tal-tech/go-zero/core/conf"
"github.com/tal-tech/go-zero/example/rpc/remote/unary" "github.com/tal-tech/go-zero/example/rpc/remote/unary"
"github.com/tal-tech/go-zero/rpcx" "github.com/tal-tech/go-zero/zrpc"
) )
var configFile = flag.String("f", "config.json", "the config file") var configFile = flag.String("f", "config.json", "the config file")
@@ -16,9 +16,9 @@ var configFile = flag.String("f", "config.json", "the config file")
func main() { func main() {
flag.Parse() flag.Parse()
var c rpcx.RpcClientConf var c zrpc.RpcClientConf
conf.MustLoad(*configFile, &c) conf.MustLoad(*configFile, &c)
client := rpcx.MustNewClient(c) client := zrpc.MustNewClient(c)
ticker := time.NewTicker(time.Millisecond * 500) ticker := time.NewTicker(time.Millisecond * 500)
defer ticker.Stop() defer ticker.Stop()
for { for {

View File

@@ -7,7 +7,7 @@ import (
"github.com/tal-tech/go-zero/core/logx" "github.com/tal-tech/go-zero/core/logx"
"github.com/tal-tech/go-zero/core/service" "github.com/tal-tech/go-zero/core/service"
"github.com/tal-tech/go-zero/example/rpc/remote/unary" "github.com/tal-tech/go-zero/example/rpc/remote/unary"
"github.com/tal-tech/go-zero/rpcx" "github.com/tal-tech/go-zero/zrpc"
"google.golang.org/grpc" "google.golang.org/grpc"
) )
@@ -17,7 +17,7 @@ var (
) )
type GreetServer struct { type GreetServer struct {
*rpcx.RpcProxy *zrpc.RpcProxy
} }
func (s *GreetServer) Greet(ctx context.Context, req *unary.Request) (*unary.Response, error) { func (s *GreetServer) Greet(ctx context.Context, req *unary.Request) (*unary.Response, error) {
@@ -33,7 +33,7 @@ func (s *GreetServer) Greet(ctx context.Context, req *unary.Request) (*unary.Res
func main() { func main() {
flag.Parse() flag.Parse()
proxy := rpcx.MustNewServer(rpcx.RpcServerConf{ proxy := zrpc.MustNewServer(zrpc.RpcServerConf{
ServiceConf: service.ServiceConf{ ServiceConf: service.ServiceConf{
Log: logx.LogConf{ Log: logx.LogConf{
Mode: "console", Mode: "console",
@@ -42,7 +42,7 @@ func main() {
ListenOn: *listen, ListenOn: *listen,
}, func(grpcServer *grpc.Server) { }, func(grpcServer *grpc.Server) {
unary.RegisterGreeterServer(grpcServer, &GreetServer{ unary.RegisterGreeterServer(grpcServer, &GreetServer{
RpcProxy: rpcx.NewProxy(*server), RpcProxy: zrpc.NewProxy(*server),
}) })
}) })
proxy.Start() proxy.Start()

View File

@@ -6,7 +6,7 @@
"Hosts": [ "Hosts": [
"localhost:2379" "localhost:2379"
], ],
"Key": "rpcx" "Key": "zrpc"
}, },
"Redis": { "Redis": {
"Host": "localhost:6379", "Host": "localhost:6379",

View File

@@ -6,7 +6,7 @@ import (
"github.com/tal-tech/go-zero/core/conf" "github.com/tal-tech/go-zero/core/conf"
"github.com/tal-tech/go-zero/example/rpc/remote/stream" "github.com/tal-tech/go-zero/example/rpc/remote/stream"
"github.com/tal-tech/go-zero/rpcx" "github.com/tal-tech/go-zero/zrpc"
"google.golang.org/grpc" "google.golang.org/grpc"
) )
@@ -39,10 +39,10 @@ func (gs StreamGreetServer) Greet(s stream.StreamGreeter_GreetServer) error {
} }
func main() { func main() {
var c rpcx.RpcServerConf var c zrpc.RpcServerConf
conf.MustLoad("etc/config.json", &c) conf.MustLoad("etc/config.json", &c)
server := rpcx.MustNewServer(c, func(grpcServer *grpc.Server) { server := zrpc.MustNewServer(c, func(grpcServer *grpc.Server) {
stream.RegisterStreamGreeterServer(grpcServer, StreamGreetServer(0)) stream.RegisterStreamGreeterServer(grpcServer, StreamGreetServer(0))
}) })
server.Start() server.Start()

View File

@@ -8,6 +8,6 @@
"Hosts": [ "Hosts": [
"localhost:2379" "localhost:2379"
], ],
"Key": "rpcx" "Key": "zrpc"
} }
} }

View File

@@ -8,6 +8,6 @@
"Hosts": [ "Hosts": [
"localhost:2379" "localhost:2379"
], ],
"Key": "rpcx" "Key": "zrpc"
} }
} }

View File

@@ -6,7 +6,7 @@
"Hosts": [ "Hosts": [
"etcd.discov:2379" "etcd.discov:2379"
], ],
"Key": "rpcx" "Key": "zrpc"
}, },
"Timeout": 500 "Timeout": 500
} }

View File

@@ -10,7 +10,7 @@ import (
"github.com/tal-tech/go-zero/core/conf" "github.com/tal-tech/go-zero/core/conf"
"github.com/tal-tech/go-zero/example/rpc/remote/unary" "github.com/tal-tech/go-zero/example/rpc/remote/unary"
"github.com/tal-tech/go-zero/rpcx" "github.com/tal-tech/go-zero/zrpc"
"google.golang.org/grpc" "google.golang.org/grpc"
) )
@@ -44,10 +44,10 @@ func (gs *GreetServer) Greet(ctx context.Context, req *unary.Request) (*unary.Re
func main() { func main() {
flag.Parse() flag.Parse()
var c rpcx.RpcServerConf var c zrpc.RpcServerConf
conf.MustLoad(*configFile, &c) conf.MustLoad(*configFile, &c)
server := rpcx.MustNewServer(c, func(grpcServer *grpc.Server) { server := zrpc.MustNewServer(c, func(grpcServer *grpc.Server) {
unary.RegisterGreeterServer(grpcServer, NewGreetServer()) unary.RegisterGreeterServer(grpcServer, NewGreetServer())
}) })
server.Start() server.Start()

View File

@@ -2,10 +2,10 @@ package config
import ( import (
"github.com/tal-tech/go-zero/rest" "github.com/tal-tech/go-zero/rest"
"github.com/tal-tech/go-zero/rpcx" "github.com/tal-tech/go-zero/zrpc"
) )
type Config struct { type Config struct {
rest.RestConf rest.RestConf
Transform rpcx.RpcClientConf Transform zrpc.RpcClientConf
} }

View File

@@ -4,7 +4,7 @@ import (
"shorturl/api/internal/config" "shorturl/api/internal/config"
"shorturl/rpc/transform/transformer" "shorturl/rpc/transform/transformer"
"github.com/tal-tech/go-zero/rpcx" "github.com/tal-tech/go-zero/zrpc"
) )
type ServiceContext struct { type ServiceContext struct {
@@ -15,6 +15,6 @@ type ServiceContext struct {
func NewServiceContext(c config.Config) *ServiceContext { func NewServiceContext(c config.Config) *ServiceContext {
return &ServiceContext{ return &ServiceContext{
Config: c, Config: c,
Transformer: transformer.NewTransformer(rpcx.MustNewClient(c.Transform)), Transformer: transformer.NewTransformer(zrpc.MustNewClient(c.Transform)),
} }
} }

View File

@@ -2,11 +2,11 @@ package config
import ( import (
"github.com/tal-tech/go-zero/core/stores/cache" "github.com/tal-tech/go-zero/core/stores/cache"
"github.com/tal-tech/go-zero/rpcx" "github.com/tal-tech/go-zero/zrpc"
) )
type Config struct { type Config struct {
rpcx.RpcServerConf zrpc.RpcServerConf
DataSource string DataSource string
Table string Table string
Cache cache.CacheConf Cache cache.CacheConf

View File

@@ -14,7 +14,7 @@ import (
transform "shorturl/rpc/transform/pb" transform "shorturl/rpc/transform/pb"
"github.com/tal-tech/go-zero/core/conf" "github.com/tal-tech/go-zero/core/conf"
"github.com/tal-tech/go-zero/rpcx" "github.com/tal-tech/go-zero/zrpc"
"google.golang.org/grpc" "google.golang.org/grpc"
) )
@@ -28,7 +28,7 @@ func main() {
ctx := svc.NewServiceContext(c) ctx := svc.NewServiceContext(c)
transformerSrv := server.NewTransformerServer(ctx) transformerSrv := server.NewTransformerServer(ctx)
s, err := rpcx.NewServer(c.RpcServerConf, func(grpcServer *grpc.Server) { s, err := zrpc.NewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
transform.RegisterTransformerServer(grpcServer, transformerSrv) transform.RegisterTransformerServer(grpcServer, transformerSrv)
}) })
if err != nil { if err != nil {

View File

@@ -11,7 +11,7 @@ import (
transform "shorturl/rpc/transform/pb" transform "shorturl/rpc/transform/pb"
"github.com/tal-tech/go-zero/core/jsonx" "github.com/tal-tech/go-zero/core/jsonx"
"github.com/tal-tech/go-zero/rpcx" "github.com/tal-tech/go-zero/zrpc"
) )
type ( type (
@@ -21,11 +21,11 @@ type (
} }
defaultTransformer struct { defaultTransformer struct {
cli rpcx.Client cli zrpc.Client
} }
) )
func NewTransformer(cli rpcx.Client) Transformer { func NewTransformer(cli zrpc.Client) Transformer {
return &defaultTransformer{ return &defaultTransformer{
cli: cli, cli: cli,
} }

View File

@@ -1,3 +1,13 @@
{ {
"Server": "localhost:3456" "Name": "edge-api",
"Host": "0.0.0.0",
"Port": 3456,
"Portal": {
"Etcd": {
"Hosts": [
"localhost:2379"
],
"Key": "portal"
}
}
} }

View File

@@ -10,14 +10,19 @@ import (
"github.com/tal-tech/go-zero/example/tracing/remote/portal" "github.com/tal-tech/go-zero/example/tracing/remote/portal"
"github.com/tal-tech/go-zero/rest" "github.com/tal-tech/go-zero/rest"
"github.com/tal-tech/go-zero/rest/httpx" "github.com/tal-tech/go-zero/rest/httpx"
"github.com/tal-tech/go-zero/rpcx" "github.com/tal-tech/go-zero/zrpc"
) )
var ( var (
configFile = flag.String("f", "config.json", "the config file") configFile = flag.String("f", "config.json", "the config file")
client rpcx.Client client zrpc.Client
) )
type Config struct {
rest.RestConf
Portal zrpc.RpcClientConf
}
func handle(w http.ResponseWriter, r *http.Request) { func handle(w http.ResponseWriter, r *http.Request) {
conn := client.Conn() conn := client.Conn()
greet := portal.NewPortalClient(conn) greet := portal.NewPortalClient(conn)
@@ -34,16 +39,16 @@ func handle(w http.ResponseWriter, r *http.Request) {
func main() { func main() {
flag.Parse() flag.Parse()
var c rpcx.RpcClientConf var c Config
conf.MustLoad(*configFile, &c) conf.MustLoad(*configFile, &c)
client = rpcx.MustNewClient(c) client = zrpc.MustNewClient(c.Portal)
engine := rest.MustNewServer(rest.RestConf{ engine := rest.MustNewServer(rest.RestConf{
ServiceConf: service.ServiceConf{ ServiceConf: service.ServiceConf{
Log: logx.LogConf{ Log: logx.LogConf{
Mode: "console", Mode: "console",
}, },
}, },
Port: 3333, Port: c.Port,
}) })
defer engine.Stop() defer engine.Stop()

View File

@@ -7,7 +7,7 @@ import (
"github.com/tal-tech/go-zero/core/conf" "github.com/tal-tech/go-zero/core/conf"
"github.com/tal-tech/go-zero/example/tracing/remote/portal" "github.com/tal-tech/go-zero/example/tracing/remote/portal"
"github.com/tal-tech/go-zero/example/tracing/remote/user" "github.com/tal-tech/go-zero/example/tracing/remote/user"
"github.com/tal-tech/go-zero/rpcx" "github.com/tal-tech/go-zero/zrpc"
"google.golang.org/grpc" "google.golang.org/grpc"
) )
@@ -15,16 +15,16 @@ var configFile = flag.String("f", "etc/config.json", "the config file")
type ( type (
Config struct { Config struct {
rpcx.RpcServerConf zrpc.RpcServerConf
UserRpc rpcx.RpcClientConf UserRpc zrpc.RpcClientConf
} }
PortalServer struct { PortalServer struct {
userRpc rpcx.Client userRpc zrpc.Client
} }
) )
func NewPortalServer(client rpcx.Client) *PortalServer { func NewPortalServer(client zrpc.Client) *PortalServer {
return &PortalServer{ return &PortalServer{
userRpc: client, userRpc: client,
} }
@@ -53,8 +53,8 @@ func main() {
var c Config var c Config
conf.MustLoad(*configFile, &c) conf.MustLoad(*configFile, &c)
client := rpcx.MustNewClient(c.UserRpc) client := zrpc.MustNewClient(c.UserRpc)
server := rpcx.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) { server := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
portal.RegisterPortalServer(grpcServer, NewPortalServer(client)) portal.RegisterPortalServer(grpcServer, NewPortalServer(client))
}) })
server.Start() server.Start()

View File

@@ -10,7 +10,7 @@ import (
"github.com/tal-tech/go-zero/core/conf" "github.com/tal-tech/go-zero/core/conf"
"github.com/tal-tech/go-zero/example/tracing/remote/user" "github.com/tal-tech/go-zero/example/tracing/remote/user"
"github.com/tal-tech/go-zero/rpcx" "github.com/tal-tech/go-zero/zrpc"
"google.golang.org/grpc" "google.golang.org/grpc"
) )
@@ -44,10 +44,10 @@ func (gs *UserServer) GetGrade(ctx context.Context, req *user.UserRequest) (*use
func main() { func main() {
flag.Parse() flag.Parse()
var c rpcx.RpcServerConf var c zrpc.RpcServerConf
conf.MustLoad(*configFile, &c) conf.MustLoad(*configFile, &c)
server := rpcx.MustNewServer(c, func(grpcServer *grpc.Server) { server := zrpc.MustNewServer(c, func(grpcServer *grpc.Server) {
user.RegisterUserServer(grpcServer, NewUserServer()) user.RegisterUserServer(grpcServer, NewUserServer())
}) })
server.Start() server.Start()

View File

@@ -20,7 +20,7 @@ type (
// why not name it as Conf, because we need to consider usage like: // why not name it as Conf, because we need to consider usage like:
// type Config struct { // type Config struct {
// rpcx.RpcConf // zrpc.RpcConf
// rest.RestConf // rest.RestConf
// } // }
// if with the name Conf, there will be two Conf inside Config. // if with the name Conf, there will be two Conf inside Config.

View File

@@ -220,11 +220,11 @@ OPTIONS:
*rrBalanced does not implement Picker (wrong type for Pick method) *rrBalanced does not implement Picker (wrong type for Pick method)
have Pick(context.Context, balancer.PickInfo) (balancer.SubConn, func(balancer.DoneInfo), error) have Pick(context.Context, balancer.PickInfo) (balancer.SubConn, func(balancer.DoneInfo), error)
want Pick(balancer.PickInfo) (balancer.PickResult, error) want Pick(balancer.PickInfo) (balancer.PickResult, error)
#github.com/tal-tech/go-zero/rpcx/internal/balancer/p2c #github.com/tal-tech/go-zero/zrpc/internal/balancer/p2c
../../../go/pkg/mod/github.com/tal-tech/go-zero@v1.0.12/rpcx/internal/balancer/p2c/p2c.go:41:32: not enough arguments in call to base.NewBalancerBuilder ../../../go/pkg/mod/github.com/tal-tech/go-zero@v1.0.12/zrpc/internal/balancer/p2c/p2c.go:41:32: not enough arguments in call to base.NewBalancerBuilder
have (string, *p2cPickerBuilder) have (string, *p2cPickerBuilder)
want (string, base.PickerBuilder, base.Config) want (string, base.PickerBuilder, base.Config)
../../../go/pkg/mod/github.com/tal-tech/go-zero@v1.0.12/rpcx/internal/balancer/p2c/p2c.go:58:9: cannot use &p2cPicker literal (type *p2cPicker) as type balancer.Picker in return argument: ../../../go/pkg/mod/github.com/tal-tech/go-zero@v1.0.12/zrpc/internal/balancer/p2c/p2c.go:58:9: cannot use &p2cPicker literal (type *p2cPicker) as type balancer.Picker in return argument:
*p2cPicker does not implement balancer.Picker (wrong type for Pick method) *p2cPicker does not implement balancer.Picker (wrong type for Pick method)
have Pick(context.Context, balancer.PickInfo) (balancer.SubConn, func(balancer.DoneInfo), error) have Pick(context.Context, balancer.PickInfo) (balancer.SubConn, func(balancer.DoneInfo), error)
want Pick(balancer.PickInfo) (balancer.PickResult, error) want Pick(balancer.PickInfo) (balancer.PickResult, error)

View File

@@ -25,7 +25,7 @@ import (
{{.package}} {{.package}}
"github.com/tal-tech/go-zero/core/jsonx" "github.com/tal-tech/go-zero/core/jsonx"
"github.com/tal-tech/go-zero/rpcx" "github.com/tal-tech/go-zero/zrpc"
) )
type ( type (
@@ -34,11 +34,11 @@ type (
} }
default{{.serviceName}} struct { default{{.serviceName}} struct {
cli rpcx.Client cli zrpc.Client
} }
) )
func New{{.serviceName}}(cli rpcx.Client) {{.serviceName}} { func New{{.serviceName}}(cli zrpc.Client) {{.serviceName}} {
return &default{{.serviceName}}{ return &default{{.serviceName}}{
cli: cli, cli: cli,
} }

View File

@@ -10,10 +10,10 @@ import (
const configTemplate = `package config const configTemplate = `package config
import "github.com/tal-tech/go-zero/rpcx" import "github.com/tal-tech/go-zero/zrpc"
type Config struct { type Config struct {
rpcx.RpcServerConf zrpc.RpcServerConf
} }
` `

View File

@@ -21,7 +21,7 @@ import (
"github.com/tal-tech/go-zero/core/conf" "github.com/tal-tech/go-zero/core/conf"
"github.com/tal-tech/go-zero/core/logx" "github.com/tal-tech/go-zero/core/logx"
"github.com/tal-tech/go-zero/rpcx" "github.com/tal-tech/go-zero/zrpc"
"google.golang.org/grpc" "google.golang.org/grpc"
) )
@@ -35,7 +35,7 @@ func main() {
ctx := svc.NewServiceContext(c) ctx := svc.NewServiceContext(c)
{{.srv}} {{.srv}}
s, err := rpcx.NewServer(c.RpcServerConf, func(grpcServer *grpc.Server) { s, err := zrpc.NewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
{{.registers}} {{.registers}}
}) })
logx.Must(err) logx.Must(err)

View File

@@ -1,12 +1,12 @@
package rpcx package zrpc
import ( import (
"log" "log"
"time" "time"
"github.com/tal-tech/go-zero/core/discov" "github.com/tal-tech/go-zero/core/discov"
"github.com/tal-tech/go-zero/rpcx/internal" "github.com/tal-tech/go-zero/zrpc/internal"
"github.com/tal-tech/go-zero/rpcx/internal/auth" "github.com/tal-tech/go-zero/zrpc/internal/auth"
"google.golang.org/grpc" "google.golang.org/grpc"
) )

View File

@@ -1,4 +1,4 @@
package rpcx package zrpc
import ( import (
"context" "context"
@@ -9,7 +9,7 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/tal-tech/go-zero/core/logx" "github.com/tal-tech/go-zero/core/logx"
"github.com/tal-tech/go-zero/rpcx/internal/mock" "github.com/tal-tech/go-zero/zrpc/internal/mock"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/codes" "google.golang.org/grpc/codes"
"google.golang.org/grpc/status" "google.golang.org/grpc/status"

View File

@@ -1,4 +1,4 @@
package rpcx package zrpc
import ( import (
"github.com/tal-tech/go-zero/core/discov" "github.com/tal-tech/go-zero/core/discov"

View File

@@ -1,4 +1,4 @@
package rpcx package zrpc
import ( import (
"testing" "testing"

View File

@@ -13,7 +13,7 @@ import (
"github.com/tal-tech/go-zero/core/logx" "github.com/tal-tech/go-zero/core/logx"
"github.com/tal-tech/go-zero/core/syncx" "github.com/tal-tech/go-zero/core/syncx"
"github.com/tal-tech/go-zero/core/timex" "github.com/tal-tech/go-zero/core/timex"
"github.com/tal-tech/go-zero/rpcx/internal/codes" "github.com/tal-tech/go-zero/zrpc/internal/codes"
"google.golang.org/grpc/balancer" "google.golang.org/grpc/balancer"
"google.golang.org/grpc/balancer/base" "google.golang.org/grpc/balancer/base"
"google.golang.org/grpc/resolver" "google.golang.org/grpc/resolver"

View File

@@ -5,9 +5,9 @@ import (
"fmt" "fmt"
"time" "time"
"github.com/tal-tech/go-zero/rpcx/internal/balancer/p2c" "github.com/tal-tech/go-zero/zrpc/internal/balancer/p2c"
"github.com/tal-tech/go-zero/rpcx/internal/clientinterceptors" "github.com/tal-tech/go-zero/zrpc/internal/clientinterceptors"
"github.com/tal-tech/go-zero/rpcx/internal/resolver" "github.com/tal-tech/go-zero/zrpc/internal/resolver"
"google.golang.org/grpc" "google.golang.org/grpc"
) )

View File

@@ -5,7 +5,7 @@ import (
"path" "path"
"github.com/tal-tech/go-zero/core/breaker" "github.com/tal-tech/go-zero/core/breaker"
"github.com/tal-tech/go-zero/rpcx/internal/codes" "github.com/tal-tech/go-zero/zrpc/internal/codes"
"google.golang.org/grpc" "google.golang.org/grpc"
) )

View File

@@ -8,7 +8,7 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/tal-tech/go-zero/core/breaker" "github.com/tal-tech/go-zero/core/breaker"
"github.com/tal-tech/go-zero/core/stat" "github.com/tal-tech/go-zero/core/stat"
rcodes "github.com/tal-tech/go-zero/rpcx/internal/codes" rcodes "github.com/tal-tech/go-zero/zrpc/internal/codes"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/codes" "google.golang.org/grpc/codes"
"google.golang.org/grpc/status" "google.golang.org/grpc/status"

View File

@@ -5,7 +5,7 @@ import (
"github.com/tal-tech/go-zero/core/proc" "github.com/tal-tech/go-zero/core/proc"
"github.com/tal-tech/go-zero/core/stat" "github.com/tal-tech/go-zero/core/stat"
"github.com/tal-tech/go-zero/rpcx/internal/serverinterceptors" "github.com/tal-tech/go-zero/zrpc/internal/serverinterceptors"
"google.golang.org/grpc" "google.golang.org/grpc"
) )

View File

@@ -3,7 +3,7 @@ package serverinterceptors
import ( import (
"context" "context"
"github.com/tal-tech/go-zero/rpcx/internal/auth" "github.com/tal-tech/go-zero/zrpc/internal/auth"
"google.golang.org/grpc" "google.golang.org/grpc"
) )

View File

@@ -7,7 +7,7 @@ import (
"github.com/alicebob/miniredis" "github.com/alicebob/miniredis"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/tal-tech/go-zero/core/stores/redis" "github.com/tal-tech/go-zero/core/stores/redis"
"github.com/tal-tech/go-zero/rpcx/internal/auth" "github.com/tal-tech/go-zero/zrpc/internal/auth"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/metadata" "google.golang.org/grpc/metadata"
) )

Some files were not shown because too many files have changed in this diff Show More