mqueue

package
v1.24.19 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2021 License: MIT Imports: 19 Imported by: 0

README

Simple message queue based on postgres, this is for more realiably sending messages with retry on failure, accepting long failture durations such as discord being down.

Documentation

Index

Constants

View Source
const DBSchema = `` /* 266-byte string literal not displayed */

Variables

This section is empty.

Functions

func QueueMessage

func QueueMessage(elem *QueuedElement)

QueueMessage queues a message in the message queue

func RegisterPlugin

func RegisterPlugin()

RegisterPlugin registers the mqueue plugin into the plugin system and also initializes it

func RegisterSource

func RegisterSource(name string, source PluginWithSourceDisabler)

RegisterSource registers a mqueue source, used for error handling

Types

type Plugin

type Plugin struct {
}

Plugin represents the mqueue plugin

func (*Plugin) BotInit added in v1.24.19

func (p *Plugin) BotInit()

func (*Plugin) LateBotInit

func (p *Plugin) LateBotInit()

LateBotInit implements bot.LateBotInitHandler

func (*Plugin) PluginInfo

func (p *Plugin) PluginInfo() *common.PluginInfo

PluginInfo implements common.Plugin

func (*Plugin) StopBot

func (p *Plugin) StopBot(wg *sync.WaitGroup)

StopBot implements bot.BotStopperHandler

type PluginWithSourceDisabler added in v1.24.19

type PluginWithSourceDisabler interface {
	DisableFeed(elem *QueuedElement, err error)
}

PluginWithSourceDisabler todo

type PluginWithWebhookAvatar

type PluginWithWebhookAvatar interface {
	WebhookAvatar() string
}

PluginWithWebhookAvatar can be implemented by plugins for custom avatars

type QueuedElement

type QueuedElement struct {
	// The channel to send the message in
	Channel int64
	Guild   int64

	ID int64

	// Where this feed originated from, responsible for handling discord specific errors
	Source string
	// Could be stuff like reddit feed element id, youtube feed element id and so on
	SourceID string

	// The actual message as a simple string
	// specify only one of MessageStr or MessageEmbed
	MessageStr string `json:",omitempty"`

	// The actual message as an embed
	// specify only one of MessageStr or MessageEmbed
	MessageEmbed *discordgo.MessageEmbed `json:",omitempty"`

	UseWebhook      bool
	WebhookUsername string

	AllowedMentions discordgo.AllowedMentions `json:"allowed_mentions"`

	// When the queue grows, the feeds with the highest priority gets sent first
	Priority int
}

QueuedElement represents a queued message

Jump to

Keyboard shortcuts

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