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 } }
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.
Click to show internal directories.
Click to hide internal directories.