dqf2

package
v1.96.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Tag_Fresh   = 0   // the default for new messages, or must be reset by clients
	Tag_OK      = 1   // set by server only
	Tag_Dropped = 177 // set by chopper only
)

Variables

This section is empty.

Functions

func Chopper_Start

func Chopper_Start[T any](
	ctx context.Context,
	chUp chan *Message[T],
	of ...func(*Chopper_Options),
)

func SyncTransaction

func SyncTransaction[T any](chUp chan *Message[T], m *Message[T])

It's nice and simple, but you can't use it in select{}. See also ChDown.Transaction(). Note: please don't over-use this as a low-level primitive, it's best for high levels of abstraction code. For low-level, consider using the DQF pattern directly.

Types

type ChDown added in v1.89.0

type ChDown[T any] chan *Message[T]

func NewChDown added in v1.89.0

func NewChDown[T any]() (chDown ChDown[T])

func (ChDown[T]) Transaction added in v1.89.0

func (chDown ChDown[T]) Transaction(chUp chan *Message[T], m *Message[T])

This can be used in select{}. See also the SyncTransaction() function. Note: please don't over-use this as a low-level primitive, it's best for high levels of abstraction code. For low-level, consider using the DQF pattern directly.

type Chopper_Mode

type Chopper_Mode struct {
	Period              time.Duration
	ThresholdPerc       float32 // threshold perc of full capacity, action happens if above it
	ChopNPerc           float32 // how much to chop per one action, perc of full capacity
	NChopsToUpgrade     int     // e.g. after 5 successive chops, upgrade to faster mode
	NNoChopsToDowngrade int     // e.g. after 5 successive no-chops, downgrade to slower mode
}

type Chopper_Options

type Chopper_Options struct {
	Modes         []Chopper_Mode // 0 is slowest, -1 is fastest
	IfChoppedFunc func(n_chopped int)
	UpgradeFunc   func(from_mode, to_mode int)
	DowngradeFunc func(from_mode, to_mode int)
}

type Message

type Message[T any] struct {
	Tag int // this is used, among other things, by the chopper to mark failed deliveries

	Func func(m *Message[T], s T)
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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