Class ScheduleConfig

java.lang.Object
io.agentscope.extensions.scheduler.config.ScheduleConfig

public class ScheduleConfig extends Object
Configuration for scheduled agent tasks.

This class defines the scheduling parameters for an agent, including the scheduling type (cron, fixed rate, or fixed delay) and associated timing settings.

Supported Scheduling Modes:

  • NONE - No automatic scheduling (default mode, manual execution only)
  • CRON - Schedule using a cron expression (e.g., "0 0 8 * * ?" for daily at 8 AM)
  • FIXED_RATE - Execute at a fixed rate (e.g., every 5 minutes, regardless of execution time)
  • FIXED_DELAY - Execute with a fixed delay between completion and next start

Usage Examples:


 // Cron-based scheduling
 ScheduleConfig config1 = ScheduleConfig.builder()
     .cron("0 0 8 * * ?")
     .zoneId("Asia/Shanghai")
     .build();

 // Fixed rate scheduling (every 5 minutes)
 ScheduleConfig config2 = ScheduleConfig.builder()
     .fixedRate(5L)
     .initialDelay(10L)
     .build();

 // Fixed delay scheduling (5 minutes after completion)
 ScheduleConfig config3 = ScheduleConfig.builder()
     .fixedDelay(5L)
     .build();
 
See Also:
  • Method Details

    • builder

      public static ScheduleConfig.Builder builder()
      Create a new builder instance.
      Returns:
      A new ScheduleConfig.Builder
    • getScheduleMode

      public ScheduleMode getScheduleMode()
      Get the schedule mode.
      Returns:
      The schedule mode
    • getCronExpression

      public String getCronExpression()
      Get the cron expression (only applicable for CRON type).
      Returns:
      The cron expression, or null if not a CRON schedule
    • getFixedRate

      public Long getFixedRate()
      Get the fixed rate duration in milliseconds (only applicable for FIXED_RATE type).
      Returns:
      The fixed rate duration in milliseconds, or null if not a FIXED_RATE schedule
    • getFixedDelay

      public Long getFixedDelay()
      Get the fixed delay duration in milliseconds (only applicable for FIXED_DELAY type).
      Returns:
      The fixed delay duration in milliseconds, or null if not a FIXED_DELAY schedule
    • getInitialDelay

      public Long getInitialDelay()
      Get the initial delay in milliseconds before the first execution.
      Returns:
      The initial delay in milliseconds, or null if no initial delay is configured
    • getZoneId

      public String getZoneId()
      Get the time zone ID for cron expression evaluation.

      Examples: "Asia/Shanghai", "America/New_York", "UTC"

      Returns:
      The time zone ID string (e.g., "Asia/Shanghai"), or null to use system default