Documentation ¶
Index ¶
- Constants
- Variables
- func LatestVersion() semver.Version
- type SQLStore
- func (sqlStore *SQLStore) CompleteUpload(uploadID, errorMessage string) error
- func (sqlStore *SQLStore) CreateImport(imp *model.Import) error
- func (sqlStore *SQLStore) CreateTranslation(translation *model.Translation) error
- func (sqlStore *SQLStore) CreateUpload(id string, archiveType model.BackupType) error
- func (sqlStore *SQLStore) GetAllImports() ([]*model.Import, error)
- func (sqlStore *SQLStore) GetAllTranslations() ([]*model.Translation, error)
- func (sqlStore *SQLStore) GetAndClaimNextReadyImport(provisionerID string) (*model.Import, error)
- func (sqlStore *SQLStore) GetCurrentVersion() (semver.Version, error)
- func (sqlStore *SQLStore) GetImport(id string) (*model.Import, error)
- func (sqlStore *SQLStore) GetImportsByInstallation(id string) ([]*model.Import, error)
- func (sqlStore *SQLStore) GetImportsByTranslation(id string) ([]*model.Import, error)
- func (sqlStore *SQLStore) GetImportsInProgress() ([]*model.Import, error)
- func (sqlStore *SQLStore) GetTranslation(id string) (*model.Translation, error)
- func (sqlStore *SQLStore) GetTranslationReadyToStart() (*model.Translation, error)
- func (sqlStore *SQLStore) GetTranslationsByInstallation(id string) ([]*model.Translation, error)
- func (sqlStore *SQLStore) GetUnlockedImportPendingWork() ([]*model.Import, error)
- func (sqlStore *SQLStore) GetUpload(id string) (*model.Upload, error)
- func (sqlStore *SQLStore) GetUploads() ([]*model.Upload, error)
- func (sqlStore *SQLStore) Migrate() error
- func (sqlStore *SQLStore) TryLockImport(imp *model.Import, owner string) error
- func (sqlStore *SQLStore) TryLockTranslation(translation *model.Translation, owner string) error
- func (sqlStore *SQLStore) UnlockImport(imp *model.Import) error
- func (sqlStore *SQLStore) UnlockTranslation(translation *model.Translation) error
- func (sqlStore *SQLStore) UpdateImport(imp *model.Import) error
- func (sqlStore *SQLStore) UpdateTranslation(translation *model.Translation) error
- type Transaction
Constants ¶
const ImportTableName = "Import"
ImportTableName is the name of the database table used for storing import records.
const TranslationTableName = "Translation"
TranslationTableName is the name of the database table used for storing translation data.
Variables ¶
var UploadTableName = "Upload"
UploadTableName is the name of the database table used for storing upload records.
Functions ¶
func LatestVersion ¶
LatestVersion returns the version to which the last migration migrates.
Types ¶
type SQLStore ¶
type SQLStore struct {
// contains filtered or unexported fields
}
SQLStore abstracts access to the database.
func New ¶
New creates and initializes a new SQLStore instance. It takes a database connection string (DSN) and a logger instance. It returns an initialized SQLStore or an error if the connection to the database fails.
func (*SQLStore) CompleteUpload ¶
CompleteUpload marks an upload as complete in the database, with or without an error message (provide an empty string if no error)
func (*SQLStore) CreateImport ¶ added in v0.2.0
CreateImport stores a new import.
func (*SQLStore) CreateTranslation ¶ added in v0.2.0
func (sqlStore *SQLStore) CreateTranslation(translation *model.Translation) error
CreateTranslation stores a new translation.
func (*SQLStore) CreateUpload ¶
func (sqlStore *SQLStore) CreateUpload(id string, archiveType model.BackupType) error
CreateUpload creates an upload object in the database to represent a started upload
func (*SQLStore) GetAllImports ¶
GetAllImports returns all of the Imports in the database TODO pagination
func (*SQLStore) GetAllTranslations ¶
func (sqlStore *SQLStore) GetAllTranslations() ([]*model.Translation, error)
GetAllTranslations returns every Translation in the DB TODO pagination
func (*SQLStore) GetAndClaimNextReadyImport ¶
GetAndClaimNextReadyImport finds the oldest unclaimed and non-started Import and locks it with the given provisionerID before returning that Import Returns nil with no error if no Import is available to lock Returns nil, error if the Import cannot be claimed for some other reason
func (*SQLStore) GetCurrentVersion ¶
GetCurrentVersion queries the System table for the current database version.
func (*SQLStore) GetImportsByInstallation ¶
GetImportsByInstallation provides a convenience function for looking up all Imports that belong to a given Installation
func (*SQLStore) GetImportsByTranslation ¶
GetImportsByTranslation provides a convenience function for looking up all Imports that belong to a given Translation
func (*SQLStore) GetImportsInProgress ¶
GetImportsInProgress retrieves all imports that are currently in progress.
func (*SQLStore) GetTranslation ¶
func (sqlStore *SQLStore) GetTranslation(id string) (*model.Translation, error)
GetTranslation returns the Translation that corresponds to the identifier ID
func (*SQLStore) GetTranslationReadyToStart ¶
func (sqlStore *SQLStore) GetTranslationReadyToStart() (*model.Translation, error)
GetTranslationReadyToStart returns a batch of Translations that are ready to go, with a maximum of ten, sorted from oldest to newest
func (*SQLStore) GetTranslationsByInstallation ¶
func (sqlStore *SQLStore) GetTranslationsByInstallation(id string) ([]*model.Translation, error)
GetTranslationsByInstallation provides a convenience method for fetching every Translation related to a given Installation by its ID
func (*SQLStore) GetUnlockedImportPendingWork ¶ added in v0.3.0
GetUnlockedImportPendingWork retrieves all imports that are pending work and not locked.
func (*SQLStore) GetUpload ¶
GetUpload will fetch the metadata about an upload from the database by ID.
func (*SQLStore) GetUploads ¶ added in v0.4.0
GetUploads will fetch a list of uploads.
func (*SQLStore) Migrate ¶
Migrate advances the schema of the configured database to the latest version.
func (*SQLStore) TryLockImport ¶
TryLockImport attempts to lock the input Import with the given owner, but will not do so if the column already contains something, and will return an error instead in that case
func (*SQLStore) TryLockTranslation ¶
func (sqlStore *SQLStore) TryLockTranslation(translation *model.Translation, owner string) error
TryLockTranslation attempts to claim the given translation for the owner ID provided and returns an error if it fails to do so
func (*SQLStore) UnlockImport ¶
UnlockImport clears the lock for the given Import
func (*SQLStore) UnlockTranslation ¶
func (sqlStore *SQLStore) UnlockTranslation(translation *model.Translation) error
UnlockTranslation clears the lock on the given translation
func (*SQLStore) UpdateImport ¶
UpdateImport writes changes to the input Import to the database
func (*SQLStore) UpdateTranslation ¶
func (sqlStore *SQLStore) UpdateTranslation(translation *model.Translation) error
UpdateTranslation stores changes to the provided translation in the database.
type Transaction ¶
Transaction is a wrapper around *sqlx.Tx providing convenience methods.
func (*Transaction) Commit ¶
func (t *Transaction) Commit() error
Commit commits the pending transaction.
func (*Transaction) RollbackUnlessCommitted ¶
func (t *Transaction) RollbackUnlessCommitted()
RollbackUnlessCommitted rollback the transaction if it is not committed.