priority

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PriorityIntToLevel

func PriorityIntToLevel(priority int32) string

PriorityIntToLevel converts a numeric priority into a logical level.

func PriorityLevelToRange

func PriorityLevelToRange(level string) (int32, int32)

PriorityLevelToRange returns the inclusive min/max priority values for a level.

Types

type PriorityWeightCalculator

type PriorityWeightCalculator struct {
	AgeFetcher func(ctx context.Context, queueName string, level string, nowMs int64) (int64, bool, error)
	// contains filtered or unexported fields
}

PriorityWeightCalculator computes priority weights with age-based boosting. It can fetch age information from the database or an injected AgeFetcher (for tests).

func NewPriorityWeightCalculator

func NewPriorityWeightCalculator(base *repositorysql.BaseSQL) *PriorityWeightCalculator

NewPriorityWeightCalculator builds a calculator using the provided BaseSQL.

func (*PriorityWeightCalculator) CalculateWeights

func (p *PriorityWeightCalculator) CalculateWeights(ctx context.Context, queueName string, queueMeta *queuepb.QueueMetadata) (map[string]int32, error)

CalculateWeights returns effective weights for each priority level with age boosting applied. If no messages exist in any level, an empty map is returned and no error is raised.

func (*PriorityWeightCalculator) SelectPriorityLevel

func (p *PriorityWeightCalculator) SelectPriorityLevel(weights map[string]int32) string

SelectPriorityLevel picks a priority level using weighted random selection. Returns empty string if weights are empty or total weight <= 0.

Jump to

Keyboard shortcuts

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