queue

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package queue parses `postqueue -j` output and summarises the Postfix queue, including a qshape-style age-by-domain matrix.

Index

Constants

This section is empty.

Variables

View Source
var BucketEdges = []int{5, 10, 20, 40, 80, 160, 320, 640, 1280}

BucketEdges are the upper edges in minutes, like qshape's default (-t 5 -b 10).

Functions

func Domain

func Domain(addr string) string

Domain returns the lower-cased domain part of an address ("" -> "<>", no @ -> "localhost").

func HumanAge

func HumanAge(d time.Duration) string

HumanAge formats a duration as 3d4h, 5h12m, 7m.

Types

type Count

type Count struct {
	Key   string `json:"key"`
	Count int    `json:"count"`
}

Count is a labelled counter.

type Filter

type Filter struct {
	Queue          string // active, deferred, hold, incoming, maildrop, corrupt; "" = all
	Domain         string // recipient domain (exact, or suffix with leading ".")
	Sender         string // substring of sender
	ReasonContains string // case-insensitive substring of any delay_reason
	Category       string // reason category id
	MinAge         time.Duration
}

Filter selects messages.

func (Filter) Apply

func (f Filter) Apply(msgs []Message, now time.Time) []Message

Apply returns the messages matching f.

type Message

type Message struct {
	QueueName    string      `json:"queue_name"`
	QueueID      string      `json:"queue_id"`
	ArrivalTime  int64       `json:"arrival_time"`
	MessageSize  int64       `json:"message_size"`
	ForcedExpire bool        `json:"forced_expire"`
	Sender       string      `json:"sender"`
	Recipients   []Recipient `json:"recipients"`
}

Message is one line of `postqueue -j` output.

func Parse

func Parse(r io.Reader) ([]Message, error)

Parse reads newline-delimited JSON objects as written by `postqueue -j`.

func (Message) Arrival

func (m Message) Arrival() time.Time

Arrival returns the arrival time.

type ReasonCount

type ReasonCount struct {
	Reason   string   `json:"reason"`
	Category string   `json:"category"`
	Hint     string   `json:"hint"`
	Count    int      `json:"recipients"`
	Domains  []string `json:"domains"`
	Example  string   `json:"example"`
}

ReasonCount groups recipients by normalised delay reason.

type Recipient

type Recipient struct {
	Address     string `json:"address"`
	DelayReason string `json:"delay_reason,omitempty"`
}

Recipient is one undelivered recipient of a queued message.

type Shape

type Shape struct {
	Queue   string     `json:"queue"`
	By      string     `json:"by"`
	Buckets []string   `json:"buckets"`
	Total   ShapeRow   `json:"total"`
	Rows    []ShapeRow `json:"rows"`
}

Shape is a qshape-style matrix: rows are domains, columns are age buckets in minutes (0-5, 5-10, 10-20 ... 1280+), cells count messages.

func BuildShape

func BuildShape(msgs []Message, now time.Time, queueName, by string, top int) Shape

BuildShape computes the matrix. by is "recipient" (default) or "sender". A message counts once per distinct domain. top limits rows (0 = all).

func (Shape) Text

func (s Shape) Text() string

Text renders the matrix like qshape does.

type ShapeRow

type ShapeRow struct {
	Domain string `json:"domain"`
	Total  int    `json:"total"`
	Cells  []int  `json:"cells"`
}

ShapeRow is one domain.

type Summary

type Summary struct {
	Total         int           `json:"messages"`
	Recipients    int           `json:"recipients"`
	Bytes         int64         `json:"bytes"`
	ByQueue       []Count       `json:"by_queue"`
	TopDomains    []Count       `json:"top_recipient_domains"`
	TopSenders    []Count       `json:"top_sender_domains"`
	Reasons       []ReasonCount `json:"reasons"`
	OldestID      string        `json:"oldest_queue_id,omitempty"`
	OldestAge     string        `json:"oldest_age,omitempty"`
	OldestAgeSecs int64         `json:"oldest_age_seconds,omitempty"`
	ForcedExpire  int           `json:"forced_expire"`
}

Summary is an overview of the queue.

func Summarize

func Summarize(msgs []Message, now time.Time, top int) Summary

Summarize builds a Summary; top limits the per-list length (0 = no limit).

Jump to

Keyboard shortcuts

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