messanger

package
v0.0.0-...-aebcd7e Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CreateUser should be used for create requests
	CreateUser = "createUser"
	// DeleteUser should be used for delete requests
	DeleteUser = "deleteUser"
	// UpdateUser should be used for update requests
	UpdateUser = "updateUser"
	// ListUser should be used for list requests
	ListUser = "listUser"
	// ListUserAnswer should be used for list callbacks
	ListUserAnswer = "listUserAnswer"
	// Notification should be used for notifications
	Notification = "notification"
)
View Source
const (
	// ProcessorQueue name
	ProcessorQueue = "processorQueue"
	// CallbackQueue name
	CallbackQueue = "callbackQueue"
	// NotificationQueue name
	NotificationQueue = "notificationQueue"
)

Variables

This section is empty.

Functions

func OpenConnection

func OpenConnection(url string) (*amqp.Connection, error)

OpenConnection opens a rabbitmq connection

Types

type Message

type Message struct {
	Data        []byte
	MessageType string
	CID         string
}

Message holds all data needed by manager and processor to read and send rabbitmq messages

type MessageQueueRead

type MessageQueueRead interface {
	GetMessageFromQueue() (*Message, error)
	GetMessageFromQueueWithCID(cID string) (*Message, error)
}

MessageQueueRead contains all method needed by consumers

type MessageQueueWrite

type MessageQueueWrite interface {
	PostMessageToQueue(message Message) error
}

MessageQueueWrite contains all method needed by producers

type MockMessagingSystem

type MockMessagingSystem struct {
	Received        []Message
	MessageToReturn []Message
	ErrorToReturn   []error
	// contains filtered or unexported fields
}

MockMessagingSystem is just a mock

func (*MockMessagingSystem) GetMessageFromQueue

func (mm *MockMessagingSystem) GetMessageFromQueue() (*Message, error)

GetMessageFromQueue here to implement interface

func (*MockMessagingSystem) GetMessageFromQueueWithCID

func (mm *MockMessagingSystem) GetMessageFromQueueWithCID(_ string) (*Message, error)

GetMessageFromQueueWithCID here to implement interface

func (*MockMessagingSystem) PostMessageToQueue

func (mm *MockMessagingSystem) PostMessageToQueue(message Message) error

PostMessageToQueue here to implement interface

type RabbitMQ

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

RabbitMQ stub implementation of a messaging system, if needed we could have different structs for producers and consumers having different interfaces was considered enough for a stub

func NewRabbitMQ

func NewRabbitMQ(conn *amqp.Connection, queueName string) (*RabbitMQ, error)

NewRabbitMQ setup new RabbitMQ opening connections and creating the queue if needed

func (RabbitMQ) Close

func (mq RabbitMQ) Close() error

Close closes a rabbitmq connection

func (RabbitMQ) GetMessageFromQueue

func (mq RabbitMQ) GetMessageFromQueue() (*Message, error)

GetMessageFromQueue get one message from the queue it could have been implemented returning a channel

func (RabbitMQ) GetMessageFromQueueWithCID

func (mq RabbitMQ) GetMessageFromQueueWithCID(cID string) (*Message, error)

GetMessageFromQueueWithCID get a message from the queue with a specific CID requeueing if needed

func (RabbitMQ) PostMessageToQueue

func (mq RabbitMQ) PostMessageToQueue(message Message) error

PostMessageToQueue post a message to a queue

Jump to

Keyboard shortcuts

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