Documentation
¶
Index ¶
- type DLog
- func (dl *DLog) AppendEntry(entry *Entry) (logPosition int64, logFile LogFileID, err error)
- func (dl *DLog) Close() error
- func (dl *DLog) GetActiveLog() LogFileID
- func (dl *DLog) GetInactiveLog() LogFileID
- func (dl *DLog) Iterator() (*DLogIter, error)
- func (dl *DLog) ReadEntryAt(logFile LogFileID, position int64) (*Entry, error)
- func (dl *DLog) SwitchActive() error
- type DLogFile
- type DLogIter
- type Entry
- type LogFileID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DLog ¶
type DLog struct {
// contains filtered or unexported fields
}
DLog manages the logA/logB double-buffered log files. Follows the double-buffering pattern where one log is active for writes and the other is inactive (being snapshotted or ready for compaction).
func NewDLog ¶
NewDLog creates a new double-buffered log manager. Initializes both logA and logB files, determines active log from state. Defaults to LogA as active if no state exists.
func (*DLog) AppendEntry ¶
AppendEntry appends an Entry to the active log file. The Entry.Commit is provided by the caller (from seq.Seq.NextCommit()). Returns the log position and which log file (A or B) it was written to. Does NOT automatically switch active log - that's handled by the caller when compaction boundaries are reached.
func (*DLog) GetActiveLog ¶
GetActiveLog returns the currently active log file ID.
func (*DLog) GetInactiveLog ¶
GetInactiveLog returns the currently inactive log file ID.
func (*DLog) Iterator ¶
Iterator creates an iterator for reading entries from both log files in commit order. Starts at position 0 for both files. Note: Currently uses non-streaming reads. Streaming support can be added later.
func (*DLog) ReadEntryAt ¶
ReadEntryAt reads an Entry from the specified log file at the given position. logFile must be "A" or "B".
func (*DLog) SwitchActive ¶
SwitchActive switches the active log (A ↔ B). Called by the caller when compaction boundaries are reached.
type DLogFile ¶
type DLogFile struct {
// contains filtered or unexported fields
}
DLogFile represents a single log file with its operations
func (*DLogFile) AppendEntry ¶
AppendEntry appends an Entry to this log file. Format: [4 bytes: uint32 length (big-endian)][entry data in Tony wire format] Returns the byte position where the entry was written.
func (*DLogFile) ReadEntryAt ¶
ReadEntryAt reads an Entry from the specified byte position. Reads length prefix, then entry data, deserializes to Entry.
type DLogIter ¶
type DLogIter struct {
// contains filtered or unexported fields
}
DLogIter provides sequential iteration over log entries using streaming reads. Uses streaming parsing to avoid loading entire entries into memory. Iterates over both logA and logB, switching between them based on commit order.
type Entry ¶
type Entry struct {
Commit int64 // Commit number (set when appended to log)
Timestamp string // RFC3339 timestamp
Patch *ir.Node // Root patch/diff (always at root, empty kinded path "")
TxSource *tx.State // Transaction state (for transaction entries)
SnapPos *int64 // Snapshot position (for snapshot entries)
LastCommit *int64 // Last commit before compaction (for compaction entries)
}
Entry represents a log entry written to logA/logB. This structure supports 4 types of entries:
- Plain patch: Patch set, TxSource/SnapPos nil *LastCommit=Commit-1
- Transaction: Patch and TxSource set, SnapPos nil *LastCommit=Commit-1
- Snapshot: SnapPos set to point to log where state exists, TxSource nil, LastCommit nil
- Compaction: Patch set, LastCommit set Commit-*LastCommit > 1, TxSource nil, SnapPos nil
func NewEntry ¶
func NewEntry(state *tx.State, mergedPatch *ir.Node, commit int64, timestamp string, lastCommit int64) *Entry
NewEntry creates a dlog.Entry for a transaction commit. The entry contains the merged patch and transaction state for debugging/dev. Parameters:
- state: The transaction state (will be stored in TxSource)
- mergedPatch: The merged root patch/diff (already merged from all participants)
- commit: The commit number for this entry
- timestamp: RFC3339 timestamp string
- lastCommit: The commit number before this one (typically commit-1)
func (*Entry) FromTony ¶
func (s *Entry) FromTony(data []byte, opts ...gomap.UnmapOption) error
FromTony parses Tony format bytes and populates Entry.
func (*Entry) FromTonyIR ¶
FromTonyIR populates Entry from a Tony IR node.