Documentation ¶
Overview ¶
Package pubsubhubbub implements PubSubHubbub, as defined in http://pubsubhubbub.github.io/PubSubHubbub/pubsubhubbub-core-0.4.html.
Index ¶
- Constants
- Variables
- type Backend
- type DeniedError
- type Event
- type HTTPError
- type Publisher
- func (p *Publisher) Register(topicURL, callbackURL, secret string, leaseEnd time.Time) error
- func (p *Publisher) ServeHTTP(resp http.ResponseWriter, req *http.Request)
- func (p *Publisher) Subscribe(topicURL, callbackURL, secret string, lease time.Duration) error
- func (p *Publisher) Unsubscribe(topicURL, callbackURL string) error
- type ReadEventFunc
- type Subscriber
Constants ¶
const ( // RelHub is the hub relation. RelHub = "hub" // RelUpdatesFrom is the updates-from relation. RelUpdatesFrom = "http://schemas.google.com/g/2010#updates-from" )
Variables ¶
var DefaultLease = 24 * time.Hour
DefaultLease is the default duration of a lease, if none is provided by the subscriber.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface { // Subscribe sends content notifications about a topic to notifies in a new // goroutine. The notifies channel should only be closed after a call to // Unsubscribe. If the subscription is not possible, it should return a // DeniedError. Subscribe(topic string, notifies chan<- Event) error // Unsubscribe closes notifies. The notifies channel must have been provided // to Subscribe. Unsubscribe(notifies chan<- Event) error }
A Backend is used to build a publisher.
type DeniedError ¶
type DeniedError string
A DeniedError is returned when a publisher forbids subscription to a feed. Its value is the reason.
type Event ¶
type Event interface { // MediaType returns the event's media type. MediaType() string // Topic returns the event's topic URL. Topic() string // WriteTo writes the event's body to w. WriteTo(w io.Writer) error }
An Event is a notification sent by a publisher and received by a subscriber.
type HTTPError ¶
type HTTPError int
An HTTPError is an HTTP error. Its value is the HTTP status code.
type Publisher ¶
type Publisher struct { // SubscriptionState specifies an optional callback function that is called // when a subscription changes state. leaseEnd is zero if the subscription // ends. SubscriptionState func(topicURL, callbackURL, secret string, leaseEnd time.Time) // contains filtered or unexported fields }
A Publisher distributes content notifications.
func (*Publisher) Register ¶
Register registers an existing subscription. It can be used to restore subscriptions when restarting the server.
func (*Publisher) ServeHTTP ¶
func (p *Publisher) ServeHTTP(resp http.ResponseWriter, req *http.Request)
ServeHTTP implements http.Handler.
func (*Publisher) Unsubscribe ¶
Unsubscribe processes an unsubscribe request.
type ReadEventFunc ¶
ReadEventFunc reads an event.
type Subscriber ¶
type Subscriber struct {
// contains filtered or unexported fields
}
A Subscriber subscribes to publishers.
func NewSubscriber ¶
func NewSubscriber(callbackURL string, readEvent ReadEventFunc) *Subscriber
NewSubscriber creates a new subscriber.
func (*Subscriber) ServeHTTP ¶
func (s *Subscriber) ServeHTTP(resp http.ResponseWriter, req *http.Request)
ServeHTTP implements http.Handler.
func (*Subscriber) Subscribe ¶
func (s *Subscriber) Subscribe(hub, topic string, notifies chan<- Event) error
Subscribe subscribes to a topic on a hub. Notifications are sent to notifies.
func (*Subscriber) Unsubscribe ¶
func (s *Subscriber) Unsubscribe(hub, topic string) error
Unsubscribe unsubscribes from a topic on a hub.