commandst

package
v0.1.4-alpha Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RCommandPing = PingStatus(0)
	RCommandPong = PingStatus(1)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandMessage

type CommandMessage struct {
	GuildID   string `json:"guild_id"`
	ChannelID string `json:"channel_id"`
	UserID    string `json:"user_id"`
	Username  string `json:"username"`
	Message   string `json:"message"`
}

type CommandsMetrics

type CommandsMetrics interface {
	CommandUsed(command string)
	CommandFailed(command string)
}

type CommandsReceiver

type CommandsReceiver interface {
	ReceiveCommands(command string) (<-chan CommandMessage, error)
	AddHandler(command string, handler ReceiverHandler)
	SetErrorMetrics(metrics CommandsMetrics)
	Start(command string) error
	Close()
}

type CommandsSender

type CommandsSender interface {
	SendCommand(cmd CommandMessage, queue string) error
}

type ErrMetricsFunc

type ErrMetricsFunc func(command string)

type PingMessage

type PingMessage struct {
	Status PingStatus
}

type PingStatus

type PingStatus int

type RabbitCommandsTransport

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

func NewRabbitCommandsTransport

func NewRabbitCommandsTransport(conn *amqp.Connection, logger *zap.Logger) (*RabbitCommandsTransport, error)

func (*RabbitCommandsTransport) AddHandler

func (t *RabbitCommandsTransport) AddHandler(command string, handler ReceiverHandler)

AddHandler add command handler

func (*RabbitCommandsTransport) Close

func (t *RabbitCommandsTransport) Close()

func (*RabbitCommandsTransport) ReceiveCommands

func (t *RabbitCommandsTransport) ReceiveCommands(command string) (<-chan CommandMessage, error)

func (*RabbitCommandsTransport) ReceivePings

func (t *RabbitCommandsTransport) ReceivePings(command string) error

func (*RabbitCommandsTransport) SendCommand

func (t *RabbitCommandsTransport) SendCommand(cmd CommandMessage, queue string) error

func (*RabbitCommandsTransport) SetErrorMetrics

func (t *RabbitCommandsTransport) SetErrorMetrics(metrics CommandsMetrics)

SetErrorMetrics add metrics interface to save metrics commands usage

func (*RabbitCommandsTransport) Start

func (t *RabbitCommandsTransport) Start(command string) error

Start starts handling command requests

type ReceiverHandler

type ReceiverHandler func(m CommandMessage) error

Jump to

Keyboard shortcuts

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