Repository navigation
Description
Summary
Add an EventBridge Scheduler plugin (scheduler_plugin.go) to emulate the Amazon EventBridge Scheduler REST API. This is needed by spore-host/spawn to test sweep scheduling logic without real AWS credentials.
Operations to implement
| Operation | HTTP method + path |
|---|---|
CreateSchedule |
POST /schedules/{Name} |
UpdateSchedule |
PUT /schedules/{Name} |
DeleteSchedule |
DELETE /schedules/{Name} |
GetSchedule |
GET /schedules/{Name} |
ListSchedules |
GET /schedules |
Design notes
Follow the pattern of eventbridge_plugin.go / apigatewayv2_plugin.go:
- Plugin struct with
StateManager,Logger,TimeController - Service name:
"scheduler"— matches the SigV4 credential scope used by the AWS SDK v2schedulerpackage - Protocol: REST-JSON (no
X-Amz-Target); routing is path + HTTP method, likeAPIGatewayV2Plugin - State keys:
sched:{accountID}/{region}/{groupName}/{name} - Name index:
sched_names:{accountID}/{region}(viaupdateStringIndex/loadStringIndex) - Default group name:
"default"(used whenGroupNameis absent from request body / query params)
Key data structures
type SchedulerRecord struct {
Name string
GroupName string
ScheduleExpression string
ScheduleExpressionTimezone string
State string // "ENABLED" | "DISABLED"
Target SchedulerTarget
FlexibleTimeWindow SchedulerFlexibleTimeWindow
Description string
Arn string
CreationDate time.Time
LastModificationDate time.Time
ClientToken string
}
type SchedulerTarget struct {
Arn string
RoleArn string
Input string
RetryPolicy *SchedulerRetryPolicy
}
type SchedulerFlexibleTimeWindow struct {
Mode string // "OFF" | "FLEXIBLE"
MaximumWindowInMinutes int32
}Response shapes
CreateSchedule / UpdateSchedule → {"ScheduleArn": "arn:aws:scheduler:…"}
GetSchedule → full SchedulerRecord (all fields)
DeleteSchedule → HTTP 200, empty body
ListSchedules → {"Schedules": [{Arn, Name, GroupName, State, CreationDate, LastModificationDate, Target:{Arn}}], "NextToken": "…"}
Query params for ListSchedules: groupName, namePrefix, maxResults, nextToken, state
Registration
Register in RegisterDefaultPlugins in plugins.go, next to ebPlugin:
schedulerPlugin := &SchedulerPlugin{}
if err := schedulerPlugin.Initialize(ctx, PluginConfig{
State: state,
Logger: logger,
Options: map[string]any{"time_controller": tc},
}); err != nil {
return fmt.Errorf("initialize scheduler plugin: %w", err)
}
registry.Register(schedulerPlugin)Caller context
spore-host/spawn/pkg/scheduler/scheduler.go uses CreateSchedule, UpdateSchedule, and DeleteSchedule via the AWS SDK v2 scheduler package. The SchedulerAPI interface is:
type SchedulerAPI interface {
CreateSchedule(ctx, *scheduler.CreateScheduleInput, ...func(*scheduler.Options)) (*scheduler.CreateScheduleOutput, error)
DeleteSchedule(ctx, *scheduler.DeleteScheduleInput, ...func(*scheduler.Options)) (*scheduler.DeleteScheduleOutput, error)
UpdateSchedule(ctx, *scheduler.UpdateScheduleInput, ...func(*scheduler.Options)) (*scheduler.UpdateScheduleOutput, error)
}Once this plugin exists, spore-host will add github.com/scttfrdmn/substrate as a test dependency and migrate tests off hand-written mocks.
Activity
Release v0.42.0: EventBridge Scheduler plugin
scttfrdmn commentedon Mar 20, 2026
Implemented in v0.42.0.