aggregator

package
v0.0.0-...-b17c1e0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Aggregator

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

Aggregator orchestrates the creation and running of aggregation jobs

func NewAggregator

func NewAggregator(jobs []Job, delayStarts bool, msgBus *nats.Conn, providerRepo storage.ProviderRepository, articles storage.ArticleRepository) (Aggregator, error)

NewAggregator returns a new instance of Aggregator, which is used for aggregating news providers that implement `aggregator.NewProvider`

func (*Aggregator) Start

func (a *Aggregator) Start() error

Start starts the aggregation jobs

func (*Aggregator) Stop

func (a *Aggregator) Stop()

Stop stops the aggregation jobs

type Job

type Job struct {
	Label string
	// contains filtered or unexported fields
}

Job is a runnable task that will retrieve news articles

func BuildJobs

func BuildJobs(provRepo storage.ProviderRepository, artRepo storage.ArticleRepository) ([]Job, error)

BuildJobs take an instance of `storage.ProviderRepository` and will return a slice of `Job` based on all valid providers that are available

func NewJob

func NewJob(label string, provider NewsProvider, articleRepo storage.ArticleRepository) (Job, error)

NewJob returns a job based on the specified NewsProvider

func (*Job) Start

func (j *Job) Start() error

Start a job

func (*Job) Stop

func (j *Job) Stop()

Stop a job

type NewsProvider

type NewsProvider interface {
	Latest() ([]storage.Article, error)
	PollingFrequency() time.Duration
}

NewsProvider defines functionality to retrieve news articles

Jump to

Keyboard shortcuts

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