messenger

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FeedItem

type FeedItem struct {
	Description string
	FeedName    string
	FeedTitle   string
	FeedURL     string
	IconURL     string
	ImageURL    string
	IsUpdated   bool
	ItemURL     string
	Published   time.Time
	Title       string
}

FeedItem represents a feed item to be posted to a webhook

func NewFeedItem

func NewFeedItem(feedName string, feed *gofeed.Feed, item *gofeed.Item, isUpdated bool) FeedItem

func (FeedItem) ToDiscordMessage

func (fi FeedItem) ToDiscordMessage(brandingDisabled bool) (dhooks.Message, error)

ToDiscordMessage generates a DiscordMessage from a FeedItem.

type Message

type Message struct {
	Attempt   int
	Item      FeedItem
	Timestamp time.Time
}

Message represents a wrapper around a feed item with additional header information for queue processing.

type Messenger

type Messenger struct {
	// contains filtered or unexported fields
}

A Messenger handles posting messages to a webhook. Failed messages are automatically retried and rate limits are respected. Unsent messages are queued and will be picked up again after a process restart.

func NewMessenger

func NewMessenger(client *dhooks.Client, queue *pqueue.PQueue, name, url string, st *storage.Storage, cfg config.Config) *Messenger

NewMessenger returns a new Messenger.

func (*Messenger) AddMessage

func (wh *Messenger) AddMessage(feedName string, feed *gofeed.Feed, item *gofeed.Item, isUpdated bool) error

AddMessage adds a new message for being send to to webhook

func (*Messenger) Name

func (mg *Messenger) Name() string

func (*Messenger) Shutdown added in v0.3.0

func (mg *Messenger) Shutdown() bool

Shutdown conducts a graceful shutdown of a messenger and frees it's resources. Reports wether a shutdown was actually conducted.

func (*Messenger) Start

func (mg *Messenger) Start() error

Start starts the service.

func (*Messenger) Status

func (mg *Messenger) Status() Status

type Status

type Status struct {
	QueueSize  int
	ErrorCount int
}

Jump to

Keyboard shortcuts

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