boost

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 13 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// TODO: This is just temporary, channel size definition still needs to be
	// fine tuned
	//
	DefaultChSize = 100
)
View Source
const (
	MaxWorkers = 100
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AnnotatedWaitGroup

type AnnotatedWaitGroup struct {
	// contains filtered or unexported fields
}

AnnotatedWaitGroup is a wrapper around the standard WaitGroup that provides annotations to wait group operations that can assist in diagnosing concurrency issues.

func (*AnnotatedWaitGroup) Add

func (d *AnnotatedWaitGroup) Add(delta int, name ...GoRoutineName)

Add wraps the standard WaitGroup Add operation with the addition of being able to associate a go routine (identified by a client provided name) with the Add request.

func (*AnnotatedWaitGroup) Count

func (d *AnnotatedWaitGroup) Count() int

func (*AnnotatedWaitGroup) Done

func (d *AnnotatedWaitGroup) Done(name ...GoRoutineName)

Done wraps the standard WaitGroup Done operation with the addition of being able to associate a go routine (identified by a client provided name) with the Done request.

func (*AnnotatedWaitGroup) Wait

func (d *AnnotatedWaitGroup) Wait(name ...GoRoutineName)

Wait wraps the standard WaitGroup Wait operation with the addition of being able to associate a go routine (identified by a client provided name) with the Wait request.

type AnnotatedWgAQ

type AnnotatedWgAQ interface {
	AnnotatedWgAdder
	AnnotatedWgQuitter
}

AnnotatedWgAQ is the interface that is a restricted view of a wait group that allows adding to the wait group and Done signalling with the addition of being able to specify the name representing the calling go routine. This interface can be acquired from the wait group using a standard interface type query.

type AnnotatedWgAdder

type AnnotatedWgAdder interface {
	Add(delta int, name ...GoRoutineName)
}

AnnotatedWgAdder is the interface that is a restricted view of a wait group that only allows adding to the wait group with the addition of being able to specify the name representing the calling go routine. This interface can be acquired from the wait group using a standard interface type query.

type AnnotatedWgCounter

type AnnotatedWgCounter interface {
	Count() int
}

AnnotatedWgCounter is the interface that is a restricted view of a wait group that only allows querying the wait group count. This interface can be acquired from the wait group using a standard interface type query.

type AnnotatedWgQuitter

type AnnotatedWgQuitter interface {
	Done(name ...GoRoutineName)
}

AnnotatedWgQuitter is the interface that is a restricted view of a wait group that only allows Done signalling on the wait group with the addition of being able to specify the name representing the calling go routine. This interface can be acquired from the wait group using a standard interface type query.

type AnnotatedWgWaiter

type AnnotatedWgWaiter interface {
	Wait(name ...GoRoutineName)
}

AnnotatedWgWaiter is the interface that is a restricted view of a wait group that only allows waiting on the wait group with the addition of being able to specify the name representing the calling go routine. This interface can be acquired from the wait group using a standard interface type query.

type CancelStream

type CancelStream = chan CancelWorkSignal

type CancelStreamR

type CancelStreamR = <-chan CancelWorkSignal

type CancelStreamW

type CancelStreamW = chan<- CancelWorkSignal

type CancelWorkSignal

type CancelWorkSignal struct{}

type Duplex added in v0.4.0

type Duplex[T any] struct {
	Channel  chan T
	ReaderCh <-chan T
	WriterCh chan<- T
}

Duplex represents a channel with multiple views, to be used by clients that need to hand out different ends of the same channel to different entities.

func NewDuplex added in v0.4.0

func NewDuplex[T any](channel chan T) *Duplex[T]

NewDuplex creates a new instance of a Duplex with all members populated

type DuplexJobOutput added in v0.4.0

type DuplexJobOutput[O any] Duplex[JobOutput[O]]

type ExecutiveFunc

type ExecutiveFunc[I, O any] func(j Job[I]) (JobOutput[O], error)

func (ExecutiveFunc[I, O]) Invoke

func (f ExecutiveFunc[I, O]) Invoke(j Job[I]) (JobOutput[O], error)

type GoRoutineID

type GoRoutineID string

type GoRoutineName

type GoRoutineName string

type Job

type Job[I any] struct {
	ID         string
	Input      I
	SequenceNo int
}

type JobOutput

type JobOutput[O any] struct {
	Payload O
}

type JobOutputStream added in v0.4.0

type JobOutputStream[O any] chan JobOutput[O]

type JobOutputStreamR added in v0.4.0

type JobOutputStreamR[O any] <-chan JobOutput[O]

type JobOutputStreamW added in v0.4.0

type JobOutputStreamW[O any] chan<- JobOutput[O]

type JobStream

type JobStream[I any] chan Job[I]

type JobStreamR

type JobStreamR[I any] <-chan Job[I]

type JobStreamW

type JobStreamW[I any] chan<- Job[I]

type NewWorkerPoolParams

type NewWorkerPoolParams[I, O any] struct {
	NoWorkers       int
	OutputChTimeout time.Duration
	Exec            ExecutiveFunc[I, O]
	JobsCh          JobStream[I]
	CancelCh        CancelStream
	WaitAQ          AnnotatedWgAQ
	Logger          *slog.Logger
}

type PoolResult added in v0.4.0

type PoolResult struct {
	Error error
}

type PoolResultStream added in v0.4.0

type PoolResultStream = chan *PoolResult

type PoolResultStreamR added in v0.4.0

type PoolResultStreamR = <-chan *PoolResult

type PoolResultStreamW added in v0.4.0

type PoolResultStreamW = chan<- *PoolResult

type WaitGroupAn

WaitGroupAn the extended WaitGroup

func NewAnnotatedWaitGroup

func NewAnnotatedWaitGroup(name string, log ...*slog.Logger) WaitGroupAn

NewAnnotatedWaitGroup creates a new AnnotatedWaitGroup instance containing the core WaitGroup instance.

type WaitGroupName

type WaitGroupName string

type WorkerPool

type WorkerPool[I, O any] struct {
	RoutineName GoRoutineName
	WaitAQ      AnnotatedWgAQ
	ResultInCh  PoolResultStreamR
	Logger      *slog.Logger
	// contains filtered or unexported fields
}

WorkerPool owns the resultOut channel, because it is the only entity that knows when all workers have completed their work due to the finished channel, which it also owns.

func NewWorkerPool

func NewWorkerPool[I, O any](params *NewWorkerPoolParams[I, O]) *WorkerPool[I, O]

func (*WorkerPool[I, O]) Start

func (p *WorkerPool[I, O]) Start(
	parentContext context.Context,
	parentCancel context.CancelFunc,
	outputsChOut chan<- JobOutput[O],
)

Jump to

Keyboard shortcuts

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