From a5ce359999a19c9fbbe8c8f9eed955d0900daaad Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Thu, 26 Mar 2020 22:46:49 -0700 Subject: [PATCH] refactoring --- weed/operation/stats.go | 26 -------------------------- weed/server/filer_grpc_server.go | 21 +++++++++++++++------ 2 files changed, 15 insertions(+), 32 deletions(-) delete mode 100644 weed/operation/stats.go diff --git a/weed/operation/stats.go b/weed/operation/stats.go deleted file mode 100644 index b69a33750..000000000 --- a/weed/operation/stats.go +++ /dev/null @@ -1,26 +0,0 @@ -package operation - -import ( - "context" - "google.golang.org/grpc" - - "github.com/chrislusf/seaweedfs/weed/pb/master_pb" -) - -func Statistics(server string, grpcDialOption grpc.DialOption, req *master_pb.StatisticsRequest) (resp *master_pb.StatisticsResponse, err error) { - - err = WithMasterServerClient(server, grpcDialOption, func(masterClient master_pb.SeaweedClient) error { - - grpcResponse, grpcErr := masterClient.Statistics(context.Background(), req) - if grpcErr != nil { - return grpcErr - } - - resp = grpcResponse - - return nil - - }) - - return -} diff --git a/weed/server/filer_grpc_server.go b/weed/server/filer_grpc_server.go index abdfb1e46..4b71c1fb5 100644 --- a/weed/server/filer_grpc_server.go +++ b/weed/server/filer_grpc_server.go @@ -293,13 +293,22 @@ func (fs *FilerServer) DeleteCollection(ctx context.Context, req *filer_pb.Delet func (fs *FilerServer) Statistics(ctx context.Context, req *filer_pb.StatisticsRequest) (resp *filer_pb.StatisticsResponse, err error) { - input := &master_pb.StatisticsRequest{ - Replication: req.Replication, - Collection: req.Collection, - Ttl: req.Ttl, - } + var output *master_pb.StatisticsResponse + + err = fs.filer.MasterClient.WithClient(func(masterClient master_pb.SeaweedClient) error { + grpcResponse, grpcErr := masterClient.Statistics(context.Background(), &master_pb.StatisticsRequest{ + Replication: req.Replication, + Collection: req.Collection, + Ttl: req.Ttl, + }) + if grpcErr != nil { + return grpcErr + } + + output = grpcResponse + return nil + }) - output, err := operation.Statistics(fs.filer.GetMaster(), fs.grpcDialOption, input) if err != nil { return nil, err }