pool

package
v1.20.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2024 License: Apache-2.0 Imports: 6 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DoFn added in v0.7.0

type DoFn[T, R any] func(req T) (R, error)

DoFn[T, R] request handle function

type ExecFn added in v0.18.0

type ExecFn[T any] func(req T)

ExecFn[T] request handle function

type GoroutinePool

type GoroutinePool[T, R any] interface {
	Start()
	Stop()
	Do(T, ResponseFn[T, R])
}

GoroutinePool[T, R] goroutine pool interface

func NewGoroutinePool

func NewGoroutinePool[T, R any](fn DoFn[T, R], opts ...Option) GoroutinePool[T, R]

NewGoroutinePool[T, R] create a new GoroutinePool[T, R] instance

type GoroutinePool2 added in v0.5.0

type GoroutinePool2[T any] interface {
	Start()
	Stop()
	Run(T, RespFn[T])
}

GoroutinePool2[T] goroutine pool interface

func NewGoroutinePool2 added in v0.5.0

func NewGoroutinePool2[T any](fn RunFn[T], opts ...Option) GoroutinePool2[T]

NewGoroutinePool2[T] create a new GoroutinePool2[T] instance

type GoroutinePool3 added in v0.18.0

type GoroutinePool3[T any] interface {
	Start()
	Stop()
	Exec(T)
}

GoroutinePool3[T] goroutine pool interface

func NewGoroutinePool3 added in v0.18.0

func NewGoroutinePool3[T any](fn ExecFn[T], opts ...Option) GoroutinePool3[T]

NewGoroutinePool3[T] create a new GoroutinePool3[T] instance

type Option added in v0.6.0

type Option = func(opt *gorotinePoolOpt)

Option groutine pool option help function used to create groutine pool instance

func WithMaxIdelTime added in v0.10.0

func WithMaxIdelTime(d time.Duration) Option

WithMaxIdelTime set max idle time to custom a worker max wait tile to worker

func WithMaxRequestBuf added in v0.10.0

func WithMaxRequestBuf(num int) Option

WithMaxRequestBuf set max request buffer size

func WithMaxRequestTempBuf added in v0.10.0

func WithMaxRequestTempBuf(num int) Option

WithMaxRequestTempBuf set max request temp buffer size

func WithMaxTempWorker added in v0.10.0

func WithMaxTempWorker(num int) Option

WithMaxRequestBuf set max temp worker count

func WithMinWorker added in v0.10.0

func WithMinWorker(num int) Option

WithMinWorker set min worker count

func WithWorkerHook added in v0.10.0

func WithWorkerHook(h WorkerHook) Option

WithWorkerHookOpt set wroker hook

type RespFn added in v0.5.0

type RespFn[T any] func(req T, err error)

RespFn[T] response handle function

type ResponseFn

type ResponseFn[T, R any] func(req T, resp R, err error)

ResponseFn[T, R] response handle function

type RunFn added in v0.5.0

type RunFn[T any] func(req T) error

RunFn[T] request handle function

type WorkPool added in v0.10.1

type WorkPool interface {
	Go(fn types.Fn)
}

WorkPool work pool interface

func NewBufferWorkPool added in v0.10.1

func NewBufferWorkPool(maxIdle int, maxIdleTime time.Duration) WorkPool

NewBufferWorkPool create a work pool instance use buffer style

func NewSimpleWorkPool added in v0.10.1

func NewSimpleWorkPool(maxIdle int, maxIdleTime time.Duration) WorkPool

NewSimpleWorkPool create a work pool instance use simple style

func NewWorkPool added in v0.10.1

func NewWorkPool(maxIdle int, maxIdleTime time.Duration) WorkPool

NewWorkPool create a work pool instance

type WorkerHook added in v0.9.1

type WorkerHook interface {
	OnJoin(count int32)
	OnLeave(count int32)
}

WorkerHook hook worker status

Jump to

Keyboard shortcuts

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