Documentation
¶
Overview ¶
Package journal defines the append-only fact log that records everything that ever happened to tasks. All derived views (queue, DLQ, stats) are projections over these facts.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Fact ¶
type Fact struct {
Seq int64 `json:"seq"`
Time time.Time `json:"time"`
TaskID string `json:"taskId"`
Type FactType `json:"type"`
Owner string `json:"owner,omitempty"`
Attempt int `json:"attempt,omitempty"`
Error string `json:"error,omitempty"`
Detail json.RawMessage `json:"detail,omitempty"`
}
Fact is one immutable observation about one task.
type FactType ¶
type FactType string
FactType enumerates the kinds of facts that can be recorded.
const ( Enqueued FactType = "task.enqueued" Claimed FactType = "task.claimed" Heartbeat FactType = "task.heartbeat" Completed FactType = "task.completed" Failed FactType = "task.failed" // attempt failed, will retry DeadLettered FactType = "task.dead-lettered" // attempts exhausted Cancelled FactType = "task.cancelled" Released FactType = "task.released" // lease expired, back to pending )
type Journal ¶
type Journal interface {
// Append records a fact. Implementations must assign Seq and Time when zero.
Append(ctx context.Context, f Fact) (Fact, error)
// All returns every fact in Seq order.
All(ctx context.Context) ([]Fact, error)
// Since returns facts with Seq strictly greater than after, in Seq order.
Since(ctx context.Context, after int64) ([]Fact, error)
}
Journal is the persistence boundary for facts.
type MemoryJournal ¶
type MemoryJournal struct {
// contains filtered or unexported fields
}
MemoryJournal is an in-memory Journal for tests and ephemeral queues.
func NewMemoryJournal ¶
func NewMemoryJournal() *MemoryJournal
NewMemoryJournal returns an empty in-memory journal.
func (*MemoryJournal) All ¶
func (m *MemoryJournal) All(_ context.Context) ([]Fact, error)
All returns every fact in Seq order.
Click to show internal directories.
Click to hide internal directories.