metadata log: read from any timestamp

This commit is contained in:
Chris Lu
2020-04-27 23:49:46 -07:00
parent 47c4a62c5d
commit 5c57297bd1
3 changed files with 92 additions and 12 deletions

View File

@@ -4,6 +4,7 @@ import (
"context"
"fmt"
"io"
"time"
"github.com/chrislusf/seaweedfs/weed/pb"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
@@ -26,6 +27,7 @@ var cmdWatch = &Command{
var (
watchFiler = cmdWatch.Flag.String("filer", "localhost:8888", "filer hostname:port")
watchTarget = cmdWatch.Flag.String("pathPrefix", "/", "path to a folder or file, or common prefix for the folders or files on filer")
watchStart = cmdWatch.Flag.Duration("timeAgo", 0, "start time before now. \"300ms\", \"1.5h\" or \"2h45m\". Valid time units are \"ns\", \"us\" (or \"µs\"), \"ms\", \"s\", \"m\", \"h\"")
)
func runWatch(cmd *Command, args []string) bool {
@@ -37,7 +39,7 @@ func runWatch(cmd *Command, args []string) bool {
stream, err := client.SubscribeMetadata(context.Background(), &filer_pb.SubscribeMetadataRequest{
ClientName: "watch",
PathPrefix: *watchTarget,
SinceNs: 0,
SinceNs: time.Now().Add(-*watchStart).UnixNano(),
})
if err != nil {
return fmt.Errorf("listen: %v", err)