Documentation
¶
Index ¶
- Constants
- Variables
- type Manager
- func (m *Manager) History(padId string) (revs []Revision, head int, available bool, err error)
- func (m *Manager) OpsSince(padId string, sinceRev int) (out []sheet.Op, err error)
- func (m *Manager) Restore(padId string, rev int, authorId *string, tsMillis int64) (int, error)
- func (m *Manager) SetWorkbook(padId string, wb *sheet.Workbook) error
- func (m *Manager) Snapshot(padId string) (snap sheet.WorkbookSnapshot, head int, err error)
- func (m *Manager) State(padId string) (epoch, head int, err error)
- func (m *Manager) StoredOps(padId string, from, to int) ([]StoredOp, error)
- func (m *Manager) Submit(padId string, op sheet.Op, authorId *string, tsMillis int64) (sheet.Op, int, error)
- func (m *Manager) SubmitOnce(padId string, op sheet.Op, authorId *string, tsMillis int64) (rebased sheet.Op, rev int, duplicate bool, err error)
- func (m *Manager) WorkbookAt(padId string, rev int) (*sheet.Workbook, error)
- type Revision
- type StoredOp
Constants ¶
const DefaultSheetID = "s1"
DefaultSheetID is the id of the single sheet created for a brand-new workbook.
Variables ¶
var ErrHistoryChanged = errors.New("sheet was replaced meanwhile")
ErrHistoryChanged means the workbook was replaced while its history was read.
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.
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 (*Manager) History ¶ added in v0.7.0
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) Restore ¶ added in v0.7.0
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 ¶
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 ¶
Snapshot returns the current workbook snapshot and head (for the initial client state on connect).
func (*Manager) StoredOps ¶ added in v0.7.0
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.