outbox

package
v0.7.522 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: AGPL-3.0, AGPL-3.0-or-later Imports: 8 Imported by: 0

Documentation

Overview

Package outbox persists outgoing stream requests that failed because the destination node was offline and replays them, oldest-first, once that node is seen online again (via the pubsub discovery signal) or on startup.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Repo

type Repo interface {
	Enqueue(destNodeId, route string, payload []byte) (database.OutboxEntry, error)
	ListByNode(destNodeId string) ([]database.OutboxEntry, error)
	Save(entry database.OutboxEntry) error
	Delete(destNodeId, id string) error
	ListNodes() ([]string, error)
}

type RetryService

type RetryService struct {
	// contains filtered or unexported fields
}

func NewRetryService

func NewRetryService(ctx context.Context, repo Repo) *RetryService

func (*RetryService) Close

func (s *RetryService) Close()

func (*RetryService) Enqueue

func (s *RetryService) Enqueue(destNodeId, route string, payload []byte) error

Enqueue stores an undelivered request and marks its destination pending so a later NotifyOnline flushes it.

func (*RetryService) FlushAllOnStart

func (s *RetryService) FlushAllOnStart()

FlushAllOnStart schedules a one-shot replay of every node that still has queued entries, covering the case where a peer is already online at startup and won't re-announce for a while.

func (*RetryService) NotifyOnline

func (s *RetryService) NotifyOnline(nodeId string)

NotifyOnline is the pubsub-discovery hook: it is called for every peer seen on the discovery topic. It is O(1) and does no I/O when the node has nothing queued, so it is cheap to call on every gossip announcement.

func (*RetryService) SetSender

func (s *RetryService) SetSender(sender Sender)

SetSender wires the redelivery transport. Until it is set, flushes are no-ops, so it is safe to construct the service before the node is up.

type Sender

type Sender interface {
	RedeliverStream(nodeId string, path stream.WarpRoute, payload []byte, msgID string) ([]byte, error)
}

Sender redelivers a queued request. Implementations must NOT re-enqueue on failure (that would loop); the retry service owns the queue lifecycle.

Jump to

Keyboard shortcuts

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