messages

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2022 License: CC0-1.0 Imports: 8 Imported by: 0

Documentation

Overview

Package messages sends jobs to a message queue. DEPRECATED.

It provides a Repository interface for generalized interactions storing and retrieving messages from a message queue, as well as a concrete type that implements that interface for RabbitMQ.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FullTextPredict

type FullTextPredict struct {
	JobID    uuid.UUID `json:"job_id"`
	ItemID   string    `json:"item_id"`
	FullText string    `json:"full_text"`
}

FullTextPredict represents a job for a file or resource passed as a message to the predictor.

func NewFullTextMsg

func NewFullTextMsg(job uuid.UUID, item string, text string) *FullTextPredict

NewFullTextMsg creates a pointer to a new FullTextPredict message

func (*FullTextPredict) CSVRow

func (f *FullTextPredict) CSVRow() []string

CSVRow converts a FullTextPredict message into a format for writing to a CSV.

type RabbitMQ

type RabbitMQ struct {
	Connection *amqp.Connection
	Channel    *amqp.Channel
	Queue      *amqp.Queue
	Consumer   <-chan amqp.Delivery
}

RabbitMQ is a data store using RabbitMQ via its amqp interface.

func NewRabbitMQ

func NewRabbitMQ(ctx context.Context, connstr string, queue string, qos int) (*RabbitMQ, error)

NewRabbitMQ returns a message repo using RabbitMQ via the amqp interface. It will create (or connect to) a queue for sending a particular type of message (determined by the type of messages sent or receive from the queue) for a particular purpose (determined by the name of the queue).

func (*RabbitMQ) Close

func (r *RabbitMQ) Close() error

Close shutdowns the connection to the message broker and associated resources.

func (*RabbitMQ) Consume

func (r *RabbitMQ) Consume() <-chan amqp.Delivery

Consume returns the channel that provides deliveries from the message queue.

func (*RabbitMQ) QueueName

func (r *RabbitMQ) QueueName() string

func (*RabbitMQ) Send

func (r *RabbitMQ) Send(ctx context.Context, body interface{}) error

Send publishes a message to the message queue. Body is any kind of object that will be marshalled to JSON and included as the body of the message.

type Repository

type Repository interface {
	Send(ctx context.Context, body interface{}) error
	Consume() <-chan amqp.Delivery
	Close() error
	QueueName() string
}

Repository is an interface that sends messages from a particular queue in a message broker.

Jump to

Keyboard shortcuts

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