Class ScheduleConfig
java.lang.Object
io.agentscope.extensions.scheduler.config.ScheduleConfig
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for creating ScheduleConfig instances. -
Method Summary
Modifier and TypeMethodDescriptionstatic ScheduleConfig.Builderbuilder()Create a new builder instance.Get the cron expression (only applicable for CRON type).Get the fixed delay duration in milliseconds (only applicable for FIXED_DELAY type).Get the fixed rate duration in milliseconds (only applicable for FIXED_RATE type).Get the initial delay in milliseconds before the first execution.Get the schedule mode.Get the time zone ID for cron expression evaluation.
-
Method Details
-
builder
Create a new builder instance.- Returns:
- A new ScheduleConfig.Builder
-
getScheduleMode
Get the schedule mode.- Returns:
- The schedule mode
-
getCronExpression
Get the cron expression (only applicable for CRON type).- Returns:
- The cron expression, or null if not a CRON schedule
-
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
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
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
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
-