protocol

package
v0.0.0-...-1ee0b1c Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Amqp

type Amqp struct{}

Amqp is a struct representing all data that could be necessary to properly connect to a broker using the AMQP protocol.

type ConnectionError

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

ConnectionError is a custom error used to give more information about errors returned during a connection to the broker.

func (*ConnectionError) Error

func (c *ConnectionError) Error() string

Error returns the information related to the issue.

func (*ConnectionError) GetProtocol

func (c *ConnectionError) GetProtocol() Protocol

GetProtocol returns the Protocol used by the Sender when the error occurred.

type LogLevel

type LogLevel int

LogLevel is a type representing the level of log wanted.

const (
	Critical LogLevel = iota
	Error
	Warning
	Debug
)

type Message

type Message struct {
	Filename string
	Content  string
}

Message is the representation of a message to send. It composed of the filename and its content.

type Mqtt

type Mqtt struct {
	QoS                     uint8
	Retained                bool
	TimeBeforeDisconnection uint
}

Mqtt is a struct representing all data that could be necessary to properly connect to a broker using the MQTT protocol.

type Options

type Options struct {
	BrokerUrl string
	ClientId  string
	Username  string
	Password  string
	Topic     string
	Protocol
	Mqtt
	Amqp
	Stomp
}

Options gathers all data used by the Sender to be correctly built. As the same Options struct can be used to build multiple Sender, it is composed with all protocol related structs.

func (*Options) GetLogOutput

func (o *Options) GetLogOutput(lvl LogLevel) *os.File

GetLogOutput gives the kind of os.File to use to write logs.

func (*Options) MustBeValid

func (o *Options) MustBeValid()

MustBeValid checks if all data passing through the Options' struct are valid regarding the defined Protocol. This function panic if the options are not valid.

type Protocol

type Protocol string

Protocol is a type representing the protocol which will be used

const (
	MQTT  Protocol = "MQTT"
	AMQP  Protocol = "AMQP"
	STOMP Protocol = "STOMP"
)

type Sender

type Sender interface {
	// Connect is used to establish a connection between Foxy and the broker.
	// If anything happens during the connection resulting in error, this error is automatically returned.
	Connect() error

	// Send is used to send one or multiple files' content to the broker.
	// If all messages are sent without any issue, the returned value will be nil. Otherwise, the slice of errors
	// will be filled with all
	Send(msg []Message) []error

	// Disconnect is a method allowing the disconnection from the broker to avoid pending connection.
	Disconnect()
}

Sender defines the methods needed by any protocol to be considered as valid by Foxy.

func NewAmqp

func NewAmqp(opt *Options) (Sender, error)

NewAmqp used the given Options to create a new Sender configured with AMQP protocol.

func NewMqtt

func NewMqtt(opt *Options) (Sender, error)

NewMqtt used the given Options to create a new Sender configured with MQTT protocol.

func NewSender

func NewSender(opt *Options) (Sender, error)

NewSender creates a new Sender configured to be able to connect to the defined broker using the defined protocol.

func NewStomp

func NewStomp(opt *Options) (Sender, error)

NewStomp used the given Options to create a new Sender configured with STOMP protocol.

type SendingError

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

SendingError is a custom error used to give more information about errors returned during sending message to the broker.

func (*SendingError) Error

func (s *SendingError) Error() string

Error returns the information related to the issue.

func (*SendingError) GetFileName

func (s *SendingError) GetFileName() string

GetFileName returns the file's name used from which the content was being extracted.

type Stomp

type Stomp struct{}

Stomp is a struct representing all data that could be necessary to properly connect to a broker using the STOMP protocol.

Jump to

Keyboard shortcuts

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