Documentation
¶
Index ¶
- Constants
- Variables
- func StartArchivalScheduler(db *sqlx.DB, rdb *redis.Client, checkPeriod time.Duration, ...)
- type ClientNotifier
- type DayOfWeek
- type DefaultHTTPClient
- type Dispatcher
- type Expander
- func (e *Expander) ExpandEvents(ctx context.Context) error
- func (e *Expander) ExpandNonRecurringEvent(ctx context.Context, event *models.Event) error
- func (e *Expander) ExpandRecurringEvent(ctx context.Context, event *models.Event) error
- func (e *Expander) GracePeriod() time.Duration
- func (e *Expander) LookAheadDuration() time.Duration
- func (e *Expander) Run(ctx context.Context) error
- type Frequency
- type HTTPClient
- type Schedule
- type Scheduler
- func (s *Scheduler) AddEvent(ctx context.Context, event *models.Event) error
- func (s *Scheduler) GetDueSchedules(ctx context.Context) (int, error)
- func (s *Scheduler) PopDispatchQueue(ctx context.Context) (*models.Schedule, error)
- func (s *Scheduler) RemoveScheduledEvent(ctx context.Context, occurrence *models.Occurrence) error
- func (s *Scheduler) ScheduleEvent(ctx context.Context, occurrence *models.Occurrence, event *models.Event) error
Constants ¶
const (
// Redis key for scheduled events
ScheduleKey = "schedules"
)
Variables ¶
var TimeNow = func() time.Time { return time.Now() }
Functions ¶
func StartArchivalScheduler ¶
Types ¶
type ClientNotifier ¶
ClientNotifier abstracts WebSocket client dispatch (or use your preferred mock generator)
type DefaultHTTPClient ¶
type DefaultHTTPClient struct {
// contains filtered or unexported fields
}
DefaultHTTPClient implements HTTPClient using http.Client
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
func NewDispatcher ¶
func NewDispatcher(eventRepo *repository.EventRepository, occurrenceRepo *repository.OccurrenceRepository, hmacService *services.HMACService, logger *zap.Logger, maxRetries int, retryDelay time.Duration, clientNotifier ClientNotifier, scheduler *Scheduler, httpClient HTTPClient) *Dispatcher
func (*Dispatcher) DispatchAction ¶
DispatchAction sends a webhook request or dispatches a websocket message based on the event's action type.
func (*Dispatcher) SetHTTPClient ¶
func (d *Dispatcher) SetHTTPClient(client HTTPClient)
SetHTTPClient allows setting a custom HTTP client (used for testing)
type Expander ¶
type Expander struct {
// contains filtered or unexported fields
}
func NewExpander ¶
func NewExpander( scheduler *Scheduler, eventRepo *repository.EventRepository, occurrenceRepo *repository.OccurrenceRepository, lookAheadDuration time.Duration, expansionInterval time.Duration, gracePeriod time.Duration, logger *zap.Logger, ) *Expander
NewExpander creates a new Expander with configurable look-ahead duration and expansion interval
func (*Expander) ExpandEvents ¶
ExpandEvents expands both recurring and non-recurring events into occurrences
func (*Expander) ExpandNonRecurringEvent ¶
func (*Expander) ExpandRecurringEvent ¶
func (*Expander) GracePeriod ¶
func (*Expander) LookAheadDuration ¶
type HTTPClient ¶
HTTPClient interface for mocking HTTP requests
type Schedule ¶
type Schedule struct { Frequency Frequency `json:"frequency"` Interval int `json:"interval"` DaysOfWeek []DayOfWeek `json:"days_of_week,omitempty"` DaysOfMonth []int `json:"days_of_month,omitempty"` Months []int `json:"months,omitempty"` Count *int `json:"count,omitempty"` Until *time.Time `json:"until,omitempty"` }
Schedule represents a JSON-based recurrence schedule
func ParseSchedule ¶
ParseSchedule parses a JSON schedule string and returns a Schedule instance
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
func NewScheduler ¶
func (*Scheduler) GetDueSchedules ¶
GetDueSchedules moves due schedules to the dispatch queue (idempotent version)
func (*Scheduler) PopDispatchQueue ¶
PopDispatchQueue pops a schedule from the dispatch queue (for worker use)
func (*Scheduler) RemoveScheduledEvent ¶
RemoveScheduledEvent removes a scheduled event from Redis (idempotent version)
func (*Scheduler) ScheduleEvent ¶
func (s *Scheduler) ScheduleEvent(ctx context.Context, occurrence *models.Occurrence, event *models.Event) error
ScheduleEvent schedules a single event occurrence using idempotent deterministic keys