db

package
v0.0.0-...-8dea4bf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CurrentVersion = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Badger

type Badger struct {
	// contains filtered or unexported fields
}

func NewBadger

func NewBadger(config *Config) (*Badger, error)

func (*Badger) AddFeed

func (b *Badger) AddFeed(_ context.Context, feedID string, feed *model.Feed) error

func (*Badger) Close

func (b *Badger) Close() error

func (*Badger) DeleteEpisode

func (b *Badger) DeleteEpisode(feedID, episodeID string) error

func (*Badger) DeleteFeed

func (b *Badger) DeleteFeed(_ context.Context, feedID string) error

func (*Badger) GetEpisode

func (b *Badger) GetEpisode(_ context.Context, feedID string, episodeID string) (*model.Episode, error)

func (*Badger) GetFeed

func (b *Badger) GetFeed(_ context.Context, feedID string) (*model.Feed, error)

func (*Badger) UpdateEpisode

func (b *Badger) UpdateEpisode(feedID string, episodeID string, cb func(episode *model.Episode) error) error

func (*Badger) Version

func (b *Badger) Version() (int, error)

func (*Badger) WalkEpisodes

func (b *Badger) WalkEpisodes(ctx context.Context, feedID string, cb func(episode *model.Episode) error) error

func (*Badger) WalkFeeds

func (b *Badger) WalkFeeds(_ context.Context, cb func(feed *model.Feed) error) error

type BadgerConfig

type BadgerConfig struct {
	Truncate bool `toml:"truncate"`
	FileIO   bool `toml:"file_io"`
}

BadgerConfig represents BadgerDB configuration parameters

type Config

type Config struct {
	// Dir is a directory to keep database files
	Dir    string        `toml:"dir"`
	Badger *BadgerConfig `toml:"badger"`
}

type Storage

type Storage interface {
	Close() error
	Version() (int, error)

	// AddFeed will:
	// - Insert or update feed info
	// - Append new episodes to the existing list of episodes (existing episodes are not overwritten!)
	AddFeed(ctx context.Context, feedID string, feed *model.Feed) error

	// GetFeed gets a feed by ID
	GetFeed(ctx context.Context, feedID string) (*model.Feed, error)

	// WalkFeeds iterates over feeds saved to database
	WalkFeeds(ctx context.Context, cb func(feed *model.Feed) error) error

	// DeleteFeed deletes feed and all related data from database
	DeleteFeed(ctx context.Context, feedID string) error

	// GetEpisode gets episode by identifier
	GetEpisode(ctx context.Context, feedID string, episodeID string) (*model.Episode, error)

	// UpdateEpisode updates episode fields
	UpdateEpisode(feedID string, episodeID string, cb func(episode *model.Episode) error) error

	// DeleteEpisode deletes an episode
	DeleteEpisode(feedID string, episodeID string) error

	// WalkEpisodes iterates over episodes that belong to the given feed ID
	WalkEpisodes(ctx context.Context, feedID string, cb func(episode *model.Episode) error) error
}

type Version

type Version int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL