rename rpcx to zrpc
This commit is contained in:
@@ -2,11 +2,11 @@ package config
|
||||
|
||||
import (
|
||||
"github.com/tal-tech/go-zero/rest"
|
||||
"github.com/tal-tech/go-zero/rpcx"
|
||||
"github.com/tal-tech/go-zero/zrpc"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
rest.RestConf
|
||||
Add rpcx.RpcClientConf
|
||||
Check rpcx.RpcClientConf
|
||||
}
|
||||
Add zrpc.RpcClientConf
|
||||
Check zrpc.RpcClientConf
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"bookstore/rpc/add/adder"
|
||||
"bookstore/rpc/check/checker"
|
||||
|
||||
"github.com/tal-tech/go-zero/rpcx"
|
||||
"github.com/tal-tech/go-zero/zrpc"
|
||||
)
|
||||
|
||||
type ServiceContext struct {
|
||||
@@ -17,7 +17,7 @@ type ServiceContext struct {
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
Adder: adder.NewAdder(rpcx.MustNewClient(c.Add)),
|
||||
Checker: checker.NewChecker(rpcx.MustNewClient(c.Check)),
|
||||
Adder: adder.NewAdder(zrpc.MustNewClient(c.Add)),
|
||||
Checker: checker.NewChecker(zrpc.MustNewClient(c.Check)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
|
||||
"github.com/tal-tech/go-zero/core/conf"
|
||||
"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"
|
||||
)
|
||||
|
||||
@@ -28,7 +28,7 @@ func main() {
|
||||
ctx := svc.NewServiceContext(c)
|
||||
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)
|
||||
})
|
||||
logx.Must(err)
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/tal-tech/go-zero/core/jsonx"
|
||||
"github.com/tal-tech/go-zero/rpcx"
|
||||
"github.com/tal-tech/go-zero/zrpc"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -19,11 +19,11 @@ type (
|
||||
}
|
||||
|
||||
defaultAdder struct {
|
||||
cli rpcx.Client
|
||||
cli zrpc.Client
|
||||
}
|
||||
)
|
||||
|
||||
func NewAdder(cli rpcx.Client) Adder {
|
||||
func NewAdder(cli zrpc.Client) Adder {
|
||||
return &defaultAdder{
|
||||
cli: cli,
|
||||
}
|
||||
|
||||
@@ -2,12 +2,12 @@ package config
|
||||
|
||||
import (
|
||||
"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 {
|
||||
rpcx.RpcServerConf
|
||||
zrpc.RpcServerConf
|
||||
DataSource string
|
||||
Table string
|
||||
Cache cache.CacheConf
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
|
||||
"github.com/tal-tech/go-zero/core/conf"
|
||||
"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"
|
||||
)
|
||||
|
||||
@@ -28,7 +28,7 @@ func main() {
|
||||
ctx := svc.NewServiceContext(c)
|
||||
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)
|
||||
})
|
||||
logx.Must(err)
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/tal-tech/go-zero/core/jsonx"
|
||||
"github.com/tal-tech/go-zero/rpcx"
|
||||
"github.com/tal-tech/go-zero/zrpc"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -19,11 +19,11 @@ type (
|
||||
}
|
||||
|
||||
defaultChecker struct {
|
||||
cli rpcx.Client
|
||||
cli zrpc.Client
|
||||
}
|
||||
)
|
||||
|
||||
func NewChecker(cli rpcx.Client) Checker {
|
||||
func NewChecker(cli zrpc.Client) Checker {
|
||||
return &defaultChecker{
|
||||
cli: cli,
|
||||
}
|
||||
|
||||
@@ -2,12 +2,12 @@ package config
|
||||
|
||||
import (
|
||||
"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 {
|
||||
rpcx.RpcServerConf
|
||||
zrpc.RpcServerConf
|
||||
DataSource string
|
||||
Table string
|
||||
Cache cache.CacheConf
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@ package config
|
||||
|
||||
import (
|
||||
"github.com/tal-tech/go-zero/rest"
|
||||
"github.com/tal-tech/go-zero/rpcx"
|
||||
"github.com/tal-tech/go-zero/zrpc"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
rest.RestConf
|
||||
Rpc rpcx.RpcClientConf
|
||||
Rpc zrpc.RpcClientConf
|
||||
}
|
||||
|
||||
@@ -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/svc"
|
||||
"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")
|
||||
@@ -19,7 +19,7 @@ func main() {
|
||||
var c config.Config
|
||||
conf.MustLoad(*configFile, &c)
|
||||
|
||||
client := rpcx.MustNewClient(c.Rpc)
|
||||
client := zrpc.MustNewClient(c.Rpc)
|
||||
ctx := &svc.ServiceContext{
|
||||
Client: client,
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package svc
|
||||
|
||||
import "github.com/tal-tech/go-zero/rpcx"
|
||||
import "github.com/tal-tech/go-zero/zrpc"
|
||||
|
||||
type ServiceContext struct {
|
||||
Client rpcx.Client
|
||||
Client zrpc.Client
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
"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/rpcx"
|
||||
"github.com/tal-tech/go-zero/zrpc"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
@@ -39,10 +39,10 @@ func (gs *GracefulServer) Grace(ctx context.Context, req *graceful.Request) (*gr
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
var c rpcx.RpcServerConf
|
||||
var c zrpc.RpcServerConf
|
||||
conf.MustLoad(*configFile, &c)
|
||||
|
||||
server := rpcx.MustNewServer(c, func(grpcServer *grpc.Server) {
|
||||
server := zrpc.MustNewServer(c, func(grpcServer *grpc.Server) {
|
||||
graceful.RegisterGraceServiceServer(grpcServer, NewGracefulServer())
|
||||
})
|
||||
defer server.Stop()
|
||||
|
||||
@@ -2,10 +2,10 @@ package config
|
||||
|
||||
import (
|
||||
"github.com/tal-tech/go-zero/rest"
|
||||
"github.com/tal-tech/go-zero/rpcx"
|
||||
"github.com/tal-tech/go-zero/zrpc"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
rest.RestConf
|
||||
Rpc rpcx.RpcClientConf
|
||||
Rpc zrpc.RpcClientConf
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"Rpc": {
|
||||
"Etcd": {
|
||||
"Hosts": ["etcd.discov:2379"],
|
||||
"Key": "rpcx"
|
||||
"Key": "zrpc"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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/svc"
|
||||
"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")
|
||||
@@ -19,7 +19,7 @@ func main() {
|
||||
var c config.Config
|
||||
conf.MustLoad(*configFile, &c)
|
||||
|
||||
client := rpcx.MustNewClient(c.Rpc)
|
||||
client := zrpc.MustNewClient(c.Rpc)
|
||||
ctx := &svc.ServiceContext{
|
||||
Client: client,
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package svc
|
||||
|
||||
import "github.com/tal-tech/go-zero/rpcx"
|
||||
import "github.com/tal-tech/go-zero/zrpc"
|
||||
|
||||
type ServiceContext struct {
|
||||
Client rpcx.Client
|
||||
Client zrpc.Client
|
||||
}
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
"ListenOn": "0.0.0.0:3456",
|
||||
"Etcd": {
|
||||
"Hosts": ["etcd.discov:2379"],
|
||||
"Key": "rpcx"
|
||||
"Key": "zrpc"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
"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/rpcx"
|
||||
"github.com/tal-tech/go-zero/zrpc"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
@@ -39,10 +39,10 @@ func (gs *GracefulServer) Grace(ctx context.Context, req *graceful.Request) (*gr
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
var c rpcx.RpcServerConf
|
||||
var c zrpc.RpcServerConf
|
||||
conf.MustLoad(*configFile, &c)
|
||||
|
||||
server := rpcx.MustNewServer(c, func(grpcServer *grpc.Server) {
|
||||
server := zrpc.MustNewServer(c, func(grpcServer *grpc.Server) {
|
||||
graceful.RegisterGraceServiceServer(grpcServer, NewGracefulServer())
|
||||
})
|
||||
defer server.Stop()
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
"github.com/tal-tech/go-zero/core/discov"
|
||||
"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"
|
||||
@@ -16,10 +16,10 @@ const timeFormat = "15:04:05"
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
client := rpcx.MustNewClient(rpcx.RpcClientConf{
|
||||
client := zrpc.MustNewClient(zrpc.RpcClientConf{
|
||||
Etcd: discov.EtcdConf{
|
||||
Hosts: []string{"localhost:2379"},
|
||||
Key: "rpcx",
|
||||
Key: "zrpc",
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
"github.com/tal-tech/go-zero/core/discov"
|
||||
"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")
|
||||
@@ -17,20 +17,20 @@ var lb = flag.String("t", "direct", "the load balancer type")
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
var cli rpcx.Client
|
||||
var cli zrpc.Client
|
||||
switch *lb {
|
||||
case "direct":
|
||||
cli = rpcx.MustNewClient(rpcx.RpcClientConf{
|
||||
cli = zrpc.MustNewClient(zrpc.RpcClientConf{
|
||||
Endpoints: []string{
|
||||
"localhost:3456",
|
||||
"localhost:3457",
|
||||
},
|
||||
})
|
||||
case "discov":
|
||||
cli = rpcx.MustNewClient(rpcx.RpcClientConf{
|
||||
cli = zrpc.MustNewClient(zrpc.RpcClientConf{
|
||||
Etcd: discov.EtcdConf{
|
||||
Hosts: []string{"localhost:2379"},
|
||||
Key: "rpcx",
|
||||
Key: "zrpc",
|
||||
},
|
||||
})
|
||||
default:
|
||||
|
||||
@@ -8,17 +8,17 @@ import (
|
||||
|
||||
"github.com/tal-tech/go-zero/core/discov"
|
||||
"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"
|
||||
|
||||
var key = flag.String("key", "rpcx", "the key on etcd")
|
||||
var key = flag.String("key", "zrpc", "the key on etcd")
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
client, err := rpcx.NewClientNoAuth(discov.EtcdConf{
|
||||
client, err := zrpc.NewClientNoAuth(discov.EtcdConf{
|
||||
Hosts: []string{"localhost:2379"},
|
||||
Key: *key,
|
||||
})
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
"github.com/tal-tech/go-zero/core/conf"
|
||||
"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")
|
||||
@@ -16,9 +16,9 @@ var configFile = flag.String("f", "config.json", "the config file")
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
var c rpcx.RpcClientConf
|
||||
var c zrpc.RpcClientConf
|
||||
conf.MustLoad(*configFile, &c)
|
||||
client := rpcx.MustNewClient(c)
|
||||
client := zrpc.MustNewClient(c)
|
||||
ticker := time.NewTicker(time.Millisecond * 500)
|
||||
defer ticker.Stop()
|
||||
for {
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"github.com/tal-tech/go-zero/core/logx"
|
||||
"github.com/tal-tech/go-zero/core/service"
|
||||
"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"
|
||||
)
|
||||
|
||||
@@ -17,7 +17,7 @@ var (
|
||||
)
|
||||
|
||||
type GreetServer struct {
|
||||
*rpcx.RpcProxy
|
||||
*zrpc.RpcProxy
|
||||
}
|
||||
|
||||
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() {
|
||||
flag.Parse()
|
||||
|
||||
proxy := rpcx.MustNewServer(rpcx.RpcServerConf{
|
||||
proxy := zrpc.MustNewServer(zrpc.RpcServerConf{
|
||||
ServiceConf: service.ServiceConf{
|
||||
Log: logx.LogConf{
|
||||
Mode: "console",
|
||||
@@ -42,7 +42,7 @@ func main() {
|
||||
ListenOn: *listen,
|
||||
}, func(grpcServer *grpc.Server) {
|
||||
unary.RegisterGreeterServer(grpcServer, &GreetServer{
|
||||
RpcProxy: rpcx.NewProxy(*server),
|
||||
RpcProxy: zrpc.NewProxy(*server),
|
||||
})
|
||||
})
|
||||
proxy.Start()
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"Hosts": [
|
||||
"localhost:2379"
|
||||
],
|
||||
"Key": "rpcx"
|
||||
"Key": "zrpc"
|
||||
},
|
||||
"Redis": {
|
||||
"Host": "localhost:6379",
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
|
||||
"github.com/tal-tech/go-zero/core/conf"
|
||||
"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"
|
||||
)
|
||||
|
||||
@@ -39,10 +39,10 @@ func (gs StreamGreetServer) Greet(s stream.StreamGreeter_GreetServer) error {
|
||||
}
|
||||
|
||||
func main() {
|
||||
var c rpcx.RpcServerConf
|
||||
var c zrpc.RpcServerConf
|
||||
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))
|
||||
})
|
||||
server.Start()
|
||||
|
||||
@@ -8,6 +8,6 @@
|
||||
"Hosts": [
|
||||
"localhost:2379"
|
||||
],
|
||||
"Key": "rpcx"
|
||||
"Key": "zrpc"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,6 @@
|
||||
"Hosts": [
|
||||
"localhost:2379"
|
||||
],
|
||||
"Key": "rpcx"
|
||||
"Key": "zrpc"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"Hosts": [
|
||||
"etcd.discov:2379"
|
||||
],
|
||||
"Key": "rpcx"
|
||||
"Key": "zrpc"
|
||||
},
|
||||
"Timeout": 500
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
"github.com/tal-tech/go-zero/core/conf"
|
||||
"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"
|
||||
)
|
||||
|
||||
@@ -44,10 +44,10 @@ func (gs *GreetServer) Greet(ctx context.Context, req *unary.Request) (*unary.Re
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
var c rpcx.RpcServerConf
|
||||
var c zrpc.RpcServerConf
|
||||
conf.MustLoad(*configFile, &c)
|
||||
|
||||
server := rpcx.MustNewServer(c, func(grpcServer *grpc.Server) {
|
||||
server := zrpc.MustNewServer(c, func(grpcServer *grpc.Server) {
|
||||
unary.RegisterGreeterServer(grpcServer, NewGreetServer())
|
||||
})
|
||||
server.Start()
|
||||
|
||||
@@ -2,10 +2,10 @@ package config
|
||||
|
||||
import (
|
||||
"github.com/tal-tech/go-zero/rest"
|
||||
"github.com/tal-tech/go-zero/rpcx"
|
||||
"github.com/tal-tech/go-zero/zrpc"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
rest.RestConf
|
||||
Transform rpcx.RpcClientConf
|
||||
Transform zrpc.RpcClientConf
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"shorturl/api/internal/config"
|
||||
"shorturl/rpc/transform/transformer"
|
||||
|
||||
"github.com/tal-tech/go-zero/rpcx"
|
||||
"github.com/tal-tech/go-zero/zrpc"
|
||||
)
|
||||
|
||||
type ServiceContext struct {
|
||||
@@ -15,6 +15,6 @@ type ServiceContext struct {
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
Transformer: transformer.NewTransformer(rpcx.MustNewClient(c.Transform)),
|
||||
Transformer: transformer.NewTransformer(zrpc.MustNewClient(c.Transform)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@ package config
|
||||
|
||||
import (
|
||||
"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 {
|
||||
rpcx.RpcServerConf
|
||||
zrpc.RpcServerConf
|
||||
DataSource string
|
||||
Table string
|
||||
Cache cache.CacheConf
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
transform "shorturl/rpc/transform/pb"
|
||||
|
||||
"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"
|
||||
)
|
||||
|
||||
@@ -28,7 +28,7 @@ func main() {
|
||||
ctx := svc.NewServiceContext(c)
|
||||
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)
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
transform "shorturl/rpc/transform/pb"
|
||||
|
||||
"github.com/tal-tech/go-zero/core/jsonx"
|
||||
"github.com/tal-tech/go-zero/rpcx"
|
||||
"github.com/tal-tech/go-zero/zrpc"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -21,11 +21,11 @@ type (
|
||||
}
|
||||
|
||||
defaultTransformer struct {
|
||||
cli rpcx.Client
|
||||
cli zrpc.Client
|
||||
}
|
||||
)
|
||||
|
||||
func NewTransformer(cli rpcx.Client) Transformer {
|
||||
func NewTransformer(cli zrpc.Client) Transformer {
|
||||
return &defaultTransformer{
|
||||
cli: cli,
|
||||
}
|
||||
|
||||
@@ -10,17 +10,17 @@ import (
|
||||
"github.com/tal-tech/go-zero/example/tracing/remote/portal"
|
||||
"github.com/tal-tech/go-zero/rest"
|
||||
"github.com/tal-tech/go-zero/rest/httpx"
|
||||
"github.com/tal-tech/go-zero/rpcx"
|
||||
"github.com/tal-tech/go-zero/zrpc"
|
||||
)
|
||||
|
||||
var (
|
||||
configFile = flag.String("f", "config.json", "the config file")
|
||||
client rpcx.Client
|
||||
client zrpc.Client
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
rest.RestConf
|
||||
Portal rpcx.RpcClientConf
|
||||
Portal zrpc.RpcClientConf
|
||||
}
|
||||
|
||||
func handle(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -41,7 +41,7 @@ func main() {
|
||||
|
||||
var c Config
|
||||
conf.MustLoad(*configFile, &c)
|
||||
client = rpcx.MustNewClient(c.Portal)
|
||||
client = zrpc.MustNewClient(c.Portal)
|
||||
engine := rest.MustNewServer(rest.RestConf{
|
||||
ServiceConf: service.ServiceConf{
|
||||
Log: logx.LogConf{
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"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/user"
|
||||
"github.com/tal-tech/go-zero/rpcx"
|
||||
"github.com/tal-tech/go-zero/zrpc"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
@@ -15,16 +15,16 @@ var configFile = flag.String("f", "etc/config.json", "the config file")
|
||||
|
||||
type (
|
||||
Config struct {
|
||||
rpcx.RpcServerConf
|
||||
UserRpc rpcx.RpcClientConf
|
||||
zrpc.RpcServerConf
|
||||
UserRpc zrpc.RpcClientConf
|
||||
}
|
||||
|
||||
PortalServer struct {
|
||||
userRpc rpcx.Client
|
||||
userRpc zrpc.Client
|
||||
}
|
||||
)
|
||||
|
||||
func NewPortalServer(client rpcx.Client) *PortalServer {
|
||||
func NewPortalServer(client zrpc.Client) *PortalServer {
|
||||
return &PortalServer{
|
||||
userRpc: client,
|
||||
}
|
||||
@@ -53,8 +53,8 @@ func main() {
|
||||
var c Config
|
||||
conf.MustLoad(*configFile, &c)
|
||||
|
||||
client := rpcx.MustNewClient(c.UserRpc)
|
||||
server := rpcx.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
|
||||
client := zrpc.MustNewClient(c.UserRpc)
|
||||
server := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
|
||||
portal.RegisterPortalServer(grpcServer, NewPortalServer(client))
|
||||
})
|
||||
server.Start()
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
"github.com/tal-tech/go-zero/core/conf"
|
||||
"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"
|
||||
)
|
||||
|
||||
@@ -44,10 +44,10 @@ func (gs *UserServer) GetGrade(ctx context.Context, req *user.UserRequest) (*use
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
var c rpcx.RpcServerConf
|
||||
var c zrpc.RpcServerConf
|
||||
conf.MustLoad(*configFile, &c)
|
||||
|
||||
server := rpcx.MustNewServer(c, func(grpcServer *grpc.Server) {
|
||||
server := zrpc.MustNewServer(c, func(grpcServer *grpc.Server) {
|
||||
user.RegisterUserServer(grpcServer, NewUserServer())
|
||||
})
|
||||
server.Start()
|
||||
|
||||
Reference in New Issue
Block a user