Class ScheduleConfig.Builder

java.lang.Object
io.agentscope.extensions.scheduler.config.ScheduleConfig.Builder
Enclosing class:
ScheduleConfig

public static class ScheduleConfig.Builder extends Object
Builder for creating ScheduleConfig instances.
  • Method Details

    • cron

      public ScheduleConfig.Builder cron(String expression)
      Configure a cron-based schedule.

      The cron expression follows the standard format:

       ┌───────────── second (0-59)
       │ ┌───────────── minute (0-59)
       │ │ ┌───────────── hour (0-23)
       │ │ │ ┌───────────── day of month (1-31)
       │ │ │ │ ┌───────────── month (1-12 or JAN-DEC)
       │ │ │ │ │ ┌───────────── day of week (0-6 or SUN-SAT)
       │ │ │ │ │ │
       * * * * * *
       

      Examples:

      • "0 0 8 * * ?" - Every day at 8:00 AM
      • "0 0/30 * * * ?" - Every 30 minutes
      • "0 0 9 * * MON-FRI" - Every weekday at 9:00 AM
      Parameters:
      expression - The cron expression
      Returns:
      This builder
    • fixedRate

      public ScheduleConfig.Builder fixedRate(Long rate)
      Configure a fixed-rate schedule.

      The task will be executed at a fixed rate. If a previous execution is still running, the next execution may start immediately after the previous one completes (depending on the scheduler implementation's concurrency policy).

      Example: If set to 5 minutes, the task will execute at T, T+5min, T+10min, etc., regardless of how long each execution takes.

      Parameters:
      rate - The fixed rate duration between executions in milliseconds
      Returns:
      This builder
    • fixedDelay

      public ScheduleConfig.Builder fixedDelay(Long delay)
      Configure a fixed-delay schedule.

      The task will be executed with a fixed delay between the completion of one execution and the start of the next.

      Example: If set to 5 minutes and an execution takes 2 minutes, the next execution will start 5 minutes after completion (i.e., 7 minutes after the previous execution started).

      Parameters:
      delay - The fixed delay duration between completion and next execution in milliseconds
      Returns:
      This builder
    • initialDelay

      public ScheduleConfig.Builder initialDelay(Long delay)
      Set the initial delay before the first execution.

      This is applicable to all schedule types. The scheduler will wait for this duration before executing the task for the first time.

      Parameters:
      delay - The initial delay in milliseconds
      Returns:
      This builder
    • zoneId

      public ScheduleConfig.Builder zoneId(String zoneIdStr)
      Set the time zone ID for cron expression evaluation.

      This is only applicable for CRON schedules. If not specified, the system default time zone will be used.

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

      Parameters:
      zoneIdStr - The time zone ID string (e.g., "Asia/Shanghai")
      Returns:
      This builder
    • build

      public ScheduleConfig build()
      Build the ScheduleConfig instance.
      Returns:
      A new ScheduleConfig instance
      Throws:
      IllegalArgumentException - if the configuration is invalid