fsq

package
v0.41.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DLQSchemaVersion = "amq/dlq/v1"
	MaxRetries       = 3
)
View Source
const (
	BoxNew = "new"
	BoxCur = "cur"
)

Variables

This section is empty.

Functions

func AgentBase

func AgentBase(root, agent string) string

func AgentDLQCur added in v0.9.0

func AgentDLQCur(root, agent string) string

func AgentDLQNew added in v0.9.0

func AgentDLQNew(root, agent string) string

func AgentDLQTmp added in v0.9.0

func AgentDLQTmp(root, agent string) string

func AgentInboxCur

func AgentInboxCur(root, agent string) string

func AgentInboxNew

func AgentInboxNew(root, agent string) string

func AgentInboxTmp

func AgentInboxTmp(root, agent string) string

func AgentOutboxSent

func AgentOutboxSent(root, agent string) string

func AgentReceipts added in v0.31.0

func AgentReceipts(root, agent string) string

func DeliverToExistingInbox added in v0.24.0

func DeliverToExistingInbox(root, agent, filename string, data []byte) (string, error)

DeliverToExistingInbox delivers a message to a foreign root's inbox using Maildir semantics (tmp -> new). Unlike DeliverToInboxes, it never creates directories — the target inbox must already exist. This prevents a sender from accidentally scaffolding structure in a peer project.

func DeliverToInbox

func DeliverToInbox(root, agent, filename string, data []byte) (string, error)

DeliverToInbox writes a message using Maildir semantics (tmp -> new). It returns the final path in inbox/new.

func DeliverToInboxes added in v0.2.0

func DeliverToInboxes(root string, recipients []string, filename string, data []byte) (map[string]string, error)

DeliverToInboxes writes a message to multiple inboxes. On partial failure, committed deliveries remain in new/ and undelivered tmp files are removed.

func EnsureAgentDirs

func EnsureAgentDirs(root, agent string) error

func EnsureRootDirs

func EnsureRootDirs(root string) error

func FindDLQMessage added in v0.9.0

func FindDLQMessage(root, agent, filename string) (string, string, error)

FindDLQMessage locates a DLQ message in dlq/new or dlq/cur.

func FindMessage

func FindMessage(root, agent, filename string) (string, string, error)

func FindTmpFilesOlderThan

func FindTmpFilesOlderThan(root string, cutoff time.Time) ([]string, error)

func GenerateDLQID added in v0.9.0

func GenerateDLQID() string

GenerateDLQID creates a unique ID for a DLQ envelope.

func ListAgents

func ListAgents(root string) ([]string, error)

func MoveCurToDLQ added in v0.39.0

func MoveCurToDLQ(root, agent, filename, originalID, failureReason, failureDetail string) (string, error)

MoveCurToDLQ moves an already-claimed inbox/cur message to dlq/new.

func MoveDLQNewToCur added in v0.9.0

func MoveDLQNewToCur(root, agent, filename string) error

MoveDLQNewToCur moves a DLQ message from new to cur (marks as inspected).

func MoveNewToCur

func MoveNewToCur(root, agent, filename string) error

func MoveToDLQ added in v0.9.0

func MoveToDLQ(root, agent, filename, originalID, failureReason, failureDetail string) (string, error)

MoveToDLQ moves a failed message from inbox/new to dlq/new with envelope.

func OpenRegularNoFollow added in v0.40.0

func OpenRegularNoFollow(path string) (*os.File, os.FileInfo, error)

OpenRegularNoFollow opens path only if it is a regular file and not a symlink.

func ReadRegularNoFollow added in v0.40.0

func ReadRegularNoFollow(path string) ([]byte, error)

func RetryFromDLQ added in v0.9.0

func RetryFromDLQ(root, agent, dlqFilename string, force bool) error

RetryFromDLQ moves a message from DLQ back to inbox/new for reprocessing. Returns error if retry_count >= MaxRetries and force is false.

func SyncDir

func SyncDir(dir string) error

SyncDir fsyncs a directory to ensure directory entries are durable.

func ValidateHandle added in v0.16.0

func ValidateHandle(agent string) error

ValidateHandle returns an error if the agent handle contains path traversal characters or does not match the allowed pattern.

func ValidateMessageFilename added in v0.40.0

func ValidateMessageFilename(filename string) error

ValidateMessageFilename validates an inbox or DLQ message filename.

func WriteFileAtomic

func WriteFileAtomic(dir, filename string, data []byte, perm os.FileMode) (string, error)

WriteFileAtomic writes data to a temporary file in dir and renames it into place.

Types

type DLQEnvelope added in v0.9.0

type DLQEnvelope struct {
	Schema        string `json:"schema"`
	ID            string `json:"id"`
	OriginalID    string `json:"original_id"`
	OriginalFile  string `json:"original_file"`
	FailureReason string `json:"failure_reason"`
	FailureDetail string `json:"failure_detail"`
	FailureTime   string `json:"failure_time"`
	RetryCount    int    `json:"retry_count"`
	SourceDir     string `json:"source_dir"`
}

DLQEnvelope wraps a failed message with failure metadata.

func ReadDLQEnvelope added in v0.9.0

func ReadDLQEnvelope(path string) (*DLQEnvelope, []byte, error)

ReadDLQEnvelope reads and parses a DLQ message.

type PartialDeliveryError added in v0.39.0

type PartialDeliveryError struct {
	Delivered map[string]string
	Failed    string
	Pending   []string
	Err       error
}

PartialDeliveryError reports the delivery state after a multi-recipient delivery fails during the tmp -> new commit phase.

func (*PartialDeliveryError) Error added in v0.39.0

func (e *PartialDeliveryError) Error() string

func (*PartialDeliveryError) Unwrap added in v0.39.0

func (e *PartialDeliveryError) Unwrap() error

Jump to

Keyboard shortcuts

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