sheetdoc

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const DefaultSheetID = "s1"

DefaultSheetID is the id of the single sheet created for a brand-new workbook.

Variables

View Source
var ErrHistoryChanged = errors.New("sheet was replaced meanwhile")

ErrHistoryChanged means the workbook was replaced while its history was read.

View Source
var ErrNoHistory = errors.New("sheet history not available")

ErrNoHistory means the versions before the current one are not known: the workbook was imported before the import's base was kept.

View Source
var ErrNoRevision = errors.New("no such revision")

ErrNoRevision means the revision is not in the history.

Functions

This section is empty.

Types

type Manager

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

Manager owns the in-memory sheet documents and serializes operations per document (total order), persisting each op and a workbook snapshot.

Several Etherpad instances may share the database. The stored ops are the authoritative history; a cached document is only a copy and is brought up to the stored state before every use. An op counts once it is stored: if its revision number is taken, another instance was first, and the op is rebased onto the newer state and stored again.

func NewManager

func NewManager(store db.DataStore) *Manager

func (*Manager) History added in v0.7.0

func (m *Manager) History(padId string) (revs []Revision, head int, available bool, err error)

History lists the stored changes up to the head. available is false when the base the changes start from is unknown; earlier versions can then not be shown.

func (*Manager) OpsSince

func (m *Manager) OpsSince(padId string, sinceRev int) (out []sheet.Op, err error)

OpsSince returns the rebased ops applied after sinceRev (for reconnect).

func (*Manager) Restore added in v0.7.0

func (m *Manager) Restore(padId string, rev int, authorId *string, tsMillis int64) (int, error)

Restore brings the workbook back to how it was at rev. It stores the changes that lead there as ordinary ops, so the history in between stays and the restore itself can be undone by restoring the revision before it. It returns the number of ops stored.

func (*Manager) SetWorkbook

func (m *Manager) SetWorkbook(padId string, wb *sheet.Workbook) error

SetWorkbook replaces the document's workbook (e.g. from an xlsx import), resetting it to revision 0 with an empty op-log and starting a new epoch, by which other instances notice that their copy is outdated.

func (*Manager) Snapshot

func (m *Manager) Snapshot(padId string) (snap sheet.WorkbookSnapshot, head int, err error)

Snapshot returns the current workbook snapshot and head (for the initial client state on connect).

func (*Manager) State added in v0.7.0

func (m *Manager) State(padId string) (epoch, head int, err error)

State returns the stored epoch and head of the document.

func (*Manager) StoredOps added in v0.7.0

func (m *Manager) StoredOps(padId string, from, to int) ([]StoredOp, error)

StoredOps returns the stored ops from..to with their authors.

func (*Manager) Submit

func (m *Manager) Submit(padId string, op sheet.Op, authorId *string, tsMillis int64) (sheet.Op, int, error)

Submit rebases, applies, and persists one op, returning the rebased op (for broadcast) and the new head revision.

func (*Manager) SubmitOnce added in v0.7.0

func (m *Manager) SubmitOnce(padId string, op sheet.Op, authorId *string, tsMillis int64) (rebased sheet.Op, rev int, duplicate bool, err error)

SubmitOnce is Submit for ops a client may send twice: an op whose cid is already in the log after its base revision (the client resent it after a reconnect) is not applied again. duplicate reports that case; rebased and rev are then the stored op and its revision.

func (*Manager) WorkbookAt added in v0.7.0

func (m *Manager) WorkbookAt(padId string, rev int) (*sheet.Workbook, error)

WorkbookAt rebuilds the workbook as it was at rev.

type Revision added in v0.7.0

type Revision struct {
	Rev       int    `json:"rev"`
	Timestamp int64  `json:"timestamp"`
	Author    string `json:"author,omitempty"`
}

Revision is one stored change.

type StoredOp added in v0.7.0

type StoredOp struct {
	Rev    int
	Op     sheet.Op
	Author string
}

StoredOp is a stored op with its revision and author.

Jump to

Keyboard shortcuts

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