rabbitmq

package
v0.0.0-...-e8a3033 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDisconnected the message error for disconnection
	ErrDisconnected = errors.New("disconnected from rabbitmq, trying to reconnect")
)

Functions

This section is empty.

Types

type AMQPClient

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

AMQPClient holds necessery information for rabbitMQ

func NewAMQPClient

func NewAMQPClient(listenQueue, pushQueue, addr string, l zerolog.Logger, done chan bool, messages chan []byte, isReal bool) *AMQPClient

NewAMQPClient is a constructor that takes address, push and listen queue names, logger, and a amqpChannel that will notify rabbitmq client on server shutdown. We calculate the number of threads, create the client, and start the connection process. Connect method connects to the rabbitmq server and creates push/listen channels if they don't exist.

func (*AMQPClient) Close

func (c *AMQPClient) Close() error

Close is used to destroy all tcp connection to rabbitmq.

func (*AMQPClient) Push

func (c *AMQPClient) Push(data []byte) error

Push will push data onto the queue, and wait for a confirmation. If no confirms are received until within the resendTimeout, it continuously resends messages until a confirmation is received. This will block until the server sends a confirm.

func (*AMQPClient) Stream

func (c *AMQPClient) Stream(cancelCtx context.Context) error

Stream is used to listen on queue and parse the messages.

func (*AMQPClient) UnsafePush

func (c *AMQPClient) UnsafePush(data []byte) error

UnsafePush will push to the queue without checking for confirmation. It returns an error if it fails to connect. No guarantees are provided for whether the server will receive the message.

type Task

type Task struct {
	ID          libUuid.UUID `json:"id"`
	Description string       `json:"description"`
	Tags        []string     `json:"tags"`
	Status      string       `json:"status"`
	Progress    float32      `json:"progress"`
}

Task is a task info description.

func CreateNewTask

func CreateNewTask(tags []string, description string) Task

CreateNewTask is used to create a new Task into bytes.

type TaskClient

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

TaskClient is a Task manager.

func NewTaskManagerClient

func NewTaskManagerClient(client *AMQPClient) *TaskClient

NewTaskManagerClient is used to create the Task manager client.

func (*TaskClient) CompleteTask

func (c *TaskClient) CompleteTask(task Task) error

CompleteTask is to update task status as completed.

func (*TaskClient) FailTask

func (c *TaskClient) FailTask(task Task) error

FailTask is to update task status as failed.

func (*TaskClient) PushTask

func (c *TaskClient) PushTask(task Task) error

PushTask is used to push a taks into pushQueue.

Jump to

Keyboard shortcuts

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