Documentation
¶
Overview ¶
The feedtr package allows feeds to be fetched and transformed to create outputs. Please refer to the feedtr command line program for example usage.
Index ¶
- func FetchSources(config *Config, cache Cache) []error
- func Process(config *Config, cache Cache, transforms Transforms, outputs Outputs) []error
- type Cache
- type CacheEntry
- type Config
- type FileCache
- type FileCacheEntry
- type FileOutputEntry
- type FileOutputs
- type FileTransforms
- type Output
- type OutputEntry
- type Outputs
- type Transform
- type Transforms
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FetchSources ¶
Fetches all the sources specified by config, storing them in the given cache.
Types ¶
type Cache ¶
type Cache interface {
// Returns a CacheEntry for a given feed source URL. A result will always be
// returned regardless of whether the entry exists.
Entry(url string) CacheEntry
}
A cache used to store fetched feed sources.
type CacheEntry ¶
type CacheEntry interface {
// Writes content from the given Reader to the cache entry. The given
// lastModified time is recorded along with the content.
Write(reader io.Reader, lastModified time.Time) error
// Returns the last modified Time of the entry or nil if nothing has been
// stored for the entry.
LastModified() *time.Time
// Returns the cached content for the cache entry as a byte slice.
Read() ([]byte, error)
}
A entry for a feed source in a Cache.
type Config ¶
type Config struct {
// A list of the outputs to be produced, each specified as an Output.
Outputs []Output
}
Specifies the outputs to produce.
type FileCache ¶
type FileCache struct {
// contains filtered or unexported fields
}
A implementation of the Cache interface using the file system to store entries.
func NewFileCache ¶
Creates and returns a new FileCache to write cache entries to the given path. The directory specified by the path is created if it does not exist.
func (*FileCache) Entry ¶
func (cache *FileCache) Entry(url string) CacheEntry
Returns a CacheEntry for a given feed source URL. A result will always be returned regardless of whether the entry exists.
type FileCacheEntry ¶
type FileCacheEntry struct {
// contains filtered or unexported fields
}
A implementation of the CacheEntry interface referencing a file on the file system.
func (*FileCacheEntry) LastModified ¶
func (entry *FileCacheEntry) LastModified() *time.Time
Returns the last modified Time of the entry or nil if nothing has been stored for the entry.
func (*FileCacheEntry) Read ¶
func (entry *FileCacheEntry) Read() ([]byte, error)
Returns the cached content for the cache entry as a byte slice.
type FileOutputEntry ¶
type FileOutputEntry struct {
// contains filtered or unexported fields
}
An implementation of the OutputEntry interface using the file system for storage.
func (*FileOutputEntry) LastModified ¶
func (entry *FileOutputEntry) LastModified() *time.Time
Returns the last modified time of the output or nil if the entry has not yet been written.
func (*FileOutputEntry) Save ¶
func (entry *FileOutputEntry) Save(content []byte) error
Stores the given content.
type FileOutputs ¶
type FileOutputs struct {
// contains filtered or unexported fields
}
An implementation of the Outputs interface using the file system for storage.
func NewFileOutputs ¶
func NewFileOutputs(path string) (*FileOutputs, error)
Returns a new FileOutputs instance to write outputs to the given path. The directory referenced by the path is created if it does not exist.
func (*FileOutputs) Entry ¶
func (outputs *FileOutputs) Entry(output Output) OutputEntry
Returns an entry for an individual configured transformed feed output.
type FileTransforms ¶
type FileTransforms struct {
// contains filtered or unexported fields
}
An implementation of the Transforms instance using the file system to store transformation files.
func NewFileTransforms ¶
func NewFileTransforms(path string) *FileTransforms
Creates an instance of FileTransforms, to load transformation files from the given path.
type Output ¶
type Output struct {
// Name of the output to be written (typically a file name).
Name string
// URL of the source feed to be fetched an transformed.
Source string
// List of transforms to be applied to the feed (i.e. file names of the
// transform files).
Transforms []string
}
An configured output to produce.
type OutputEntry ¶
type OutputEntry interface {
// Stores the given content.
Save(content []byte) error
// Returns the last modified time of the output or nil if the entry has not
// yet been written.
LastModified() *time.Time
}
An entry for a transformed feed output.
type Outputs ¶
type Outputs interface {
// Returns an entry for an individual configured transformed feed output.
Entry(output Output) OutputEntry
}
The output location for transformed feeds.
type Transform ¶
type Transform interface {
// Runs the transformation on the given input, returning an output as a byte
// slice.
Process(input []byte) ([]byte, error)
// Closes the Transform. Must be called after the instance is no longer
// needed.
Close()
}
A transformation that can be run on a feed.
type Transforms ¶
A source that can be used to obtain Transform instances.