Documentation
¶
Overview ¶
Package fileoutbox provides a dependency-free JSON Lines outbox adapter for runtime/contracts.
Index ¶
- type Decoder
- type Option
- type Record
- type SeenOption
- type SeenRecord
- type SeenStore
- 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 = contracts.EventDecoder
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"`
EventID string `json:"eventId,omitempty"`
TraceParent string `json:"traceparent,omitempty"`
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 SeenOption ¶ added in v0.5.0
type SeenOption func(*SeenStore)
SeenOption configures a SeenStore.
func WithSeenLimit ¶ added in v0.5.0
func WithSeenLimit(limit int) SeenOption
WithSeenLimit sets the maximum retained IDs. Non-positive values keep the default window.
type SeenRecord ¶ added in v0.5.0
SeenRecord is one file-backed deduplication entry.
type SeenStore ¶ added in v0.5.0
type SeenStore struct {
// contains filtered or unexported fields
}
SeenStore records delivered event IDs in a JSON Lines file. It is intended for local single-binary apps that also use fileoutbox.
func NewSeenStore ¶ added in v0.5.0
func NewSeenStore(path string, options ...SeenOption) *SeenStore
NewSeenStore creates a file-backed seen store at path.
func (*SeenStore) MarkIfNew ¶ added in v0.5.0
MarkIfNew records id and reports whether it was not already present in the retained file window.
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.
Store synchronizes access within a single process only. Pointing multiple processes at the same outbox file is not supported and can lose or double-deliver records.
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.