pool

package
v0.0.0-...-2c5973f Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: GPL-2.0 Imports: 1 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Base

type Base interface {
	Close() error
	CloseSignal() <-chan error
}

type DetachSubmitResult

type DetachSubmitResult[S any] struct {
	Err    error
	Result S
	Id     int
}

type Job

type Job[T any] struct {
	// contains filtered or unexported fields
}

func CreateJob

func CreateJob[T any](parentCtx context.Context, payload T) (context.CancelFunc, Job[T])

func (Job[T]) Ctx

func (j Job[T]) Ctx() context.Context

func (Job[T]) Payload

func (j Job[T]) Payload() T

type Manager

type Manager[T, S any] interface {
	Base
	// add a worker to the pool
	Add(Worker[T, S]) error
	// submit a payload to be done
	Submit(context.Context, T) (S, error)
	// only send an error if there is an error
	DetachSubmit(context.Context, T, int, chan<- error)
}

type Result

type Result[T any] struct {
	// contains filtered or unexported fields
}

func CreateResult

func CreateResult[T any](payload T) Result[T]

func ResultFromError

func ResultFromError[T any](err error) Result[T]

func (Result[T]) Err

func (j Result[T]) Err() error

func (Result[T]) Payload

func (j Result[T]) Payload() T

type Worker

type Worker[T, S any] interface {
	Base
	Run(Job[T]) (S, error)
}

Jump to

Keyboard shortcuts

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