document

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package document coordinates the piece tree, recovery WAL, transactional history, leased source generations, and atomic persistence.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRevisionConflict = errors.New("document: revision conflict")
	ErrInvalidUTF8      = errors.New("document: file is not UTF-8")
	ErrClosed           = errors.New("document: session closed")
	ErrNothingToUndo    = errors.New("document: nothing to undo")
	ErrNothingToRedo    = errors.New("document: nothing to redo")
	ErrExternalChange   = errors.New("document: file changed on disk")
	ErrRevisionOverflow = errors.New("document: revision overflow")
)

Functions

This section is empty.

Types

type ApplyResult

type ApplyResult struct {
	Revision   uint64
	ByteLength int64
	Dirty      bool
}

type EOLStyle

type EOLStyle string
const (
	EOLLF    EOLStyle = "lf"
	EOLCRLF  EOLStyle = "crlf"
	EOLMixed EOLStyle = "mixed"
)

type Metadata

type Metadata struct {
	Path              string
	Name              string
	ByteLength        int64
	Revision          uint64
	CommittedRevision uint64
	Dirty             bool
	Recovered         bool
	HasBOM            bool
	EOL               EOLStyle
}

type OpenOptions

type OpenOptions struct {
	RecoveryDir string
	SessionDir  string
}

type ReplaceOperation

type ReplaceOperation struct {
	Start        int64
	DeleteLength int64
	Insert       string
}

type Session

type Session struct {
	// contains filtered or unexported fields
}

func Open

func Open(path string, options OpenOptions) (*Session, error)

func (*Session) ApplyBatch

func (s *Session) ApplyBatch(ctx context.Context, expectedRevision uint64, operations []ReplaceOperation) (ApplyResult, error)

func (*Session) Close

func (s *Session) Close() error

func (*Session) CommitAtLeast

func (s *Session) CommitAtLeast(expectedRevision uint64) (Metadata, error)

CommitAtLeast atomically persists a snapshot whose revision is at least the requested revision. New edits continue in the current generation while the snapshot is streamed.

func (*Session) Metadata

func (s *Session) Metadata() Metadata

func (*Session) ReadAt

func (s *Session) ReadAt(p []byte, off int64) (int, error)

func (*Session) Redo

func (s *Session) Redo() (ApplyResult, error)

func (*Session) Save

func (s *Session) Save() (Metadata, error)

func (*Session) Snapshot

func (s *Session) Snapshot() (uint64, SnapshotLease, error)

func (*Session) Undo

func (s *Session) Undo() (ApplyResult, error)

type SnapshotLease

type SnapshotLease interface {
	io.ReaderAt
	Len() int64
	WriteTo(io.Writer) (int64, error)
	Close() error
}

SnapshotLease keeps every source used by a snapshot alive until Close. Callers must release the lease when they finish reading or saving a snapshot.

Directories

Path Synopsis
Package save contains streaming, crash-safe document persistence.
Package save contains streaming, crash-safe document persistence.
Package store implements a bounded-memory source store for large documents.
Package store implements a bounded-memory source store for large documents.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL