8000 feat: enhance repeatPolicy with explicit while/until modes · Issue #1043 · dagu-org/dagu · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
feat: enhance repeatPolicy with explicit while/until modes #1043
@yottahmd

Description

@yottahmd

The current repeatPolicy has implicit behavior that changes based on configuration:

  • condition + expected: Repeats until condition matches expected
  • condition only: Repeats while condition returns exit code 0
  • exitCode: Repeats while exit code matches

This implicit behavior is confusing. For example, to monitor while a service is "RUNNING", you have to think backwards and set it to repeat until it's NOT running.

Solution

Add an explicit mode field to repeatPolicy:

# Clear intent: repeat WHILE status is RUNNING
steps:
  - name: monitor-service
    command: check_status.sh
    output: STATUS
    repeatPolicy:
      repeat: while
      condition: "${STATUS}"
      expected: "RUNNING"
      intervalSec: 30

Examples

# Wait UNTIL service is ready
repeatPolicy:
  repeat: until
  condition: "nc -z localhost 8080"
  intervalSec: 5

# Retry WHILE failing
repeatPolicy:
  repeat: while
  exitCode: [1]
  intervalSec: 10
  limit: 5

# Monitor WHILE healthy
repeatPolicy:
  repeat: while
  condition: "curl -f http://localhost/health"
  intervalSec: 60

Implementation

  1. Update repeat field type in RepeatPolicy struct to RepeatMode
  2. Accept constants values: whi 4ECD le or until
  3. Maintain backward compatibility by inferring mode when not specified:
    • repeat: true or unspecified (empty) -> defaults to while
  4. Add integration test
  5. Update the json schema
  6. Update the documentation on repeat policy

Benefits

  • Clear Intent: No more mental gymnastics to invert logic
  • Better DX: repeat: while is self-documenting

I’d appreciate any thoughts or suggestions you might have about this feature.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0