outbox

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package outbox provides in-memory outbox pattern implementation for gorp framework. Implements transactional outbox pattern for reliable message delivery. Suitable for testing and single-instance deployments.

Outbox 包提供内存 Outbox 模式实现,用于 gorp 框架。 实现事务 Outbox 模式,确保可靠的消息投递。 适用于测试和单实例部署场景。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MemoryOutbox

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

MemoryOutbox is the in-memory outbox pattern implementation. Core logic: Store messages, process with retry, track status.

MemoryOutbox 是内存 Outbox 模式实现。 核心逻辑:存储消息、带重试处理、跟踪状态。

func NewMemoryOutbox

NewMemoryOutbox creates a new in-memory outbox. Core logic: Initialize message map and store sender/config.

NewMemoryOutbox 创建新的内存 Outbox。 核心逻辑:初始化消息 map 并存储 sender/config。

func (*MemoryOutbox) Emit

func (o *MemoryOutbox) Emit(ctx context.Context, topic string, payload interface{}) error

Emit emits a message asynchronously to the outbox. Core logic: Create message with UUID, store, spawn background processor.

Emit 异步将消息发送到 Outbox。 核心逻辑:创建带 UUID 的消息、存储、启动后台处理器。

func (*MemoryOutbox) EmitSync

func (o *MemoryOutbox) EmitSync(ctx context.Context, topic string, payload interface{}) error

EmitSync emits a message synchronously and processes immediately. Core logic: Create message, store, call Process synchronously.

EmitSync 同步发送消息并立即处理。 核心逻辑:创建消息、存储、同步调用 Process。

func (*MemoryOutbox) Process

func (o *MemoryOutbox) Process(ctx context.Context) error

Process processes pending messages with retry logic. Core logic: Find pending/retrying messages, send with retry limit, update status.

Process 处理待处理消息,带重试逻辑。 核心逻辑:找到待处理/重试中的消息、带重试限制发送、更新状态。

type MemoryOutboxStore

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

MemoryOutboxStore is the in-memory outbox storage implementation. Core logic: Store messages, provide pending query, mark status.

MemoryOutboxStore 是内存 Outbox 存储实现。 核心逻辑:存储消息、提供待处理查询、标记状态。

func NewMemoryOutboxStore

func NewMemoryOutboxStore() *MemoryOutboxStore

func (*MemoryOutboxStore) GetPending

func (*MemoryOutboxStore) MarkFailed

func (s *MemoryOutboxStore) MarkFailed(ctx context.Context, id string, err error) error

func (*MemoryOutboxStore) MarkSent

func (s *MemoryOutboxStore) MarkSent(ctx context.Context, id string) error

func (*MemoryOutboxStore) Save

Jump to

Keyboard shortcuts

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