Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Article ¶
type Article struct { ID string // ID of article. Title string // Title of article. Time time.Time // An article's publication time. Description string // An article's description text. LinkURL string // A hyperlink to article's web page. ImageURL *string // A hyperlink to article's title image if available. Author string // Article's author name. Tags []string // List of article's tags. }
Article is a single item of a feed.
type Consumer ¶
type Consumer interface { // On method is invoked when an article is received from the feed. On(ctx context.Context, article Article) error }
Consumer consumes feed items.
type ConsumerFunc ¶
ConsumerFunc is a function-based implementation of Consumer.
type Feed ¶
type Feed interface { // Read method reads feed items and streams them into the consumer. Read(ctx context.Context, consumer Consumer) error }
Feed reads article list from remote source.
func Transform ¶
func Transform(feed Feed, transformation Transformation) Feed
Transform applies a function to the feed's stream.
func Wrap ¶
func Wrap(feed Feed, middleware Middleware) Feed
Wrap applies wraps stream into a middleware.
type Middleware ¶
type Middleware interface { // Do method executes an action over a stream item. Do(ctx context.Context, article Article, next NextFunc) error }
Middleware allows to hook into stream processing pipeline.
type MiddlewareFunc ¶
MiddlewareFunc is a function that implements Middleware interface.
type Predicate ¶
type Predicate interface { // Filter returns true if an article passes through the filter, and false otherwise. Filter(ctx context.Context, article Article) (bool, error) }
Predicate is a predicate interface for feed stream's filtering.
type PredicateFunc ¶
PredicateFunc is a function that implements Predicate interface.
type Transformation ¶
type Transformation interface { // Apply updates an article according to transformation logic. Apply(ctx context.Context, article *Article) error }
Transformation defines a feed item's transformation.
type TransformationFunc ¶
TransformationFunc is a function that implements Transformation interface.