[+]优雅关机

This commit is contained in:
goodjava@qq.com
2018-06-29 13:14:45 +08:00
parent bf13dee8f6
commit b1f485da35
3 changed files with 9 additions and 4 deletions

View File

@@ -13,7 +13,7 @@ import (
)
func TestLoop(t *testing.T) {
func TestShutdownHook(t *testing.T) {
opt := Option{
Retries: 1,
RPCPath: share.DefaultRPCPath,
@@ -37,7 +37,7 @@ func TestLoop(t *testing.T) {
args.B = 100
go func(){
reply := testutils.ThriftReply{}
err := xclient.Call(context.Background(), "ThriftMul", &args, &reply)
err := xclient.Call(context.Background(), "ConsumingOperation", &args, &reply)
fmt.Println(reply.C,err)
}()
}

View File

@@ -638,7 +638,7 @@ func (s *Server) RegisterOnShutdown(f func(s *Server)) {
s.mu.Unlock()
}
var shutdownPollInterval = 500 * time.Millisecond
var shutdownPollInterval = 1000 * time.Millisecond
// // Shutdown gracefully shuts down the server without interrupting any
// // active connections. Shutdown works by first closing the

View File

@@ -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 {
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)
return nil
}