Documentation
¶
Overview ¶
Package delay provides a task queue abstraction for background job execution. This is a standalone implementation that replaces the google.golang.org/appengine/delay package.
Index ¶
- Constants
- Variables
- func Later(ctx context.Context, delay time.Duration, fn func(context.Context) error) error
- func Now(ctx context.Context, fn func(context.Context) error) error
- func RunFunc(c context.Context, w http.ResponseWriter, req *http.Request)
- type Function
- type RequestHeaders
- type Task
- type TaskOptions
Constants ¶
const (
// Path is the HTTP path for invocations (maintained for compatibility)
Path = "/_/queue/delay"
)
Variables ¶
Functions ¶
func Later ¶
Later executes a function after a delay. This is a simpler API for one-off delayed tasks.
Types ¶
type Function ¶
type Function struct {
// contains filtered or unexported fields
}
Function wraps a delayed function with queue configuration
func Func ¶
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 ¶
Call invokes a delayed function asynchronously using goroutines. The function is executed in a background goroutine after any configured delay.
func (*Function) Once ¶
func (f *Function) Once(ctx context.Context, name string, delay time.Duration, args ...interface{}) error
Once adds a task only once by using a unique name. This prevents duplicate task execution.
type RequestHeaders ¶
RequestHeaders contains metadata from the task queue request. This replaces taskqueue.RequestHeaders from appengine.
func GetRequestHeaders ¶
func GetRequestHeaders(ctx context.Context) *RequestHeaders
GetRequestHeaders retrieves the task queue headers from the context. Returns nil if called outside of a delay function execution.
func ParseRequestHeaders ¶
func ParseRequestHeaders(h http.Header) *RequestHeaders
ParseRequestHeaders extracts task queue headers from an HTTP request. This is a compatibility function for HTTP-based task invocation.