Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrShutdown = errors.New("shutdown")
Functions ¶
This section is empty.
Types ¶
type BatchProcessor ¶
The BatchProcessor function transforms a list of values into a list of results. The processor MUST produce a result for each input, and the order of the results must be in the same order as the input.
type JobResult ¶
type JobResult[T any] interface { // Block until the result is ready, potentially waiting for the System wait for more jobs and execute the batch. // Can be called multiple times to receive the same value. Get() T }
JobResults contain a reference to Get the eventual result.
type System ¶
type System[A any, B any] interface { // Add a new job to the queue of pending jobs. // Jobs are added to the queue but their execution is delayed until the batch is processed. // Returns a JobResult with the eventual answer. // Can return an error if the System was unable to process the job. Eg, it was shutdown. Submit(job A) (JobResult[B], error) // Stop the system from accepting new jobs and finish any existing jobs. Shutdown() }
A System is configured with a BatchProcessor, a batch size and an interval. the System accepts jobs via `Submit` and returns a `JobResult` which contains a way to get the result when it is eventually ready.
Click to show internal directories.
Click to hide internal directories.