qos

package
v0.2.9 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxQueueBytes   = 1 * 1024 * 1024 // 1MB max/queue
	DefaultMaxMessageBytes = 256 * 1024      // 256 KB
)

Variables

View Source
var (
	PriorityTypeUnmarshal = map[string]PriorityType{
		"unknown": UnknownType,
		"oldest":  OldestType,
		"newest":  NewestType,
	}
	PriorityTypeMarshal = map[PriorityType]string{
		UnknownType: "unknown",
		OldestType:  "oldest",
		NewestType:  "newest",
	}
)
View Source
var (
	ErrInvalidInput     = errors.New("invalid input")
	ErrMisconfiguredQOS = errors.New("misconfigured QOS")
	ErrQOSHasShutdown   = errors.New("QOS has been shutdown")
)
View Source
var ErrMaxMessageBytes = errors.New("wrp message payload exceeds maxMessageBytes")
View Source
var ErrPriorityTypeInvalid = errors.New("Priority type is invalid")

Functions

func PriorityNewestMsg added in v0.1.4

func PriorityNewestMsg(i, j item) bool

func PriorityOldestMsg added in v0.1.4

func PriorityOldestMsg(i, j item) bool

Types

type Handler

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

Handler queues incoming messages and sends them to the next wrpkit.Handler

func New

func New(next wrpkit.Handler, opts ...Option) (*Handler, error)

New creates a new instance of the Handler struct. The parameter next is the handler that will be called and monitored for errors. Note, once Handler.Stop is called, any calls to Handler.HandleWrp will result in an ErrQOSHasShutdown error

func (*Handler) HandleWrp

func (h *Handler) HandleWrp(msg wrp.Message) error

HandleWRP queues incoming messages while the background serviceQOS goroutine attempts to send as many queued messages as possible, where the highest QOS messages are prioritized

func (*Handler) Start

func (h *Handler) Start()

func (*Handler) Stop

func (h *Handler) Stop()

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option is a functional option type for QOS.

func MaxMessageBytes

func MaxMessageBytes(s int) Option

MaxMessageBytes is the largest allowable wrp message payload. Note, the default zero behavior is a 256KB payload size constraint.

func MaxQueueBytes

func MaxQueueBytes(s int64) Option

MaxQueueBytes is the allowable max size of the qos' priority queue, based on the sum of all queued wrp message's payload. Note, the default zero behavior is a queue with a 1MB size constraint.

func Priority added in v0.1.4

func Priority(p PriorityType) Option

Priority determines what is used [newest, oldest message] for QualityOfService tie breakers, with the default being to prioritize the newest messages.

type PriorityType added in v0.1.4

type PriorityType int
const (
	UnknownType PriorityType = iota
	OldestType
	NewestType
)

func (PriorityType) String added in v0.1.4

func (pt PriorityType) String() string

String returns a human-readable string representation for an existing PriorityType, otherwise String returns the `unknown` string value.

func (*PriorityType) UnmarshalText added in v0.1.4

func (pt *PriorityType) UnmarshalText(b []byte) error

UnmarshalText unmarshals a PriorityType's enum value.

Jump to

Keyboard shortcuts

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