Documentation ¶
Index ¶
- Constants
- Variables
- func MarshalNotificationsJSON(n []Notification) ([]byte, error)
- type Dispatcher
- type History
- type MonitorSubscriber
- func (m *MonitorSubscriber) Address() string
- func (m *MonitorSubscriber) ID() string
- func (m *MonitorSubscriber) MarshalJSON() ([]byte, error)
- func (m *MonitorSubscriber) Notifications() <-chan string
- func (m *MonitorSubscriber) Send(n Notification) error
- func (m *MonitorSubscriber) Since() time.Time
- func (m *MonitorSubscriber) SubType() string
- type Notification
- type NotificationConsumer
- type StandardSubscriber
- func (s *StandardSubscriber) Address() string
- func (s *StandardSubscriber) ID() string
- func (s *StandardSubscriber) MarshalJSON() ([]byte, error)
- func (s *StandardSubscriber) Notifications() <-chan string
- func (s *StandardSubscriber) Send(n Notification) error
- func (s *StandardSubscriber) Since() time.Time
- func (s *StandardSubscriber) SubType() string
- type Standout
- type Subscriber
- type SubscriberPayload
Constants ¶
const ( AnnotationsType = "Annotations" ArticleContentType = "Article" ContentPackageType = "ContentPackage" AudioContentType = "Audio" AllContentType = "All" )
subscription types
const ( ContentUpdateType = "http://www.ft.com/thing/ThingChangeType/UPDATE" ContentDeleteType = "http://www.ft.com/thing/ThingChangeType/DELETE" AnnotationUpdateType = "http://www.ft.com/thing/ThingChangeType/ANNOTATIONS_UPDATE" )
notification types
const (
RFC3339Millis = "2006-01-02T15:04:05.000Z07:00"
)
Variables ¶
var ErrSubLagging = errors.New("subscriber lagging behind")
Functions ¶
func MarshalNotificationsJSON ¶
func MarshalNotificationsJSON(n []Notification) ([]byte, error)
MarshalNotificationsJSON returns the JSON encoding of n. For notifications, we do not use the standard function json.Marshal() because that will always escape special characters (<,>,&) in unicode format ("\u0026P" and similar)
Types ¶
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
func NewDispatcher ¶
func NewDispatcher(delay time.Duration, history History, log *logger.UPPLogger) *Dispatcher
NewDispatcher creates and returns a new Dispatcher Delay argument configures minimum delay between send notifications History is a system that collects a list of all notifications send by Dispatcher
func (*Dispatcher) Send ¶
func (d *Dispatcher) Send(n Notification)
func (*Dispatcher) Start ¶
func (d *Dispatcher) Start()
func (*Dispatcher) Stop ¶
func (d *Dispatcher) Stop()
func (*Dispatcher) Subscribe ¶ added in v4.2.1
func (d *Dispatcher) Subscribe(address string, subType string, monitoring bool) Subscriber
func (*Dispatcher) Subscribers ¶
func (d *Dispatcher) Subscribers() []Subscriber
func (*Dispatcher) Unsubscribe ¶ added in v4.2.1
func (d *Dispatcher) Unsubscribe(subscriber Subscriber)
type History ¶
type History interface { Push(notification Notification) Notifications() []Notification }
History contains the last x notifications pushed out to subscribers.
type MonitorSubscriber ¶ added in v4.2.1
type MonitorSubscriber struct {
// contains filtered or unexported fields
}
monitorSubscriber implements a Monitor subscriber
func NewMonitorSubscriber ¶
func NewMonitorSubscriber(address string, subType string) *MonitorSubscriber
NewMonitorSubscriber returns a new instance of a Monitor subscriber
func (*MonitorSubscriber) Address ¶ added in v4.2.1
func (m *MonitorSubscriber) Address() string
func (*MonitorSubscriber) ID ¶ added in v4.2.1
func (m *MonitorSubscriber) ID() string
func (*MonitorSubscriber) MarshalJSON ¶ added in v4.2.1
func (m *MonitorSubscriber) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON representation of a MonitorSubscriber
func (*MonitorSubscriber) Notifications ¶ added in v4.2.1
func (m *MonitorSubscriber) Notifications() <-chan string
func (*MonitorSubscriber) Send ¶ added in v4.2.1
func (m *MonitorSubscriber) Send(n Notification) error
func (*MonitorSubscriber) Since ¶ added in v4.2.1
func (m *MonitorSubscriber) Since() time.Time
func (*MonitorSubscriber) SubType ¶ added in v4.2.1
func (m *MonitorSubscriber) SubType() string
type Notification ¶
type Notification struct { APIURL string `json:"apiUrl"` ID string `json:"id"` Type string `json:"type"` SubscriberID string `json:"subscriberId,omitempty"` PublishReference string `json:"publishReference,omitempty"` LastModified string `json:"lastModified,omitempty"` NotificationDate string `json:"notificationDate,omitempty"` Title string `json:"title,omitempty"` Standout *Standout `json:"standout,omitempty"` SubscriptionType string `json:"-"` }
Notification model
type NotificationConsumer ¶ added in v4.2.1
type NotificationConsumer interface { Subscriber Send(n Notification) error }
type StandardSubscriber ¶ added in v4.2.1
type StandardSubscriber struct {
// contains filtered or unexported fields
}
StandardSubscriber implements a standard subscriber
func NewStandardSubscriber ¶
func NewStandardSubscriber(address string, subType string) *StandardSubscriber
NewStandardSubscriber returns a new instance of a standard subscriber
func (*StandardSubscriber) Address ¶ added in v4.2.1
func (s *StandardSubscriber) Address() string
Address returns the IP address of the standard subscriber
func (*StandardSubscriber) ID ¶ added in v4.2.1
func (s *StandardSubscriber) ID() string
Id returns the uniquely generated subscriber identifier Returned value is assigned during the construction phase.
func (*StandardSubscriber) MarshalJSON ¶ added in v4.2.1
func (s *StandardSubscriber) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON representation of a StandardSubscriber
func (*StandardSubscriber) Notifications ¶ added in v4.2.1
func (s *StandardSubscriber) Notifications() <-chan string
Notifications returns the channel that can provides serialized notifications send to the subscriber
func (*StandardSubscriber) Send ¶ added in v4.2.1
func (s *StandardSubscriber) Send(n Notification) error
Send tries to send notification to the subscriber. It removes the monitoring fields from the notification. Serializes it as string and pushes it to the subscriber
func (*StandardSubscriber) Since ¶ added in v4.2.1
func (s *StandardSubscriber) Since() time.Time
Since returns the time since a subscriber have been registered
func (*StandardSubscriber) SubType ¶ added in v4.2.1
func (s *StandardSubscriber) SubType() string
SubType returns the accepted subscription type for which notifications are returned
type Standout ¶
type Standout struct {
Scoop bool `json:"scoop"`
}
Standout model for a Notification