Documentation
¶
Index ¶
- Constants
- func AgentBase(root, agent string) string
- func AgentDLQCur(root, agent string) string
- func AgentDLQNew(root, agent string) string
- func AgentDLQTmp(root, agent string) string
- func AgentInboxCur(root, agent string) string
- func AgentInboxNew(root, agent string) string
- func AgentInboxTmp(root, agent string) string
- func AgentOutboxSent(root, agent string) string
- func AgentReceipts(root, agent string) string
- func DeliverToExistingInbox(root *DeliveryRoot, agent, filename string, data []byte) (string, error)
- func DeliverToInbox(root *DeliveryRoot, agent, filename string, data []byte) (string, error)
- func DeliverToInboxes(root *DeliveryRoot, recipients []string, filename string, data []byte) (map[string]string, error)
- func EnsureAgentDirs(root, agent string) error
- func EnsureRootDirs(root string) error
- func FindDLQMessage(root *DeliveryRoot, agent, filename string) (string, string, error)
- func FindMessage(root, agent, filename string) (string, string, error)
- func FindTmpFilesOlderThan(root string, cutoff time.Time) ([]string, error)
- func GenerateDLQID() string
- func ListAgents(root string) ([]string, error)
- func MoveCurToDLQ(root *DeliveryRoot, ...) (string, error)
- func MoveDLQNewToCur(root *DeliveryRoot, agent, filename string) error
- func MoveNewToCur(root *DeliveryRoot, agent, filename string) error
- func MoveToDLQ(root *DeliveryRoot, ...) (string, error)
- func OpenRegularNoFollow(path string) (*os.File, os.FileInfo, error)
- func ReadRegularNoFollow(path string) ([]byte, error)
- func RetryFromDLQ(root *DeliveryRoot, agent, dlqFilename string, force bool) error
- func SyncDir(dir string) error
- func ValidateHandle(agent string) error
- func ValidateMessageFilename(filename string) error
- func WriteFileAtomic(dir, filename string, data []byte, perm os.FileMode) (string, error)
- type CommittedDurabilityError
- type DLQEnvelope
- type DLQTransitionError
- type DeliveryRoot
- func (r *DeliveryRoot) Base() string
- func (r *DeliveryRoot) Close() error
- func (r *DeliveryRoot) DisplayPath(name string) string
- func (r *DeliveryRoot) ReadDir(name string) ([]os.DirEntry, error)
- func (r *DeliveryRoot) ReadFile(name string) ([]byte, error)
- func (r *DeliveryRoot) ReadRegularNoFollow(name string) ([]byte, error)
- func (r *DeliveryRoot) Remove(name string) error
- func (r *DeliveryRoot) Stat(name string) (os.FileInfo, error)
- func (r *DeliveryRoot) SyncDir(name string) error
- func (r *DeliveryRoot) VerifyBase() error
- func (r *DeliveryRoot) WriteFileAtomic(dir, filename string, data []byte, perm os.FileMode) (string, error)
- type DeliveryRootIdentity
- type PartialDeliveryError
Constants ¶
const ( DLQSchemaVersion = "amq/dlq/v1" MaxRetries = 3 )
const ( BoxNew = "new" BoxCur = "cur" )
Variables ¶
This section is empty.
Functions ¶
func AgentDLQCur ¶ added in v0.9.0
func AgentDLQNew ¶ added in v0.9.0
func AgentDLQTmp ¶ added in v0.9.0
func AgentInboxCur ¶
func AgentInboxNew ¶
func AgentInboxTmp ¶
func AgentOutboxSent ¶
func AgentReceipts ¶ added in v0.31.0
func DeliverToExistingInbox ¶ added in v0.24.0
func DeliverToExistingInbox(root *DeliveryRoot, 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 *DeliveryRoot, 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 *DeliveryRoot, 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 EnsureRootDirs ¶
func FindDLQMessage ¶ added in v0.9.0
func FindDLQMessage(root *DeliveryRoot, agent, filename string) (string, string, error)
FindDLQMessage locates a DLQ message in dlq/new or dlq/cur.
func FindTmpFilesOlderThan ¶
func GenerateDLQID ¶ added in v0.9.0
func GenerateDLQID() string
GenerateDLQID creates a unique ID for a DLQ envelope.
func ListAgents ¶
func MoveCurToDLQ ¶ added in v0.39.0
func MoveCurToDLQ(root *DeliveryRoot, 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 *DeliveryRoot, agent, filename string) error
MoveDLQNewToCur moves a DLQ message from new to cur (marks as inspected).
func MoveNewToCur ¶
func MoveNewToCur(root *DeliveryRoot, agent, filename string) error
func MoveToDLQ ¶ added in v0.9.0
func MoveToDLQ(root *DeliveryRoot, 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
OpenRegularNoFollow opens path only if it is a regular file and not a symlink.
func ReadRegularNoFollow ¶ added in v0.40.0
func RetryFromDLQ ¶ added in v0.9.0
func RetryFromDLQ(root *DeliveryRoot, 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 ValidateHandle ¶ added in v0.16.0
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
ValidateMessageFilename validates an inbox or DLQ message filename.
Types ¶
type CommittedDurabilityError ¶ added in v0.45.0
CommittedDurabilityError means the visible rename succeeded, but the destination directory could not be synced. Retrying with a new identifier may duplicate an artifact that is already present at FinalPath.
func (*CommittedDurabilityError) Error ¶ added in v0.45.0
func (e *CommittedDurabilityError) Error() string
func (*CommittedDurabilityError) Unwrap ¶ added in v0.45.0
func (e *CommittedDurabilityError) Unwrap() error
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(root *DeliveryRoot, path string) (*DLQEnvelope, []byte, error)
ReadDLQEnvelope reads and parses a DLQ message.
func ReadDLQEnvelopePath ¶ added in v0.45.0
func ReadDLQEnvelopePath(path string) (*DLQEnvelope, []byte, error)
ReadDLQEnvelopePath is the legacy pathname reader used only by non-mutating listing code. Mutating DLQ flows must use ReadDLQEnvelope with a capability.
type DLQTransitionError ¶ added in v0.45.0
type DLQTransitionError struct {
EnvelopePath string
SourcePath string
SourceRetained bool
Err error
}
DLQTransitionError reports that a DLQ envelope is visible but its directory sync failed, so the claimed source was deliberately retained for recovery.
func (*DLQTransitionError) Error ¶ added in v0.45.0
func (e *DLQTransitionError) Error() string
func (*DLQTransitionError) Unwrap ¶ added in v0.45.0
func (e *DLQTransitionError) Unwrap() error
type DeliveryRoot ¶ added in v0.45.0
type DeliveryRoot struct {
// contains filtered or unexported fields
}
DeliveryRoot is an authorized, pinned filesystem capability for one AMQ tree. All delivery paths are resolved relative to the open directory rather than by reopening Base through the ambient filesystem namespace.
func OpenDeliveryRoot ¶ added in v0.45.0
func OpenDeliveryRoot(base string, expected DeliveryRootIdentity) (*DeliveryRoot, error)
OpenDeliveryRoot opens base once and proves the opened directory is the same physical object authorized by expected. Subsequent operations are pinned to that handle and never reopen base through the ambient namespace.
func (*DeliveryRoot) Base ¶ added in v0.45.0
func (r *DeliveryRoot) Base() string
Base returns the authorized path for diagnostics only. Filesystem operations must stay relative to the pinned root.
func (*DeliveryRoot) Close ¶ added in v0.45.0
func (r *DeliveryRoot) Close() error
func (*DeliveryRoot) DisplayPath ¶ added in v0.45.0
func (r *DeliveryRoot) DisplayPath(name string) string
DisplayPath returns the diagnostic path for a root-relative name. The result must not be used for filesystem I/O.
func (*DeliveryRoot) ReadDir ¶ added in v0.45.0
func (r *DeliveryRoot) ReadDir(name string) ([]os.DirEntry, error)
ReadDir reads a root-relative directory through the pinned capability.
func (*DeliveryRoot) ReadFile ¶ added in v0.45.0
func (r *DeliveryRoot) ReadFile(name string) ([]byte, error)
ReadFile reads a root-relative file through the pinned capability.
func (*DeliveryRoot) ReadRegularNoFollow ¶ added in v0.45.0
func (r *DeliveryRoot) ReadRegularNoFollow(name string) ([]byte, error)
ReadRegularNoFollow reads a root-relative regular file while refusing an initially symlinked artifact and detecting replacement between lstat/open.
func (*DeliveryRoot) Remove ¶ added in v0.45.0
func (r *DeliveryRoot) Remove(name string) error
Remove removes a root-relative path through the pinned capability.
func (*DeliveryRoot) Stat ¶ added in v0.45.0
func (r *DeliveryRoot) Stat(name string) (os.FileInfo, error)
Stat stats a root-relative path through the pinned capability.
func (*DeliveryRoot) SyncDir ¶ added in v0.45.0
func (r *DeliveryRoot) SyncDir(name string) error
SyncDir syncs a root-relative directory through the pinned capability.
func (*DeliveryRoot) VerifyBase ¶ added in v0.45.0
func (r *DeliveryRoot) VerifyBase() error
VerifyBase reports a lexical alias change after authorization. The open root remains the security boundary even if an alias changes immediately after this check; this verification makes a detected swap fail closed instead of silently delivering into the formerly named tree.
func (*DeliveryRoot) WriteFileAtomic ¶ added in v0.45.0
func (r *DeliveryRoot) WriteFileAtomic(dir, filename string, data []byte, perm os.FileMode) (string, error)
WriteFileAtomic writes a root-relative file through the pinned capability.
type DeliveryRootIdentity ¶ added in v0.45.0
type DeliveryRootIdentity struct {
// contains filtered or unexported fields
}
DeliveryRootIdentity is an opaque physical-identity snapshot taken at the authorization boundary and consumed when the directory capability is opened.
func SnapshotDeliveryRoot ¶ added in v0.45.0
func SnapshotDeliveryRoot(base string) (DeliveryRootIdentity, error)
SnapshotDeliveryRoot captures the physical directory identity at the authorization boundary. The snapshot is intentionally opaque so callers cannot forge or reinterpret it.
func (DeliveryRootIdentity) FileInfo ¶ added in v0.45.0
func (i DeliveryRootIdentity) FileInfo() os.FileInfo
FileInfo returns the captured identity for comparison with an existing platform identity token. Filesystem operations cannot be performed through this value.
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