Added basic documentation of backend interfaces

This commit is contained in:
Philipp Wolfer 2023-11-15 10:06:35 +01:00
parent bae81d9b08
commit 3a76ec7988
No known key found for this signature in database
GPG key ID: 8FDF744D4919943B

View file

@ -27,23 +27,37 @@ import (
"github.com/spf13/viper"
)
// A listen service backend.
// All listen services must implement this interface.
type Backend interface {
FromConfig(config *viper.Viper) Backend
}
// Must be implemented by services supporting the export of listens.
type ListensExport interface {
// 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) ([]Listen, error)
}
// Must be implemented by services supporting the import of listens.
type ListensImport interface {
// Imports the given list of listens.
ImportListens(listens []Listen, oldestTimestamp time.Time) (ImportResult, error)
}
// Must be implemented by services supporting the export of loves.
type LovesExport interface {
// 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) ([]Love, error)
}
// Must be implemented by services supporting the import of loves.
type LovesImport interface {
// Imports the given list of loves.
ImportLoves(loves []Love, oldestTimestamp time.Time) (ImportResult, error)
}