feed

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrIDNotFound = errors.New("feed by id not found")

Functions

This section is empty.

Types

type Config

type Config struct {
	FeedID      string
	Title       string
	Description string
	URL         string
	Matcher     Matcher
}

type Feed

type Feed struct {
	ID          string
	Title       string
	Link        string
	Description string
	Items       []Item
}

type HTTPClient

type HTTPClient interface {
	Get(ctx context.Context, url string) (io.ReadCloser, error)
}

HTTPClient interface for get content by URL.

type Item

type Item struct {
	Title       string
	Link        string
	Description string
	Published   time.Time
}

type Matcher

type Matcher struct {
	Engine      query.Engine
	ItemURL     query.Selector
	Title       query.Selector
	Description query.Selector
	Published   query.SelectorTime
}

func (Matcher) FindItem

func (m Matcher) FindItem(doc *query.Document) (Item, error)

func (Matcher) FindItemURLs

func (m Matcher) FindItemURLs(doc *query.Document) ([]string, error)

type Middleware

type Middleware interface {
	Process(ctx context.Context, feed Feed) (Feed, error)
}

type MiddlewareFunc

type MiddlewareFunc func(ctx context.Context, feed Feed) (Feed, error)

func (MiddlewareFunc) Process

func (f MiddlewareFunc) Process(ctx context.Context, feed Feed) (Feed, error)

type Repository

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

func NewRepository

func NewRepository(configs []Config, client HTTPClient) *Repository

func (*Repository) Get

func (r *Repository) Get(ctx context.Context, feedID string) (Feed, error)

func (*Repository) IDs

func (r *Repository) IDs() []string

type Service

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

func NewService

func NewService(configs []Config, client HTTPClient, middlewares []Middleware) *Service

func (*Service) Get

func (s *Service) Get(ctx context.Context, feedID string) (Feed, error)

func (*Service) IDs

func (s *Service) IDs() []string

Jump to

Keyboard shortcuts

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