rabbitmq

package
v0.0.0-...-7fdc067 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2019 License: BSD-2-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnnouncementMessage

type AnnouncementMessage struct {
	Message string `json:"message"`
	URL     string `json:"url"`
	What    string `json:"what"`
}

AnnouncementMessage announcement message

func (*AnnouncementMessage) ToJSON

func (ce *AnnouncementMessage) ToJSON() ([]byte, error)

ToJSON converts to json

type Client

type Client struct {
	Publisher *EventPublisher
	Consumer  *EventConsumer
	// contains filtered or unexported fields
}

Client the RabbitMQ publisher & consumer client linked with configuration

func NewClient

func NewClient(logger *logging.Logger, config *Config, ccb ConsumeCallback) *Client

NewClient create a new RabbitMQ client

func (*Client) AddConsumerName

func (rc *Client) AddConsumerName(name string)

AddConsumerName add consumer name registration for consumer verifications

func (*Client) PublishCommand

func (rc *Client) PublishCommand(cc *CommandEvent, replyTo string) bool

PublishCommand publish a command to RabbitMQ, and hope somebody we reply on the replyTo queue

func (*Client) PublishGitlabEvent

func (rc *Client) PublishGitlabEvent(event *CommandResponse) bool

PublishGitlabEvent publish incoming gitlab event to exchange

func (*Client) VerifyConsumer

func (rc *Client) VerifyConsumer() bool

VerifyConsumer ensure consumer is properly created, else instantiate it

func (*Client) VerifyPublisher

func (rc *Client) VerifyPublisher() bool

VerifyPublisher ensure publisher is properly created, else instantiate it

type CommandEvent

type CommandEvent struct {
	Command string `json:"command"`
	Channel string `json:"channel"`
	User    string `json:"user"`
}

CommandEvent event sent to command handler

func (*CommandEvent) ToJSON

func (ce *CommandEvent) ToJSON() ([]byte, error)

ToJSON converts CommandEvent to JSON

type CommandResponse

type CommandResponse struct {
	Channel     string `json:"channel"`
	Message     string `json:"message"`
	User        string `json:"user"`
	MessageType string `json:"message_type"`
}

CommandResponse command response received on RabbitMQ from command handler

func (*CommandResponse) ToJSON

func (gre *CommandResponse) ToJSON() ([]byte, error)

ToJSON converts CommandResponse to json string

type Config

type Config struct {
	URL                  string              `yaml:"url"`
	EventExchange        string              `yaml:"exchange"`
	EventExchangeDurable bool                `yaml:"exchange-durable"`
	EventExchangeType    string              `yaml:"exchange-type"`
	PublisherRoutingKey  string              `yaml:"publisher-routing-key"`
	Consumers            map[string]Consumer `yaml:"consumers"`
}

Config standard configuration

func (*Config) GetConsumer

func (c *Config) GetConsumer(name string) *Consumer

GetConsumer retrieve consumer frm Config consumer list. nil if not found

type ConsumeCallback

type ConsumeCallback func(*amqp.Delivery)

ConsumeCallback callback function called on consuming

type Consumer

type Consumer struct {
	ConsumerID      string `yaml:"consumer-id"`
	Queue           string `yaml:"queue"`
	Exchange        string `yaml:"exchange"`
	ExchangeDurable bool   `yaml:"exchange-durable"`
	ExchangeType    string `yaml:"exchange-type"`
	RoutingKey      string `yaml:"routing-key"`
}

Consumer single consumer object

type Event

type Event interface {
	ToJSON() ([]byte, error)
}

Event interface

type EventConsumer

type EventConsumer struct {
	IncomingMessages chan amqp.Delivery
	// contains filtered or unexported fields
}

EventConsumer publication object

func NewEventConsumer

func NewEventConsumer(logger *logging.Logger, config *Config) *EventConsumer

NewEventConsumer creates a new EventPublisher with config & logger

func (*EventConsumer) BindExchange

func (ep *EventConsumer) BindExchange(queue string, exchange string, routingKey string) bool

BindExchange bind exchange with queue

func (*EventConsumer) Consume

func (ep *EventConsumer) Consume(queue string, consumerID string, cb ConsumeCallback, autoAck bool, forever bool) bool

Consume consume events on queue

func (*EventConsumer) DeclareExchange

func (ep *EventConsumer) DeclareExchange(name string, exgType string, durable bool) bool

DeclareExchange declare exchange on event consumer

func (*EventConsumer) DeclareQueue

func (ep *EventConsumer) DeclareQueue(name string) bool

DeclareQueue declare queue with name

func (*EventConsumer) Init

func (ep *EventConsumer) Init() bool

Init initialize event consumer

type EventOptions

type EventOptions struct {
	CorrelationID string
	ReplyTo       string
	ExpirationMs  uint32
	RoutingKey    string
}

EventOptions event options on publication

type EventPublisher

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

EventPublisher publication object

func NewEventPublisher

func NewEventPublisher(logger *logging.Logger, config *Config) *EventPublisher

NewEventPublisher creates a new EventPublisher with config & logger

func (*EventPublisher) Init

func (ep *EventPublisher) Init() bool

Init initialize event publisher

func (*EventPublisher) IsValid

func (ep *EventPublisher) IsValid() bool

IsValid return the valid flag

func (*EventPublisher) Publish

func (ep *EventPublisher) Publish(event Event, eventType string, options *EventOptions) bool

Publish publish event

type TweetMessage

type TweetMessage struct {
	Message        string `json:"message"`
	Username       string `json:"username"`
	UserScreenName string `json:"user_screen_name"`
	Date           string `json:"date"`
}

TweetMessage twitter reduced message for transport on rabbitmq

func (*TweetMessage) ToJSON

func (ce *TweetMessage) ToJSON() ([]byte, error)

ToJSON converts to json

Jump to

Keyboard shortcuts

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