Documentation ¶
Overview ¶
Package schedule provides a simple way to schedule functions at a time or interval
Package schedule provides a simple way to schedule functions at a time or interval
Index ¶
- func At(f ScheduledAction, context Context, t time.Time, i time.Duration) chan struct{}
- type ActionContext
- func (c *ActionContext) Config(key string) string
- func (c *ActionContext) Get(key string) interface{}
- func (c *ActionContext) Log(message string)
- func (c *ActionContext) Logf(format string, v ...interface{})
- func (c *ActionContext) Production() bool
- func (c *ActionContext) Set(key string, data interface{})
- type Config
- type Context
- type Logger
- type ScheduledAction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ActionContext ¶
type ActionContext struct {
// contains filtered or unexported fields
}
ActionContext is the scheduled action context, a simplified version of a web request context
func NewContext ¶
func NewContext(l Logger, c Config) *ActionContext
NewContext returns a new context initialised with the given interfaces
func (*ActionContext) Config ¶
func (c *ActionContext) Config(key string) string
Config returns a key from the context config
func (*ActionContext) Get ¶
func (c *ActionContext) Get(key string) interface{}
Get retreives arbitrary data for this request
func (*ActionContext) Log ¶
func (c *ActionContext) Log(message string)
Log logs the given message using our logger
func (*ActionContext) Logf ¶
func (c *ActionContext) Logf(format string, v ...interface{})
Logf logs the given message and arguments using our logger
func (*ActionContext) Production ¶
func (c *ActionContext) Production() bool
Production returns whether this context is running in production
func (*ActionContext) Set ¶
func (c *ActionContext) Set(key string, data interface{})
Set saves arbitrary data for this request
type Context ¶
type Context interface { // Config returns a key from the context config Config(key string) string // Production returns true if we are running in a production environment Production() bool // Store arbitrary data for this request Set(key string, data interface{}) // Retreive arbitrary data for this request Get(key string) interface{} // Log a message Log(message string) // Log a format and arguments Logf(format string, v ...interface{}) }
Context is the context passed to ScheduledActions, a subset of the router.Context interface
type Logger ¶
type Logger interface {
Printf(format string, args ...interface{})
}
Logger Interface for a simple logger (the stdlib log pkg and the fragmenta log pkg conform)
type ScheduledAction ¶
type ScheduledAction func(Context)
ScheduledAction is the function type passed in to be executed at the given time