mirror of
https://codeberg.org/scip/esctl.git
synced 2026-08-24 09:44:17 +02:00
add alias+datastream rollover, and auto rollover on index tpl change (#40)
fixes #37
This commit is contained in:
@@ -37,6 +37,7 @@ func Datastream(conf *cfg.Config) *cli.Command {
|
||||
DatastreamShow(conf),
|
||||
DatastreamCreate(conf),
|
||||
DatastreamDelete(conf),
|
||||
DatastreamRollover(conf),
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -138,3 +139,61 @@ func DatastreamDelete(conf *cfg.Config) *cli.Command {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func DatastreamRollover(conf *cfg.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "rollover",
|
||||
Aliases: []string{"roll"},
|
||||
Usage: "roll over a data stream",
|
||||
UsageText: "rollover <data stream>",
|
||||
|
||||
ShellComplete: func(ctx context.Context, cmd *cli.Command) {
|
||||
complete(cmd, Cindex)
|
||||
},
|
||||
|
||||
Flags: []cli.Flag{
|
||||
&cli.BoolFlag{
|
||||
Name: "wait",
|
||||
Usage: "wait for active shards",
|
||||
Destination: &conf.Wait,
|
||||
Aliases: []string{"w"},
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "dry-run",
|
||||
Usage: "checks conditions but does not perform a rollover",
|
||||
Destination: &conf.Wait,
|
||||
Aliases: []string{"n"},
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "max-age",
|
||||
Usage: "roll over after max age (eg: 7d, 2m, 8h)",
|
||||
Destination: &conf.MaxAge,
|
||||
},
|
||||
&cli.IntFlag{
|
||||
Name: "max-docs",
|
||||
Usage: "roll over after max docs",
|
||||
Destination: &conf.MaxDocs,
|
||||
},
|
||||
&cli.IntFlag{
|
||||
Name: "max-primary-shard-size",
|
||||
Usage: "roll over when primary shard size reaches size",
|
||||
Destination: &conf.MaxShardSize,
|
||||
},
|
||||
&cli.IntFlag{
|
||||
Name: "max-primary-shard-docs",
|
||||
Usage: "roll over after max docs in primary shard reached",
|
||||
Destination: &conf.MaxShardDocs,
|
||||
},
|
||||
},
|
||||
|
||||
Action: func(ctx context.Context, cmd *cli.Command) error {
|
||||
alias := cmd.Args().Get(0)
|
||||
|
||||
if alias == "" {
|
||||
return errors.New("no data stream specified")
|
||||
}
|
||||
|
||||
return es.DatastreamRollover(conf, alias)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user