asynq

package
v0.18.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BatchTask

func BatchTask() worker.TaskOption

BatchTask configures a task to process a list of tasks in batches. Each task payload will be aggregated, separated by '\n'. Example:

func(ctx context.Context, payload []byte) error {
    scanner := bufio.NewScanner(bytes.NewReader(payload))
    scanner.Split(bufio.ScanLines)

    for scanner.Scan() {
        // Process each task payload
    }
}

func NewClient

func NewClient(redisURI string) (worker.Client, error)

func NewServer

func NewServer(redisURI string, opts ...ServerOption) worker.Server

func Unique added in v0.17.2

func Unique() worker.CronjobOption

Unique configures a cron job to prevent concurrent processing. When enabled, the job will not be enqueued or executed again until it completes or the timeout specified in `SHELLHUB_ASYNQ_UNIQUENESS_TIMEOUT` is reached.

Types

type ServerOption

type ServerOption func(s *server) error

func BatchConfig

func BatchConfig(maxSize, maxDelay, gracePeriod int) ServerOption

BatchConfig sets the batch configuration of the server. It's required when setting a task with BatchTask option.

maxSize is the maximum number of tasks that a batch task can handle before processing.

maxDelay is the maximum amount of time that a batch task can wait before processing.

gracePeriod is the amount of time that the server will wait before aggregating batch tasks.

func UniquenessTimeout added in v0.17.2

func UniquenessTimeout(timeout int) ServerOption

UniquenessTimeout defines the maximum duration, in hours, for which a unique job remains locked in the queue. If the job does not complete within this timeout, the lock is released, allowing a new instance of the job to be enqueued and executed.

Jump to

Keyboard shortcuts

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