poller

package
v0.0.0-...-5d88ada Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const NewsPublishedDateLayout = "2006-01-02 15:04:05"

NewsPublishedDateLayout is the layout for date time in gathered news remember that layout needs to be pointing to Jan 2, 2006 at 3:04pm (MST) in expected format

Variables

This section is empty.

Functions

func GetArticleFromNewsElement

func GetArticleFromNewsElement(n NewsElement, teamId string, hasDetails bool) (types.Article, error)

GetArticleFromNewsElement creates Article from NewsElement taken as a value so that it can create pointers to its fields

func PollNewsDetailsIntoStorage

func PollNewsDetailsIntoStorage(ctx context.Context, config DetailsConfig, logger logr.Logger, s storage.ArticleStorage)

func PollNewsDetailsIntoStorageOfGivenID

func PollNewsDetailsIntoStorageOfGivenID(ctx context.Context, config DetailsConfig, logger logr.Logger, s storage.ArticleStorage, newsId string) error

func PollNewsListIntoStorage

func PollNewsListIntoStorage(ctx context.Context, config ListConfig, logger logr.Logger, s storage.ArticleStorage)

func StartPollerWithConfigFile

func StartPollerWithConfigFile(
	ctx context.Context,
	v *viper.Viper,
	logger logr.Logger,
	s storage.ArticleStorage,
) error

StartPollerWithConfigFile starts cron jobs based on config file. The jobs then queries news provider for list of new news and their details

Types

type Config

type Config struct {
	TeamId        string `mapstructure:"teamId"`
	RunOnceAtBoot bool   `mapstructure:"runOnceAtBoot"`
	List          struct {
		URL      string `mapstructure:"url"`
		Count    int    `mapstructure:"count"`
		Schedule string `mapstructure:"schedule"`
	} `mapstructure:"list"`
	Details struct {
		URL      string `mapstructure:"url"`
		Schedule string `mapstructure:"schedule"`
	} `mapstructure:"details"`
}

func (Config) GetDetailsSchedule

func (c Config) GetDetailsSchedule() string

func (Config) GetDetailsURL

func (c Config) GetDetailsURL() string

func (Config) GetListCount

func (c Config) GetListCount() int

func (Config) GetListSchedule

func (c Config) GetListSchedule() string

func (Config) GetListURL

func (c Config) GetListURL() string

func (Config) GetTeamId

func (c Config) GetTeamId() string

type DetailsConfig

type DetailsConfig interface {
	GetDetailsURL() string
	GetDetailsSchedule() string
	GetTeamId() string
}

type ListConfig

type ListConfig interface {
	GetListURL() string
	GetListCount() int
	GetListSchedule() string
	GetTeamId() string
}

type NewsDetailed

type NewsDetailed struct {
	XMLName        xml.Name    `xml:"NewsArticleInformation"`
	Text           string      `xml:",chardata"`
	ClubName       string      `xml:"ClubName"`       // Hull City
	ClubWebsiteURL string      `xml:"ClubWebsiteURL"` // https://www.wearehullcity...
	NewsArticle    NewsElement `xml:"NewsArticle"`
}

NewsDetailed is struct for getting detailed single news from feed.

It was generated with the help of:

go install github.com/miku/zek/cmd/zek@latest
cat examples/hullcityDetailed.xml | zek -e

The inner news element was refactored into separate struct NewsElement.

type NewsElement

type NewsElement struct {
	Text              string `xml:",chardata"`
	ArticleURL        string `xml:"ArticleURL"`        // https://www.wearehullcity...
	NewsArticleID     string `xml:"NewsArticleID"`     // 444541, 444515, 444506, 4...
	PublishDate       string `xml:"PublishDate"`       // 2023-03-04 18:58:00, 2023...
	Taxonomies        string `xml:"Taxonomies"`        // Academy, Academy, Intervi...
	TeaserText        string `xml:"TeaserText"`        // Midfielder Sincere Hall w...
	ThumbnailImageURL string `xml:"ThumbnailImageURL"` // https://www.wearehullcity...
	Title             string `xml:"Title"`             // Hall: ‘Really happy wit...
	OptaMatchId       string `xml:"OptaMatchId"`       // g2322054, g2322054, g2300...
	LastUpdateDate    string `xml:"LastUpdateDate"`    // 2023-03-05 02:00:11, 2023...
	IsPublished       string `xml:"IsPublished"`       // True, True, True, True, T...
	Subtitle          string `xml:"Subtitle"`
	BodyText          string `xml:"BodyText"` // <p class="x_MsoNormal">Be...
	GalleryImageURLs  string `xml:"GalleryImageURLs"`
	VideoURL          string `xml:"VideoURL"`
}

NewsElement is inner element merged from NewsList inner element and NewsDetailed inner element.

type NewsList

type NewsList struct {
	XMLName             xml.Name `xml:"NewListInformation"`
	Text                string   `xml:",chardata"`
	ClubName            string   `xml:"ClubName"`       // Hull City
	ClubWebsiteURL      string   `xml:"ClubWebsiteURL"` // https://www.wearehullcity...
	NewsletterNewsItems struct {
		Text               string        `xml:",chardata"`
		NewsletterNewsItem []NewsElement `xml:"NewsletterNewsItem"`
	} `xml:"NewsletterNewsItems"`
}

NewsList is struct for getting news from feed.

It was generated with the help of:

go install github.com/miku/zek/cmd/zek@latest
cat examples/hullcityList.xml | zek -e

The inner news element was refactored into separate struct NewsElement.

Jump to

Keyboard shortcuts

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