events

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2023 License: AGPL-3.0 Imports: 8 Imported by: 2

Documentation

Overview

Package events provides data serialization for Baleen-specific events using message pack - a binary JSON compatible serialization format. Message pack is slightly larger than protocol buffers or other serialization formats but can be simpler to implement.

Index

Constants

View Source
const (
	TypeSubscription = "Subscription"
	TypeFeedSync     = "FeedSync"
	TypeFeedItem     = "FeedItem"
	TypeDocument     = "Document"
)

Types specifies the event types for Ensign

View Source
const (
	VersionSubscription = "1.0.0"
	VersionFeedSync     = "1.0.0"
	VersionFeedItem     = "1.0.0"
	VersionDocument     = "1.0.0"
)

Versions specifies the semantic version for each event type

Variables

This section is empty.

Functions

func Marshal

func Marshal(event TypedEvent, uuid string) (msg *message.Message, err error)

Types

type Document

type Document struct {
	ETag         string    `msg:"etag,omitempty"`
	LastModified string    `msg:"last_modified,omitempty"`
	Active       bool      `msg:"active"`
	StatusCode   int       `msg:"status_code,omitempty"`
	Error        string    `msg:"error,omitempty"`
	FetchedAt    time.Time `msg:"fetched_at"`
	FeedID       string    `msg:"feed_id"`
	Language     string    `msg:"language"`
	Year         int       `msg:"year"`
	Month        string    `msg:"month"`
	Day          int       `msg:"day"`
	Title        string    `msg:"title"`
	Description  string    `msg:"description"`
	Content      []byte    `msg:"content"`
	Encoding     string    `msg:"encoding"`
	Link         string    `msg:"link"`
}

func UnmarshalDocument

func UnmarshalDocument(msg *message.Message) (e *Document, err error)

func (*Document) DecodeMsg

func (z *Document) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*Document) EncodeMsg

func (z *Document) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*Document) MarshalMsg

func (z *Document) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*Document) Msgsize

func (z *Document) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (Document) Type

func (Document) Type() *api.Type

func (*Document) UnmarshalMsg

func (z *Document) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type FeedItem

type FeedItem struct {
	FeedID      string   `msg:"feed_id"`
	Title       string   `msg:"title"`
	Description string   `msg:"description"`
	Content     string   `msg:"content"`
	Link        string   `msg:"link"`
	Updated     string   `msg:"updated"`
	Published   string   `msg:"published"`
	GUID        string   `msg:"guid"`
	Authors     []string `msg:"authors"`
	Image       string   `msg:"image"`
	Categories  []string `msg:"categories"`
	Enclosures  []string `msg:"enclosures"`
}

func UnmarshalFeedItem

func UnmarshalFeedItem(msg *message.Message) (e *FeedItem, err error)

func (*FeedItem) DecodeMsg

func (z *FeedItem) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*FeedItem) EncodeMsg

func (z *FeedItem) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*FeedItem) MarshalMsg

func (z *FeedItem) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*FeedItem) Msgsize

func (z *FeedItem) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (FeedItem) Type

func (FeedItem) Type() *api.Type

func (*FeedItem) UnmarshalMsg

func (z *FeedItem) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type FeedSync

type FeedSync struct {
	FeedID       string    `msg:"feed_id"`
	ETag         string    `msg:"etag"`
	LastModified string    `msg:"last_modified"`
	Active       bool      `msg:"active"`
	StatusCode   int       `msg:"status_code"`
	Error        string    `msg:"error"`
	SyncedAt     time.Time `msg:"synced_at"`
	FeedItems    int64     `msg:"feed_items"`
	Title        string    `msg:"title"`
	Description  string    `msg:"description"`
	Link         string    `msg:"link"`
	Links        []string  `msg:"links"`
	FeedLink     string    `msg:"feed_link"`
	Updated      string    `msg:"updated"`
	Published    string    `msg:"published"`
	Language     string    `msg:"language"`
	Copyright    string    `msg:"copyright"`
	Generator    string    `msg:"generator"`
	Categories   []string  `msg:"categories"`
	FeedType     string    `msg:"feed_type"`
	FeedVersion  string    `msg:"feed_version"`
}

func UnmarshalFeedSync

func UnmarshalFeedSync(msg *message.Message) (e *FeedSync, err error)

func (*FeedSync) DecodeMsg

func (z *FeedSync) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*FeedSync) EncodeMsg

func (z *FeedSync) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*FeedSync) MarshalMsg

func (z *FeedSync) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*FeedSync) Msgsize

func (z *FeedSync) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (FeedSync) Type

func (FeedSync) Type() *api.Type

func (*FeedSync) UnmarshalMsg

func (z *FeedSync) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type Subscription

type Subscription struct {
	FeedID   string `msg:"feed_id,omitempty"` // a unique ID for the feed (optional)
	Title    string `msg:"title"`             // the title of the subscription
	FeedType string `msg:"feed_type"`         // either rss or atom
	FeedURL  string `msg:"feed_url"`          // the url to the feed (xmlURL in OPML)
	SiteURL  string `msg:"site_url"`          // the url to the site (htmlURL in OPML)
}

func UnmarshalSubscription

func UnmarshalSubscription(msg *message.Message) (e *Subscription, err error)

func (*Subscription) DecodeMsg

func (z *Subscription) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*Subscription) EncodeMsg

func (z *Subscription) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*Subscription) MarshalMsg

func (z *Subscription) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*Subscription) Msgsize

func (z *Subscription) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (Subscription) Type

func (Subscription) Type() *api.Type

func (*Subscription) UnmarshalMsg

func (z *Subscription) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type TypedEvent

type TypedEvent interface {
	msgp.Marshaler
	msgp.Unmarshaler
	Type() *api.Type
}

TypedEvents can return their type for Ensign serialization

func Unmarshal

func Unmarshal(msg *message.Message) (_ TypedEvent, err error)

Jump to

Keyboard shortcuts

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