Documentation ¶
Index ¶
- type DB
- func (d *DB) ActivateClient(ctx context.Context, projectID types.ID, key string) (*database.ClientInfo, error)
- func (d *DB) Close() error
- func (d *DB) CreateChangeInfos(ctx context.Context, projectID types.ID, docInfo *database.DocInfo, ...) error
- func (d *DB) CreateProjectInfo(ctx context.Context, name string) (*database.ProjectInfo, error)
- func (d *DB) CreateSnapshotInfo(ctx context.Context, docID types.ID, doc *document.InternalDocument) error
- func (d *DB) DeactivateClient(ctx context.Context, projectID, clientID types.ID) (*database.ClientInfo, error)
- func (d *DB) EnsureDefaultProjectInfo(ctx context.Context) (*database.ProjectInfo, error)
- func (d *DB) FindChangeInfosBetweenServerSeqs(ctx context.Context, docID types.ID, from uint64, to uint64) ([]*database.ChangeInfo, error)
- func (d *DB) FindChangesBetweenServerSeqs(ctx context.Context, docID types.ID, from uint64, to uint64) ([]*change.Change, error)
- func (d *DB) FindClientInfoByID(ctx context.Context, projectID, clientID types.ID) (*database.ClientInfo, error)
- func (d *DB) FindClosestSnapshotInfo(ctx context.Context, docID types.ID, serverSeq uint64) (*database.SnapshotInfo, error)
- func (d *DB) FindDeactivateCandidates(ctx context.Context, inactiveThreshold gotime.Duration, candidatesLimit int) ([]*database.ClientInfo, error)
- func (d *DB) FindDocInfoByID(ctx context.Context, id types.ID) (*database.DocInfo, error)
- func (d *DB) FindDocInfoByKey(ctx context.Context, projectID types.ID, clientID types.ID, key key.Key, ...) (*database.DocInfo, error)
- func (d *DB) FindDocInfosByPaging(ctx context.Context, projectID types.ID, paging types.Paging) ([]*database.DocInfo, error)
- func (d *DB) FindProjectInfoByName(ctx context.Context, name string) (*database.ProjectInfo, error)
- func (d *DB) FindProjectInfoByPublicKey(ctx context.Context, publicKey string) (*database.ProjectInfo, error)
- func (d *DB) ListProjectInfos(ctx context.Context) ([]*database.ProjectInfo, error)
- func (d *DB) UpdateAndFindMinSyncedTicket(ctx context.Context, clientInfo *database.ClientInfo, docID types.ID, ...) (*time.Ticket, error)
- func (d *DB) UpdateClientInfoAfterPushPull(ctx context.Context, clientInfo *database.ClientInfo, ...) error
- func (d *DB) UpdateProjectInfo(ctx context.Context, info *database.ProjectInfo) error
- func (d *DB) UpdateSyncedSeq(ctx context.Context, clientInfo *database.ClientInfo, docID types.ID, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is an in-memory database for testing or temporarily.
func (*DB) ActivateClient ¶
func (d *DB) ActivateClient( ctx context.Context, projectID types.ID, key string, ) (*database.ClientInfo, error)
ActivateClient activates a client.
func (*DB) CreateChangeInfos ¶
func (d *DB) CreateChangeInfos( ctx context.Context, projectID types.ID, docInfo *database.DocInfo, initialServerSeq uint64, changes []*change.Change, ) error
CreateChangeInfos stores the given changes and doc info.
func (*DB) CreateProjectInfo ¶
CreateProjectInfo creates a new project.
func (*DB) CreateSnapshotInfo ¶
func (d *DB) CreateSnapshotInfo( ctx context.Context, docID types.ID, doc *document.InternalDocument, ) error
CreateSnapshotInfo stores the snapshot of the given document.
func (*DB) DeactivateClient ¶
func (d *DB) DeactivateClient(ctx context.Context, projectID, clientID types.ID) (*database.ClientInfo, error)
DeactivateClient deactivates a client.
func (*DB) EnsureDefaultProjectInfo ¶
EnsureDefaultProjectInfo creates the default project if it does not exist.
func (*DB) FindChangeInfosBetweenServerSeqs ¶
func (d *DB) FindChangeInfosBetweenServerSeqs( ctx context.Context, docID types.ID, from uint64, to uint64, ) ([]*database.ChangeInfo, error)
FindChangeInfosBetweenServerSeqs returns the changeInfos between two server sequences.
func (*DB) FindChangesBetweenServerSeqs ¶
func (d *DB) FindChangesBetweenServerSeqs( ctx context.Context, docID types.ID, from uint64, to uint64, ) ([]*change.Change, error)
FindChangesBetweenServerSeqs returns the changes between two server sequences.
func (*DB) FindClientInfoByID ¶
func (d *DB) FindClientInfoByID(ctx context.Context, projectID, clientID types.ID) (*database.ClientInfo, error)
FindClientInfoByID finds a client by ID.
func (*DB) FindClosestSnapshotInfo ¶
func (d *DB) FindClosestSnapshotInfo( ctx context.Context, docID types.ID, serverSeq uint64, ) (*database.SnapshotInfo, error)
FindClosestSnapshotInfo finds the last snapshot of the given document.
func (*DB) FindDeactivateCandidates ¶
func (d *DB) FindDeactivateCandidates( ctx context.Context, inactiveThreshold gotime.Duration, candidatesLimit int, ) ([]*database.ClientInfo, error)
FindDeactivateCandidates finds the clients that need housekeeping.
func (*DB) FindDocInfoByID ¶
FindDocInfoByID finds a docInfo of the given ID.
func (*DB) FindDocInfoByKey ¶
func (d *DB) FindDocInfoByKey( ctx context.Context, projectID types.ID, clientID types.ID, key key.Key, createDocIfNotExist bool, ) (*database.DocInfo, error)
FindDocInfoByKey finds a docInfo by key.
func (*DB) FindDocInfosByPaging ¶
func (d *DB) FindDocInfosByPaging( ctx context.Context, projectID types.ID, paging types.Paging, ) ([]*database.DocInfo, error)
FindDocInfosByPaging returns the documentInfos of the given paging.
func (*DB) FindProjectInfoByName ¶ added in v0.2.6
FindProjectInfoByName returns a project by the given name.
func (*DB) FindProjectInfoByPublicKey ¶
func (d *DB) FindProjectInfoByPublicKey(ctx context.Context, publicKey string) (*database.ProjectInfo, error)
FindProjectInfoByPublicKey returns a project by public key.
func (*DB) ListProjectInfos ¶
ListProjectInfos returns all projects.
func (*DB) UpdateAndFindMinSyncedTicket ¶
func (d *DB) UpdateAndFindMinSyncedTicket( ctx context.Context, clientInfo *database.ClientInfo, docID types.ID, serverSeq uint64, ) (*time.Ticket, error)
UpdateAndFindMinSyncedTicket updates the given serverSeq of the given client and returns the min synced ticket.
func (*DB) UpdateClientInfoAfterPushPull ¶
func (d *DB) UpdateClientInfoAfterPushPull( ctx context.Context, clientInfo *database.ClientInfo, docInfo *database.DocInfo, ) error
UpdateClientInfoAfterPushPull updates the client from the given clientInfo after handling PushPull.
func (*DB) UpdateProjectInfo ¶
UpdateProjectInfo updates the given project.