server

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: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Listen           int
	Secret           string
	Version          string
	CacheTTL         time.Duration
	FeedsCfgFilePath string
}

Config the server configuration.

type FeedsCache

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

FeedsCache - cache for the latest up-to-date feeds.

func NewFeedsCache

func NewFeedsCache(feeds FeedsRepo, ttl time.Duration) *FeedsCache

NewFeedsCache creates FeedsCache. ttl - duration how often will be refresh cache for gets up-to-date feeds.

func (*FeedsCache) Get

func (f *FeedsCache) Get(feedID string) (feed.Feed, error)

func (*FeedsCache) Run

func (f *FeedsCache) Run(ctx context.Context)

Run loads actual feeds to cache and runs background tasks for updates its. When ctx.Done -> all background tasks stopping too.

type FeedsRepo

type FeedsRepo interface {
	Get(ctx context.Context, feedID string) (feed.Feed, error)
	IDs() []string
}

FeedsRepo interface for gets the latest up-to-date feeds.

type Server

type Server struct {
	Config
	// contains filtered or unexported fields
}

Server implement http api for gets RSS/Atom feeds.

func NewServer

func NewServer(cfg Config) (*Server, error)

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Run starts http server and closes on context cancellation.

Jump to

Keyboard shortcuts

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