Documentation ¶
Index ¶
- type AnnouncementMessage
- type Client
- type CommandEvent
- type CommandResponse
- type Config
- type ConsumeCallback
- type Consumer
- type Event
- type EventConsumer
- func (ep *EventConsumer) BindExchange(queue string, exchange string, routingKey string) bool
- func (ep *EventConsumer) Consume(queue string, consumerID string, cb ConsumeCallback, autoAck bool, ...) bool
- func (ep *EventConsumer) DeclareExchange(name string, exgType string, durable bool) bool
- func (ep *EventConsumer) DeclareQueue(name string) bool
- func (ep *EventConsumer) Init() bool
- type EventOptions
- type EventPublisher
- type TweetMessage
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 ¶
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 ¶
VerifyConsumer ensure consumer is properly created, else instantiate it
func (*Client) VerifyPublisher ¶
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 ¶
GetConsumer retrieve consumer frm Config consumer list. nil if not found
type ConsumeCallback ¶
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 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
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) 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