Skip to content

feat: Add EventBridge Scheduler plugin #228

Closed

Description

@scttfrdmn

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 v2 scheduler package
  • Protocol: REST-JSON (no X-Amz-Target); routing is path + HTTP method, like APIGatewayV2Plugin
  • State keys: sched:{accountID}/{region}/{groupName}/{name}
  • Name index: sched_names:{accountID}/{region} (via updateStringIndex / loadStringIndex)
  • Default group name: "default" (used when GroupName is 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

  1. scttfrdmn commented on Mar 20, 2026

    @scttfrdmn
    OwnerAuthor

    Implemented in v0.42.0.

  2. added
    type: feature
    and removed on Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions