scheduler

package
v1.0.1-0...-b79cbba Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package scheduler handles rescheduling resource provider handlers when required by in_progress events.

Index

Constants

View Source
const (
	HandlerPrepend string = "reinvoke-handler-%s"
	TargentPrepend string = "reinvoke-target-%s"
)
View Source
const (
	// ServiceInternalError is used when there's a downstream error
	// in the code.
	ServiceInternalError string = "ServiceInternal"
)

Variables

This section is empty.

Functions

func GenerateOneTimeCronExpression

func GenerateOneTimeCronExpression(secFromNow int64, t time.Time) string

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

New creates a CloudWatchScheduler and returns a pointer to the struct.

func (*Scheduler) CleanupEvents

func (s *Scheduler) CleanupEvents(ruleName string, targetID string) error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL