Implemented progressbar for export/import

This commit is contained in:
Philipp Wolfer 2023-11-16 00:45:00 +01:00
parent ab04eb1123
commit 6e330daf06
No known key found for this signature in database
GPG key ID: 8FDF744D4919943B
24 changed files with 590 additions and 239 deletions

View file

@ -30,33 +30,54 @@ import (
// A listen service backend.
// All listen services must implement this interface.
type Backend interface {
// Initialize the backend from a config.
FromConfig(config *viper.Viper) Backend
}
type ImportBackend interface {
Backend
// If the backend needs to setup resources before starting to import,
// this can be done here.
Init() error
// The implementation can perform all steps here to finalize the
// export/import and free used resources.
Finish() error
}
// Must be implemented by services supporting the export of listens.
type ListensExport interface {
Backend
// Returns a list of all listens newer then oldestTimestamp.
// The returned list of listens is supposed to be ordered by the
// Listen.ListenedAt timestamp, with the oldest entry first.
ExportListens(oldestTimestamp time.Time, results chan ListensResult)
ExportListens(oldestTimestamp time.Time, results chan ListensResult, progress chan Progress)
}
// Must be implemented by services supporting the import of listens.
type ListensImport interface {
ImportBackend
// Imports the given list of listens.
ImportListens(results chan ListensResult, oldestTimestamp time.Time) (ImportResult, error)
ImportListens(export ListensResult, importResult ImportResult, progress chan Progress) (ImportResult, error)
}
// Must be implemented by services supporting the export of loves.
type LovesExport interface {
Backend
// Returns a list of all loves newer then oldestTimestamp.
// The returned list of listens is supposed to be ordered by the
// Love.Created timestamp, with the oldest entry first.
ExportLoves(oldestTimestamp time.Time, results chan LovesResult)
ExportLoves(oldestTimestamp time.Time, results chan LovesResult, progress chan Progress)
}
// Must be implemented by services supporting the import of loves.
type LovesImport interface {
ImportBackend
// Imports the given list of loves.
ImportLoves(results chan LovesResult, oldestTimestamp time.Time) (ImportResult, error)
ImportLoves(export LovesResult, importResult ImportResult, progress chan Progress) (ImportResult, error)
}