diff options
Diffstat (limited to 'weed/operation/stats.go')
| -rw-r--r-- | weed/operation/stats.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/weed/operation/stats.go b/weed/operation/stats.go index 277b0e835..364727272 100644 --- a/weed/operation/stats.go +++ b/weed/operation/stats.go @@ -2,6 +2,7 @@ package operation import ( "context" + "time" "github.com/chrislusf/seaweedfs/weed/pb/master_pb" ) @@ -9,7 +10,10 @@ import ( func Statistics(server string, req *master_pb.StatisticsRequest) (resp *master_pb.StatisticsResponse, err error) { err = withMasterServerClient(server, func(masterClient master_pb.SeaweedClient) error { - grpcResponse, grpcErr := masterClient.Statistics(context.Background(), req) + ctx, cancel := context.WithTimeout(context.Background(), time.Duration(5*time.Second)) + defer cancel() + + grpcResponse, grpcErr := masterClient.Statistics(ctx, req) if grpcErr != nil { return grpcErr } |
