backend

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2023 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultCacheDuration = 24 * time.Hour

DefaultCacheDuration is the default duration for which an item is cached

View Source
var DefaultCacheSize = 100

DefaultCacheSize is the default size of the cache

Functions

func DeleteItem

func DeleteItem(itemType ItemType, key string) tea.Cmd

DeleteItem is a function to tell the main model that a new item needs to be removed from the list

func NewItem

func NewItem(itemType ItemType, newItem bool, itemPath []string, oldFields []string) tea.Cmd

NewItem is a function to tell the main model that a new item needs to be added to the list

Types

type Backend

type Backend struct {
	Cache *Cache
	Rss   *rss.Rss
}

The Backend uses a local cache to get all the feeds and their articles

func New

func New(urlPath, cachePath string, resetCache bool) (Backend, error)

New creates a new Cache Backend

func (Backend) Close

func (b Backend) Close() error

Close closes the backend

func (Backend) FetchArticles

func (b Backend) FetchArticles(feedName string) tea.Cmd

FetchArticles returns a tea.Cmd which gets the articles from the backend via a string key

func (Backend) FetchCategories

func (b Backend) FetchCategories() tea.Cmd

FetchCategories returns a tea.Cmd which gets the category list fron the backend

func (Backend) FetchFeeds

func (b Backend) FetchFeeds(catName string) tea.Cmd

FetchFeeds returns a tea.Cmd which gets the feed list from the backend via a string key

type Cache

type Cache struct {
	Content map[string]Item
	// contains filtered or unexported fields
}

Cache is a basic cache to read and write gofeed.Items based on the URL

func (*Cache) GetAllArticles added in v1.0.1

func (c *Cache) GetAllArticles(urls []string) ([]gofeed.Item, error)

GetAllArticles reutrns an article list from the cache or fetches it from the internet if it is not cached and updates the cache, it also updates expired items and sorts the items by publish date

func (*Cache) GetArticle

func (c *Cache) GetArticle(url string) ([]gofeed.Item, error)

GetArticle returns an article list from the cache or fetches it from the internet if it is not cached and updates the cache, it also updates expired items

func (*Cache) Load

func (c *Cache) Load() error

Load reads the cache from disk

func (*Cache) Save

func (c *Cache) Save() error

Save writes the cache to disk

type DeleteItemMessage

type DeleteItemMessage struct {
	Type ItemType
	Key  string
}

DeleteItemMessage is a message to tell the main model that a new item needs to be removed from the list

type FetchErrorMessage

type FetchErrorMessage struct {
	Description string
	Err         error
}

FetchErrorMessage is a message that is sent when the fetching of the categories or feeds failed

type FetchSuccessMessage

type FetchSuccessMessage struct {
	Items []list.Item
}

FetchSuccessMessage is a message that is sent when the fetching of the categories or feeds was successful

type Item

type Item struct {
	Expire time.Time
	Items  []gofeed.Item
}

Item is an item in the cache

type ItemType

type ItemType int

ItemType is the type of the added item

const (
	Category ItemType = iota
	Feed
)

type NewItemMessage

type NewItemMessage struct {
	Type      ItemType
	New       bool
	Fields    []string
	ItemPath  []string
	OldFields []string
}

NewItemMessage is a message to tell the main model that a new item needs to be added to the list

Jump to

Keyboard shortcuts

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