feed

package
v0.0.0-...-75ded5f Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package feed implements streaming interface to access RSS, Atom, etc. feeds.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func EqualSizeBlocks

func EqualSizeBlocks(size, n int) iter.Seq[Block]

EqualSizeBlocks generates a sequence of blocks of a given size out of n items.

Example
package main

import (
	"fmt"
	"slices"

	"github.com/skhal/lab/x/feed/internal/feed"
)

func main() {
	chunks := slices.Collect(feed.EqualSizeBlocks(3, 7))
	fmt.Println(chunks)
}
Output:

[{0 3} {3 6} {6 7}]

Types

type Block

type Block struct {
	Low  int // start index (inclusive)
	High int // end index (exclusive)
}

Block is a range of indices [Low, High).

type Feed

type Feed <-chan *Item

Feed is a stream of RSS, Atom, etc. feed items.

type Fetcher

type Fetcher interface {
	// Fetch retrieves items from the feed.
	Fetch() ([]*Item, error)
}

Fetcher is responsible for getting items from the feed.

func Fetch

func Fetch(s *pb.Source) (Fetcher, error)

Fetch fetches a feed and generates a stream of items. It returns an error if the feed source is not supported or there is an error in accessing the feed.

type Item

type Item struct {
	Title     string     // Title of the item.
	Updated   *time.Time // When the item was updated.
	Published *time.Time // When the item was published.
}

Item is a feed item, be it RSS, Atom, etc.

type Subscription

type Subscription interface {
	// Feed generates a stream of feed items. It returns an error if it fails to
	// create a stream.
	Feed() (Feed, error)
	// Close stops the subscription and closes the feed.
	Close() error
}

Subscription is a client API to access streamed feed.

func Merge

func Merge(subs []Subscription) Subscription

Merge multiplexes subscriptions into a single subscription.

func Subscribe

func Subscribe(f *pb.Feed) Subscription

Subscribe creates a feed subscription.

Jump to

Keyboard shortcuts

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