Documentation ¶
Overview ¶
Package scheduler handles rescheduling resource provider handlers when required by in_progress events.
Index ¶
Constants ¶
const ( HandlerPrepend string = "reinvoke-handler-%s" TargentPrepend string = "reinvoke-target-%s" )
const ( // ServiceInternalError is used when there's a downstream error // in the code. ServiceInternalError string = "ServiceInternal" )
Variables ¶
This section is empty.
Functions ¶
func GenerateOneTimeCronExpression ¶
GenerateOneTimeCronExpression a cron(..) expression for a single instance at Now+minutesFromNow
Example
// Will generate a cron string of: "1 0 0 0 0" scheduler.GenerateOneTimeCronExpression(60, time.Now())
Types ¶
type Result ¶
type Result struct { // Denotes if the computation was done locally. ComputeLocal bool IDS ScheduleIDS }
Result holds the confirmation of the rescheduled invocation.
type ScheduleIDS ¶
type ScheduleIDS struct { // The Cloudwatch target ID. Target string // The Cloudwatch handler ID. Handler string }
ScheduleIDS is of the invocation
func GenerateCloudWatchIDS ¶
func GenerateCloudWatchIDS() (*ScheduleIDS, error)
GenerateCloudWatchIDS creates the targetID and handlerID for invocation
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler is the implementation of the rescheduler of an invoke
Invokes will be rescheduled if a handler takes longer than 60 seconds. The invoke is rescheduled through CloudWatch Events via a CRON expression
func New ¶
func New(client cloudwatcheventsiface.CloudWatchEventsAPI) *Scheduler
New creates a CloudWatchScheduler and returns a pointer to the struct.
func (*Scheduler) CleanupEvents ¶
CleanupEvents is used to clean up Cloudwatch Events. After a re-invocation, the CWE rule which generated the reinvocation should be scrubbed.
func (*Scheduler) Reschedule ¶
func (s *Scheduler) Reschedule(lambdaCtx context.Context, secsFromNow int64, callbackRequest string, invocationIDS *ScheduleIDS) (*Result, error)
Reschedule when a handler requests a sub-minute callback delay, and if the lambda invocation has enough runtime (with 20% buffer), we can reschedule from a thread wait otherwise we re-invoke through CloudWatchEvents which have a granularity of minutes. re-invoke through CloudWatchEvents no less than 1 minute from now.