data

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2022 License: MIT Imports: 2 Imported by: 0

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.

func Tee

func Tee(consumers ...Consumer) Consumer

Tee splits feed stream between consumers, implementing a fanout pattern.

type ConsumerFunc

type ConsumerFunc func(ctx context.Context, article Article) error

ConsumerFunc is a function-based implementation of Consumer.

func (ConsumerFunc) On

func (c ConsumerFunc) On(ctx context.Context, article Article) error

On method is invoked when an article is received from the feed.

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 Filter

func Filter(feed Feed, predicate Predicate) Feed

Filter applies a predicate to the feed's stream.

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

type MiddlewareFunc func(ctx context.Context, article Article, next NextFunc) error

MiddlewareFunc is a function that implements Middleware interface.

func (MiddlewareFunc) Do

func (mw MiddlewareFunc) Do(ctx context.Context, article Article, next NextFunc) error

Do method executes an action over a stream item.

type NextFunc

type NextFunc func(article Article) error

NextFunc is a "next" function for middlewares.

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

type PredicateFunc func(ctx context.Context, article Article) (bool, error)

PredicateFunc is a function that implements Predicate interface.

func (PredicateFunc) Filter

func (f PredicateFunc) Filter(ctx context.Context, article Article) (bool, error)

Filter returns true if an article passes through the filter, and false otherwise.

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

type TransformationFunc func(ctx context.Context, article *Article) error

TransformationFunc is a function that implements Transformation interface.

func (TransformationFunc) Apply

func (f TransformationFunc) Apply(ctx context.Context, article *Article) error

Apply updates an article according to transformation logic.

Jump to

Keyboard shortcuts

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