Skip to content

Commit

Permalink
support show segment according to target state (#84) (#85)
Browse files Browse the repository at this point in the history
Signed-off-by: MrPresent-Han <[email protected]>
  • Loading branch information
MrPresent-Han authored Jan 19, 2023
1 parent 9af60ee commit 22a9d74
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion states/etcd/show/segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,15 @@ func SegmentCommand(cli *clientv3.Client, basePath string) *cobra.Command {
if err != nil {
return err
}
state, err := cmd.Flags().GetString("state")
if err != nil {
return err
}

segments, err := common.ListSegments(cli, basePath, func(info *datapb.SegmentInfo) bool {
return (collID == 0 || info.CollectionID == collID) &&
(segmentID == 0 || info.ID == segmentID)
(segmentID == 0 || info.ID == segmentID) &&
(state == "" || info.State.String() == state)
})
if err != nil {
fmt.Println("failed to list segments", err.Error())
Expand Down Expand Up @@ -99,6 +104,7 @@ func SegmentCommand(cli *clientv3.Client, basePath string) *cobra.Command {
cmd.Flags().String("format", "line", "segment display format")
cmd.Flags().Bool("detail", false, "flags indicating whether pring detail binlog info")
cmd.Flags().Int64("segment", 0, "segment id to filter with")
cmd.Flags().String("state", "", "target segment state")
return cmd
}

Expand Down

0 comments on commit 22a9d74

Please sign in to comment.