Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PriorityIntToLevel ¶
PriorityIntToLevel converts a numeric priority into a logical level.
func PriorityLevelToRange ¶
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.