From 62ee484d12c2753402e67a4a8ba8490324e4731b Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 11 Jan 2021 00:03:13 -0800 Subject: [PATCH] refactoring --- weed/command/watch.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/weed/command/watch.go b/weed/command/watch.go index fd7dd6fb2..431a326d7 100644 --- a/weed/command/watch.go +++ b/weed/command/watch.go @@ -76,6 +76,10 @@ func runWatch(cmd *Command, args []string) bool { return false } + eachEntryFunc := func(resp *filer_pb.SubscribeMetadataResponse) { + fmt.Printf("dir:%s %+v\n", resp.Directory, resp.EventNotification) + } + watchErr := pb.WithFilerClient(*watchFiler, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error { ctx, cancel := context.WithCancel(context.Background()) @@ -101,7 +105,7 @@ func runWatch(cmd *Command, args []string) bool { if !shouldPrint(resp) { continue } - fmt.Printf("dir:%s %+v\n", resp.Directory, resp.EventNotification) + eachEntryFunc(resp) } })