Documentation
¶
Index ¶
- Constants
- type OffsetInfo
- type Tracker
- func (t *Tracker) GetInfo() OffsetInfo
- func (t *Tracker) GetJobID() string
- func (t *Tracker) GetOffset() int
- func (t *Tracker) Load() error
- func (t *Tracker) MarkComplete(idx int)
- func (t *Tracker) Reset() error
- func (t *Tracker) Save() error
- func (t *Tracker) SetJobID(jobID string)
- func (t *Tracker) ShouldSkip(index int) bool
- func (t *Tracker) UpdateOffset(newOffset int)
Constants ¶
const DefaultOffsetFile = ".mailgrid.offset"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OffsetInfo ¶
type OffsetInfo struct {
JobID string `json:"job_id"`
Offset int `json:"offset"`
Total int `json:"total,omitempty"`
}
OffsetInfo contains information about the current offset state
type Tracker ¶
type Tracker struct {
// contains filtered or unexported fields
}
Tracker manages email delivery offset tracking for resumable campaigns.
Concurrency model:
- GetOffset / ShouldSkip / GetJobID / GetInfo: read-only; safe from any goroutine.
- UpdateOffset / SetJobID: writer methods used by the CLI before/after dispatch.
- MarkComplete: hot-path call from worker goroutines. Maintains a contiguous high-water mark so the persisted offset advances only past indices that have all been completed (correct under concurrent out-of-order completion).
- Save: serializes to disk; the file write happens outside the lock so readers and MarkComplete callers do not block on I/O.
func (*Tracker) GetInfo ¶
func (t *Tracker) GetInfo() OffsetInfo
GetInfo returns current offset information
func (*Tracker) MarkComplete ¶
MarkComplete records that the absolute task index `idx` has been delivered. The persisted offset advances to one past the highest index N such that all indices in [t.offset, N] have been marked complete. Indices that arrive out of order are buffered in t.pending and drained when the gap closes.
Indices that arrive below the current offset (e.g. duplicates from a retry after a flusher has already moved past) are ignored.
func (*Tracker) Save ¶
Save writes the current offset to disk atomically (write to temp + rename). The disk I/O happens outside the tracker lock so concurrent MarkComplete callers are not blocked on fsync.
func (*Tracker) ShouldSkip ¶
ShouldSkip returns true if the given index should be skipped based on offset
func (*Tracker) UpdateOffset ¶
UpdateOffset sets the offset directly. Used by the CLI to seed the tracker from a persisted state and by tests; production worker code should use MarkComplete instead. Calling UpdateOffset clears any pending out-of-order completions because they no longer correspond to a meaningful baseline.