Documentation
¶
Overview ¶
Package fileoutbox provides a dependency-free JSON Lines outbox adapter for runtime/contracts.
Index ¶
- type Decoder
- type Option
- type Record
- type Store
- func (store *Store) DeadLetterRecords(ctx context.Context) ([]Record, error)
- func (store *Store) ReceiveEventBatch(ctx context.Context) (contracts.EventBatch, error)
- func (store *Store) Records(ctx context.Context) ([]Record, error)
- func (store *Store) StoreEvents(ctx context.Context, events []contracts.EventEnvelope) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Decoder ¶
type Decoder func(json.RawMessage) (any, error)
Decoder converts one persisted JSON payload back into the typed Go event value expected by runtime/contracts subscribers.
type Option ¶
type Option func(*Store)
Option configures a Store.
func WithBatchSize ¶
WithBatchSize sets the maximum number of records returned by one worker batch. Non-positive values keep the default.
func WithDeadLetter ¶
WithDeadLetter moves records to deadLetterPath after maxAttempts failed deliveries. Non-positive maxAttempts or an empty path disables dead-lettering.
func WithDecoder ¶
WithDecoder registers a decoder for one stored event type.
func WithJSONDecoder ¶
WithJSONDecoder registers a JSON decoder for one stored event type.
func WithJSONTypeDecoder ¶
WithJSONTypeDecoder registers a JSON decoder using the same Go type name stored by runtime/contracts when T is emitted.
type Record ¶
type Record struct {
ID string `json:"id"`
StoredAt time.Time `json:"storedAt"`
Category contracts.EventCategory `json:"category"`
Type string `json:"type"`
Value json.RawMessage `json:"value"`
Attempts int `json:"attempts,omitempty"`
LastAttemptAt *time.Time `json:"lastAttemptAt,omitempty"`
LastError string `json:"lastError,omitempty"`
}
Record is one durable outbox row stored as a JSON Lines object.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store appends event envelopes to a JSON Lines file and can replay them as an EventSource. Ack removes delivered records; Nack records retry metadata and leaves records for later delivery.
func (*Store) DeadLetterRecords ¶
DeadLetterRecords returns records moved out of the pending outbox by the configured dead-letter policy.
func (*Store) ReceiveEventBatch ¶
ReceiveEventBatch returns the next pending records as typed event envelopes. It returns contracts.ErrEventSourceClosed when the outbox is empty.
func (*Store) StoreEvents ¶
StoreEvents appends events to the outbox file.