Skip to content

Commit

Permalink
Add parallels flag
Browse files Browse the repository at this point in the history
  • Loading branch information
daaru00 committed Mar 15, 2021
1 parent 9191955 commit 744d637
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
11 changes: 8 additions & 3 deletions cmd/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ func NewCommand(globalFlags []cli.Flag) *cli.Command {
Aliases: []string{"a"},
Usage: "Select all documents",
},
&cli.IntFlag{
Name: "parallels",
Usage: "Set max deploy executed in parallel",
Value: 5,
},
}...),
Action: Action,
ArgsUsage: "[path...]",
Expand Down Expand Up @@ -90,12 +95,12 @@ func Action(c *cli.Context) error {

// Setup max parallels
allDocuments := *documents
parallel := 10
parallels := c.Int("parallels")

// Start parallel deploy
for start := 0; start < len(allDocuments); start += parallel {
for start := 0; start < len(allDocuments); start += parallels {
// Update chunk start and end
end := start + parallel
end := start + parallels
if end > len(allDocuments) {
end = len(allDocuments)
}
Expand Down
11 changes: 8 additions & 3 deletions cmd/remove/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ func NewCommand(globalFlags []cli.Flag) *cli.Command {
Aliases: []string{"a"},
Usage: "Select all documents",
},
&cli.IntFlag{
Name: "parallels",
Usage: "Set max remove executed in parallel",
Value: 5,
},
}...),
Action: Action,
ArgsUsage: "[path...]",
Expand Down Expand Up @@ -92,12 +97,12 @@ func Action(c *cli.Context) error {

// Setup max parallels
allDocuments := *documents
parallel := 10
parallels := c.Int("parallels")

// Start parallel deploy
for start := 0; start < len(allDocuments); start += parallel {
for start := 0; start < len(allDocuments); start += parallels {
// Update chunk start and end
end := start + parallel
end := start + parallels
if end > len(allDocuments) {
end = len(allDocuments)
}
Expand Down

0 comments on commit 744d637

Please sign in to comment.