Package delay
Overview ▹
Index ▹
type Function ¶
Function represents a function that may have a delayed invocation.
type Function struct {
// contains filtered or unexported fields
}
func Func ¶
func Func(key string, i interface{}) *Function
Func declares a new Function. The second argument must be a function with a first argument of type context.Context. This function must be called at program initialization time. That means it must be called in a global variable declaration or from an init function. This restriction is necessary because the instance that delays a function call may not be the one that executes it. Only the code executed at program initialization time is guaranteed to have been run by an instance before it receives a request.
func (*Function) Call ¶
func (f *Function) Call(c context.Context, args ...interface{}) error
Call invokes a delayed function.
err := f.Call(c, ...)
is equivalent to
t, _ := f.Task(...) _, err := taskqueue.Add(c, t, "")
func (*Function) Task ¶
func (f *Function) Task(args ...interface{}) (*taskqueue.Task, error)
Task creates a Task that will invoke the function. Its parameters may be tweaked before adding it to a queue. Users should not modify the Path or Payload fields of the returned Task.