Documentation ¶
Index ¶
- Constants
- type Migrator
- type SqlStore
- func (s *SqlStore) BackupSqlStore(ctx context.Context, w io.Writer) (rErr error)
- func (s *SqlStore) Close() error
- func (s *SqlStore) Flush(ctx context.Context)
- func (s *SqlStore) RLockSqlStore()
- func (s *SqlStore) RUnlockSqlStore()
- func (s *SqlStore) RestoreSqlStore(ctx context.Context, r io.Reader) (rErr error)
Constants ¶
const ( DefaultFilename = "influxd.sqlite" InmemPath = ":memory:" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Migrator ¶
type Migrator struct {
// contains filtered or unexported fields
}
func (*Migrator) Down ¶
Down applies the "down" migrations until the SQL database has migrations only >= untilMigration. Use untilMigration = 0 to apply all down migrations, which will delete all data from the database.
func (*Migrator) SetBackupPath ¶
SetBackupPath records the filepath where pre-migration state should be written prior to running migrations.
type SqlStore ¶
SqlStore is a wrapper around the db and provides basic functionality for maintaining the db including flushing the data from the db during end-to-end testing.
func (*SqlStore) BackupSqlStore ¶
BackupSqlStore creates a new temporary database and uses the sqlite backup API to back the database up into the temporary database. It then writes the temporary database file to the writer. Using the sqlite backup API allows the backup to be performed without needing to lock the database, and also allows it to work with in-memory databases. See: https://www.sqlite.org/backup.html
The backup works by copying the SOURCE database to the DESTINATION database. The SOURCE is the running database that needs to be backed up, and the DESTINATION is the resulting backup. The underlying sqlite connection is needed for both SOURCE and DESTINATION databases to use the sqlite backup API made available by the go-sqlite3 driver.
func (*SqlStore) Flush ¶
Flush deletes all records for all tables in the database except for the migration table. This method should only be used during end-to-end testing.
func (*SqlStore) RLockSqlStore ¶
func (s *SqlStore) RLockSqlStore()
RLockSqlStore locks the database using the mutex. This is intended to lock the database for writes. It is the responsibilty of implementing service code to manage locks for write operations.
func (*SqlStore) RUnlockSqlStore ¶
func (s *SqlStore) RUnlockSqlStore()
RUnlockSqlStore unlocks the database.