Documentation
¶
Index ¶
- func NewSQLite(dbFilePath string, requiredVer uint) (*sql.DB, error)
- type SQLiteStore
- func (s *SQLiteStore) Begin(ctx context.Context) (Store, error)
- func (s *SQLiteStore) Close()
- func (s *SQLiteStore) Commit() error
- func (s *SQLiteStore) EpisodeCountAll(ctx context.Context) (int, error)
- func (s *SQLiteStore) EpisodeCreate(ctx context.Context, episode *entities.Episode) error
- func (s *SQLiteStore) EpisodeGetByOriginalUrl(ctx context.Context, url string) ([]*entities.Episode, error)
- func (s *SQLiteStore) EpisodeGetLastTime(ctx context.Context) (time.Time, error)
- func (s *SQLiteStore) EpisodeListAll(ctx context.Context) ([]*entities.Episode, error)
- func (s *SQLiteStore) ProcessCountByUrlAndStatus(ctx context.Context, url string, status entities.Status) (int, error)
- func (s *SQLiteStore) ProcessGetByStatus(ctx context.Context, status entities.Status) ([]*entities.Process, error)
- func (s *SQLiteStore) ProcessUpsert(ctx context.Context, process *entities.Process) error
- func (s *SQLiteStore) Rollback() error
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type SQLiteStore ¶
type SQLiteStore struct {
// contains filtered or unexported fields
}
SQLiteStore is a SQLite implementation of the Store interface.
func NewSQLiteStore ¶
func NewSQLiteStore(db *sql.DB) *SQLiteStore
NewSQLiteStore creates a new SQLiteStore instance.
func (*SQLiteStore) Begin ¶
func (s *SQLiteStore) Begin(ctx context.Context) (Store, error)
Begin returns a new SQLiteStore within a transaction
func (*SQLiteStore) EpisodeCountAll ¶ added in v0.1.0
func (s *SQLiteStore) EpisodeCountAll(ctx context.Context) (int, error)
EpisodeCountAll returns the total count of episodes in the database
func (*SQLiteStore) EpisodeCreate ¶
EpisodeCreate creates a new episode in the database
func (*SQLiteStore) EpisodeGetByOriginalUrl ¶
func (s *SQLiteStore) EpisodeGetByOriginalUrl(ctx context.Context, url string) ([]*entities.Episode, error)
EpisodeGetByOriginalUrl returns episodes by original URL
func (*SQLiteStore) EpisodeGetLastTime ¶ added in v0.1.0
EpisodeGetLastTime returns the creation time of the most recently added episode. If no episodes exist, it returns zero time.
func (*SQLiteStore) EpisodeListAll ¶
EpisodeListAll returns all episodes from the database
func (*SQLiteStore) ProcessCountByUrlAndStatus ¶
func (*SQLiteStore) ProcessGetByStatus ¶
func (*SQLiteStore) ProcessUpsert ¶
ProcessUpsert creates or updates a process in the database
func (*SQLiteStore) Rollback ¶
func (s *SQLiteStore) Rollback() error
Rollback aborts the transaction.
type Store ¶
type Store interface {
// Close the store and release all resources.
Close()
// Begin starts a new transaction and returns a new Store instance.
Begin(ctx context.Context) (Store, error)
// Commit commits the current transaction.
Commit() error
// Rollback aborts the current transaction.
Rollback() error
// EpisodeCreate creates a new episode record in the store.
EpisodeCreate(ctx context.Context, episode *entities.Episode) error
// EpisodeListAll returns all episodes from the store in descending order by creation date.
EpisodeListAll(ctx context.Context) ([]*entities.Episode, error)
// EpisodeCountAll returns the total count of episodes in the store.
EpisodeCountAll(ctx context.Context) (int, error)
// EpisodeGetByOriginalUrl returns episodes matching the given original URL.
EpisodeGetByOriginalUrl(ctx context.Context, url string) ([]*entities.Episode, error)
// EpisodeGetLastTime returns the creation time of the most recently added episode.
// If no episodes exist, it returns zero time.
EpisodeGetLastTime(ctx context.Context) (time.Time, error)
// ProcessUpsert creates or updates a process record in the store.
ProcessUpsert(ctx context.Context, process *entities.Process) error
// ProcessGetByStatus returns processes matching the given status.
ProcessGetByStatus(ctx context.Context, status entities.Status) ([]*entities.Process, error)
// ProcessCountByUrlAndStatus returns the count of processes matching the given URL and status.
ProcessCountByUrlAndStatus(ctx context.Context, url string, status entities.Status) (int, error)
}
Store defines the interface for a data store that manages episodes and processes.