Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: fail after 5 messages, add option to limit by message count #395

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion cmd/project/project_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var projectWorkerCmd = &cobra.Command{
memoryLimit, _ := cobraCmd.Flags().GetString("memory-limit")
timeLimit, _ := cobraCmd.Flags().GetString("time-limit")
gracefulStopLimit, _ := cobraCmd.Flags().GetUint("graceful-stop-limit")
messagesLimit, _ := cobraCmd.Flags().GetUint("limit")

if projectRoot, err = findClosestShopwareProject(); err != nil {
return err
Expand All @@ -56,7 +57,16 @@ var projectWorkerCmd = &cobra.Command{
cancelCtx, cancel := context.WithCancel(cobraCmd.Context())
cancelOnTermination(cancelCtx, cancel)

consumeArgs := []string{"messenger:consume", fmt.Sprintf("--memory-limit=%s", memoryLimit), fmt.Sprintf("--time-limit=%s", timeLimit)}
consumeArgs := []string{
"messenger:consume",
fmt.Sprintf("--memory-limit=%s", memoryLimit),
fmt.Sprintf("--time-limit=%s", timeLimit),
"--failure-limit=5",
}

if messagesLimit > 0 {
consumeArgs = append(consumeArgs, fmt.Sprintf("--limit=%d", messagesLimit))
}

if queuesToConsume == "" {
if is, _ := shop.IsShopwareVersion(projectRoot, ">=6.5.7"); is {
Expand Down Expand Up @@ -128,6 +138,7 @@ func init() {
projectWorkerCmd.PersistentFlags().String("memory-limit", "", "Memory Limit")
projectWorkerCmd.PersistentFlags().String("time-limit", "", "Time Limit")
projectWorkerCmd.PersistentFlags().Uint("graceful-stop-limit", 0, "Graceful Stop Limit")
projectWorkerCmd.PersistentFlags().Uint("limit", 0, "Messages Limit")
}

func cancelOnTermination(ctx context.Context, cancel context.CancelFunc) {
Expand Down