Documentation
¶
Index ¶
- Constants
- type Migrator
- type SqlStore
- func (s *SqlStore) BackupSqlStore(ctx context.Context, w io.Writer) (rErr error)
- func (s *SqlStore) Check(ctx context.Context) check.Response
- func (s *SqlStore) CheckName() string
- 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)
- type SqlStoreOption
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 NewSqlStore ¶
func NewTestStore ¶
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) Check ¶ added in v2.10.0
Check pings the underlying sqlite database to confirm it is reachable. The probe has an upper bound of check.DefaultProbeTimeout even when ctx has no deadline, so /health latency stays bounded if the driver is wedged. s.Mu is held as a reader so a concurrent RestoreSqlStore (which swaps s.DB under the write lock) cannot observe a torn handle. The response is stamped with s.name so the launcher can register the store without an extra check.Named wrapper.
func (*SqlStore) CheckName ¶ added in v2.10.0
CheckName satisfies check.NamedChecker so the store can be passed to AddNamedHealthCheck without an extra wrapper. Returns the name configured by WithCheckName, or "" if unset, which registration rejects.
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.
type SqlStoreOption ¶ added in v2.10.0
type SqlStoreOption func(*SqlStore)
SqlStoreOption configures a SqlStore at construction time.
func WithCheckName ¶ added in v2.10.0
func WithCheckName(name string) SqlStoreOption
WithCheckName sets the name reported by Check and CheckName. Required for callers that register the store with a kit/check.Check registry; other callers can omit it and leave CheckName empty.