mirror of
https://github.com/smallnest/rpcx.git
synced 2025-10-16 13:10:39 +08:00
[+]优雅关机
This commit is contained in:
@@ -13,7 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func TestLoop(t *testing.T) {
|
func TestShutdownHook(t *testing.T) {
|
||||||
opt := Option{
|
opt := Option{
|
||||||
Retries: 1,
|
Retries: 1,
|
||||||
RPCPath: share.DefaultRPCPath,
|
RPCPath: share.DefaultRPCPath,
|
||||||
@@ -37,7 +37,7 @@ func TestLoop(t *testing.T) {
|
|||||||
args.B = 100
|
args.B = 100
|
||||||
go func(){
|
go func(){
|
||||||
reply := testutils.ThriftReply{}
|
reply := testutils.ThriftReply{}
|
||||||
err := xclient.Call(context.Background(), "ThriftMul", &args, &reply)
|
err := xclient.Call(context.Background(), "ConsumingOperation", &args, &reply)
|
||||||
fmt.Println(reply.C,err)
|
fmt.Println(reply.C,err)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
@@ -638,7 +638,7 @@ func (s *Server) RegisterOnShutdown(f func(s *Server)) {
|
|||||||
s.mu.Unlock()
|
s.mu.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
var shutdownPollInterval = 500 * time.Millisecond
|
var shutdownPollInterval = 1000 * time.Millisecond
|
||||||
|
|
||||||
// // Shutdown gracefully shuts down the server without interrupting any
|
// // Shutdown gracefully shuts down the server without interrupting any
|
||||||
// // active connections. Shutdown works by first closing the
|
// // active connections. Shutdown works by first closing the
|
||||||
|
@@ -29,7 +29,12 @@ func (t *Arith) Mul(ctx context.Context, args *Args, reply *Reply) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *Arith) ThriftMul(ctx context.Context, args *testutils.ThriftArgs_, reply *testutils.ThriftReply) error {
|
func (t *Arith) ThriftMul(ctx context.Context, args *testutils.ThriftArgs_, reply *testutils.ThriftReply) error {
|
||||||
reply.C = args.A * args.B + 11111111
|
reply.C = args.A * args.B
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *Arith) ConsumingOperation(ctx context.Context, args *testutils.ThriftArgs_, reply *testutils.ThriftReply) error {
|
||||||
|
reply.C = args.A * args.B
|
||||||
time.Sleep(10*time.Second)
|
time.Sleep(10*time.Second)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user