schedule

package
v1.5.5 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2017 License: MIT Imports: 1 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func At

func At(f ScheduledAction, context Context, t time.Time, i time.Duration) chan struct{}

At schedules execution for a particular time and at intervals thereafter. If interval is 0, the function will be called only once. Callers should call close(task) before exiting the app or to stop repeating the action.

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 Config

type Config interface {
	Production() bool
	Config(string) string
}

Config Interface to retreive configuration details of the server

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

Jump to

Keyboard shortcuts

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