plethora

package module
v0.0.0-...-c0ec25b Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2014 License: BSD-3-Clause Imports: 6 Imported by: 0

README

Experiment to be a single view on consumable media

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Identifier

func Identifier(d Data) identifier

Identifier returns an identifier unique to this Data, this is different from Data.Identifier in that the former is only unique to the provider associated with the Data. The identifier returned by Identifier is unique in the whole system.

func RegisterProvider

func RegisterProvider(name string, provider DataProvider)

RegisterProvider registers a DataProvider with the given name.

A DataProvider can be registered under multiple names

Note: changing the name of a data provider after any data has entered the system will result in data becoming unreachable. Therefore if you want to change the name of your data provider you should register a backwards-compatible version under the old name to be used with the existing data.

func StoreData

func StoreData(d Data, sourceTime time.Time) error

StoreData is equal to StoreIdentifier but removes a few steps.

func StoreIdentifier

func StoreIdentifier(id identifier, sourceTime time.Time) error

StoreIdentifier stores the identifier, it should point to valid data. The sourceTime is the time this data was created at the data source (e.g news article posting date/time).

Types

type Data

type Data interface {
	// Type returns the type of data this is
	Type() DataType
	// Provider returns the DataProvider of this data
	Provider() DataProvider
	// Identifier is called to get an unique identifier to this
	// data. The identifier only has to be unique to the
	// DataProvider returned by Provider.
	Identifier() string
	// Render should write a html representation of the data to
	// the writer given.
	Render(w io.Writer) error
}

Data is the interface used to support arbitrary kinds of data in plethora. All data types need to support the interface to be able to register with plethora.

type DataProvider

type DataProvider func(identifier string) (Data, error)

DataProvider returns the Data associated with the identifier passed.

type DataType

type DataType string

DataType is a kind of data

Each DataType is backed by a DataProvider that stores data in a place the provider sees fit. It is possible for multiple providers to exist for a single DataType.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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