Documentation
¶
Index ¶
- func CreateDB(t *testing.T, keyLen int) sql.Database
- func EnsureDBItems(t *testing.T, db sql.Database, content []rangesync.KeyBytes)
- func InsertDBItems(t *testing.T, db sql.Database, content []rangesync.KeyBytes)
- func PopulateDB(t *testing.T, keyLen int, content []rangesync.KeyBytes) sql.Database
- type Binder
- type IDStore
- type SQLIDStore
- func (s *SQLIDStore) All() rangesync.SeqResult
- func (s *SQLIDStore) Clone() IDStore
- func (s *SQLIDStore) From(from rangesync.KeyBytes, sizeHint int) rangesync.SeqResult
- func (s *SQLIDStore) RegisterKey(k rangesync.KeyBytes) error
- func (s *SQLIDStore) Release()
- func (s *SQLIDStore) SetSnapshot(sts *SyncedTableSnapshot)
- func (s *SQLIDStore) Since(from rangesync.KeyBytes, since int64) (rangesync.SeqResult, int)
- type SyncedTable
- type SyncedTableSnapshot
- func (sts *SyncedTableSnapshot) Load(db sql.Executor, dec func(stmt *sql.Statement) bool) error
- func (sts *SyncedTableSnapshot) LoadCount(db sql.Executor) (int, error)
- func (sts *SyncedTableSnapshot) LoadRange(db sql.Executor, fromID rangesync.KeyBytes, limit int, ...) error
- func (sts *SyncedTableSnapshot) LoadRecent(db sql.Executor, fromID rangesync.KeyBytes, limit int, since int64, ...) error
- func (sts *SyncedTableSnapshot) LoadRecentCount(db sql.Executor, since int64) (int, error)
- func (sts *SyncedTableSnapshot) LoadSinceSnapshot(db sql.Executor, prev *SyncedTableSnapshot, dec func(stmt *sql.Statement) bool) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureDBItems ¶ added in v1.7.10
EnsureDBItems inserts items into a test database, skipping rows with keys that already exist. It is only used for testing.
func InsertDBItems ¶
InsertDBItems inserts items into a test database. It is only used for testing.
Types ¶
type IDStore ¶
type IDStore interface { // Clone makes a copy of the store. // It is expected to be an O(1) operation. Clone() IDStore // Release releases the resources associated with the store. Release() // RegisterKey registers the key with the store. RegisterKey(k rangesync.KeyBytes) error // All returns all keys in the store. // The sequence in SeqResult returned by All is either empty or infinite. All() rangesync.SeqResult // From returns all keys in the store starting from the given key. // sizeHint is a hint for the expected number of keys to be returned. // The sequence in SeqResult returned by From is either empty or infinite. From(from rangesync.KeyBytes, sizeHint int) rangesync.SeqResult }
IDStore represents a store of IDs (keys).
type SQLIDStore ¶
type SQLIDStore struct {
// contains filtered or unexported fields
}
SQLIDStore is an implementation of IDStore that is based on a database table snapshot.
func NewSQLIDStore ¶
func NewSQLIDStore(db sql.Executor, sts *SyncedTableSnapshot, keyLen int) *SQLIDStore
NewSQLIDStore creates a new SQLIDStore.
func (*SQLIDStore) All ¶
func (s *SQLIDStore) All() rangesync.SeqResult
All returns all IDs in the store. The sequence in SeqResult returned by All is either empty or infinite. Implements IDStore.
func (*SQLIDStore) Clone ¶
func (s *SQLIDStore) Clone() IDStore
Clone creates a new SQLIDStore that shares the same database connection and table snapshot. Implements IDStore.
func (*SQLIDStore) From ¶
From returns IDs in the store starting from the given key. The sequence in SeqResult returned by From is either empty or infinite. Implements IDStore.
func (*SQLIDStore) RegisterKey ¶
func (s *SQLIDStore) RegisterKey(k rangesync.KeyBytes) error
RegisterKey is a no-op for SQLIDStore, as the underlying table is never immediately updated upon receiving new items. Implements IDStore.
func (*SQLIDStore) Release ¶
func (s *SQLIDStore) Release()
Release is a no-op for SQLIDStore. Implements IDStore.
func (*SQLIDStore) SetSnapshot ¶
func (s *SQLIDStore) SetSnapshot(sts *SyncedTableSnapshot)
Sets the table snapshot to use for the store.
type SyncedTable ¶
type SyncedTable struct { // The name of the table. TableName string // The name of the ID column. IDColumn string // The name of the timestamp column. TimestampColumn string // The filter expression. Filter expr.Expr // The binder function for the bind parameters appearing in the filter expression. Binder Binder // contains filtered or unexported fields }
SyncedTable represents a table that can be used with SQLIDStore.
func (*SyncedTable) Snapshot ¶
func (st *SyncedTable) Snapshot(db sql.Executor) (*SyncedTableSnapshot, error)
Snaptshot creates a snapshot of the table based on its current max rowid value.
type SyncedTableSnapshot ¶
type SyncedTableSnapshot struct { *SyncedTable // contains filtered or unexported fields }
SyncedTableSnapshot represents a snapshot of an append-only table. The snapshotting is relies on rowids of the table rows never decreasing as new rows are added. Each snapshot inherits filter expression from the table, so all the rows relevant to the snapshot are always filtered using that expression, if it's specified.
func (*SyncedTableSnapshot) LoadCount ¶
func (sts *SyncedTableSnapshot) LoadCount( db sql.Executor, ) (int, error)
LoadCount returns the number of rows in the snapshot.
func (*SyncedTableSnapshot) LoadRange ¶
func (sts *SyncedTableSnapshot) LoadRange( db sql.Executor, fromID rangesync.KeyBytes, limit int, dec func(stmt *sql.Statement) bool, ) error
LoadRange loads ids starting from the specified one. limit specifies the maximum number of ids to load.
func (*SyncedTableSnapshot) LoadRecent ¶
func (sts *SyncedTableSnapshot) LoadRecent( db sql.Executor, fromID rangesync.KeyBytes, limit int, since int64, dec func(stmt *sql.Statement) bool, ) error
LoadRecent loads rows added since the specified timestamp.
func (*SyncedTableSnapshot) LoadRecentCount ¶
LoadRecentCount returns the number of rows added since the specified timestamp.
func (*SyncedTableSnapshot) LoadSinceSnapshot ¶
func (sts *SyncedTableSnapshot) LoadSinceSnapshot( db sql.Executor, prev *SyncedTableSnapshot, dec func(stmt *sql.Statement) bool, ) error
LoadSinceSnapshot loads rows added since the specified previous snapshot.