Documentation
¶
Overview ¶
Package patches provides streaming patch application for snapshots.
This package implements the PatchApplier interface for applying patches to event streams without materializing full documents in memory.
Current implementation (InMemoryApplier) is temporary and materializes the full document. Future implementation (StreamingApplier) will apply patches incrementally to streaming events, only materializing small subtrees at patch target paths.
See docs/patch_design_reference.md for the full streaming design (Piece 2).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventReadCloser ¶
type EventReadCloser interface {
stream.EventReader
io.Closer
}
EventReadCloser extends stream.EventReader with Close for managing resources. This is specific to storage layer needs, not part of the general stream package.
func NewEmptyEventReader ¶
func NewEmptyEventReader() EventReadCloser
NewEmptyEventReader creates an empty event reader. Returns an EventReadCloser with a no-op Close method.
func NewSnapshotEventReader ¶
func NewSnapshotEventReader(r io.ReadCloser) EventReadCloser
NewSnapshotEventReader creates an event reader from a closable reader positioned at snapshot events. Takes ownership of the closer and will close it when Close() is called.
type EventWriteCloser ¶
type EventWriteCloser interface {
stream.EventWriter
io.Closer
}
EventWriteCloser extends stream.EventSink with Close for managing resources. This is specific to storage layer needs, not part of the general stream package.
func NewBufferEventSink ¶
func NewBufferEventSink(buf *bytes.Buffer) EventWriteCloser
NewBufferEventSink creates an event sink that writes to a byte buffer. Returns an EventWriteCloser with a no-op Close since buffers don't need closing.
func NewFileEventSink ¶
func NewFileEventSink(w io.WriteCloser) EventWriteCloser
NewFileEventSink creates an event sink that writes to a file or other closable writer. Takes ownership of the closer and will close it when Close() is called.
type InMemoryApplier ¶
type InMemoryApplier struct{}
InMemoryApplier is a temporary implementation that materializes the full document. This violates the streaming principle but provides a working implementation until the streaming processor (Piece 2 from patch_design_reference.md) is complete.
func NewInMemoryApplier ¶
func NewInMemoryApplier() *InMemoryApplier
NewInMemoryApplier creates an in-memory patch applier.
func (*InMemoryApplier) ApplyPatches ¶
func (a *InMemoryApplier) ApplyPatches(baseEvents stream.EventReader, patches []*ir.Node, sink stream.EventWriter) error
ApplyPatches materializes the full document, applies patches, converts back to events. TODO: Replace with streaming implementation that never materializes full document.
type PatchApplier ¶
type PatchApplier interface {
// ApplyPatches applies patches to base events, writes result to sink.
// Patches are applied in order.
ApplyPatches(baseEvents stream.EventReader, patches []*ir.Node, sink stream.EventWriter) error
}
PatchApplier applies patches to streaming events. Implementations may materialize subtrees or stream fully depending on design.