mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-13 00:22:26 +08:00
feat:rpc gs增加gm接口
This commit is contained in:
29
gm/rpc_client/client.go
Normal file
29
gm/rpc_client/client.go
Normal file
@@ -0,0 +1,29 @@
|
||||
// Package rpc_client rpc客户端
|
||||
package rpc_client
|
||||
|
||||
import (
|
||||
"hk4e/gs/api"
|
||||
|
||||
"github.com/nats-io/nats.go"
|
||||
"github.com/nats-io/nats.go/encoders/protobuf"
|
||||
)
|
||||
|
||||
// Client rpc客户端
|
||||
type Client struct {
|
||||
api.GMNATSRPCClient
|
||||
}
|
||||
|
||||
// New 构造
|
||||
func New(conn *nats.Conn) (*Client, error) {
|
||||
enc, err := nats.NewEncodedConn(conn, protobuf.PROTOBUF_ENCODER)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cli, err := api.NewGMNATSRPCClient(enc)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Client{
|
||||
GMNATSRPCClient: cli,
|
||||
}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user