Documentation ¶
Index ¶
- Constants
- func ParseCommand(command *gocli.Command) (action string, arguments []gocli.Argument, e porterr.IError)
- type Application
- func (a *Application) Consume(name string) porterr.IError
- func (a *Application) ConsumerCommander(command *gocli.Command)
- func (a *Application) GetConfig() *Config
- func (a *Application) GetRegistry() Registry
- func (a *Application) Publish(p amqp.Publishing, queue string, server string, route ...string) porterr.IError
- func (a *Application) SetRegistry(r Registry) *Application
- type Config
- type ConnectionPool
- type Consumer
- type Queues
- type RabbitQueue
- type RabbitServer
- type Registry
- type ServerPool
- type Servers
Constants ¶
const ( CommandStart = "start" CommandStop = "stop" CommandRestart = "restart" CommandStatus = "status" CommandConsumer = "consumer" CommandSet = "set" CommandKeyWordAll = "all" CommandKeyWordCount = "count" )
const ( // Default value for max conn DefaultMaxConnections = 10 // Default value for max idle lifetime DefaultMaxIdleConnectionLifeTime = 10 * time.Second // Maximum connection on 5000 rps DefaultMaxConnectionOnRPS = 5000 )
const MaxMessagesPerConnection = int64(50000)
MaxMessagesPerConnection will close connection on reach limit
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Application ¶
type Application struct { // Basic application gocli.Application // contains filtered or unexported fields }
Application Rabbit application struct
func NewApplication ¶
func NewApplication(config Config, app gocli.Application) *Application
NewApplication New rabbit application
func (*Application) Consume ¶
func (a *Application) Consume(name string) porterr.IError
Consume Create new consumer
func (*Application) ConsumerCommander ¶ added in v1.2.0
func (a *Application) ConsumerCommander(command *gocli.Command)
ConsumerCommander Consumer command processor
func (*Application) GetConfig ¶ added in v1.2.0
func (a *Application) GetConfig() *Config
GetConfig Get app config
func (*Application) GetRegistry ¶ added in v1.2.0
func (a *Application) GetRegistry() Registry
GetRegistry Get registry of subscribers
func (*Application) Publish ¶
func (a *Application) Publish(p amqp.Publishing, queue string, server string, route ...string) porterr.IError
Publish Publisher publishing - AMQP Message queue - name of the queue defined in config server - name of the server defined in config route - routing keys
func (*Application) SetRegistry ¶ added in v1.2.1
func (a *Application) SetRegistry(r Registry) *Application
SetRegistry Set registry of subscribers
type Config ¶
type Config struct { // Servers configuration Servers Servers // Queues configuration Queues Queues }
Config Rabbit config
type ConnectionPool ¶ added in v1.3.0
type ConnectionPool struct {
// contains filtered or unexported fields
}
ConnectionPool Connection pool
func NewConnectionPool ¶ added in v1.3.0
func NewConnectionPool(maxConnection int) *ConnectionPool
NewConnectionPool Init connection pool
func (*ConnectionPool) GetConnection ¶ added in v1.3.0
func (cp *ConnectionPool) GetConnection(s RabbitServer) (c *connection, e porterr.IError)
GetConnection Get current connection using round robin algorithm
func (*ConnectionPool) Publish ¶ added in v1.3.0
func (cp *ConnectionPool) Publish(p amqp.Publishing, s RabbitServer, q RabbitQueue, route ...string) (e porterr.IError)
Publish message to queue
type Consumer ¶
type Consumer struct { // Queue name Queue string // Server name Server string // Delivery process callback Callback func(d amqp.Delivery) // Subscribers count Count uint8 // contains filtered or unexported fields }
Consumer entity
func (*Consumer) HasSubscribers ¶ added in v1.2.0
Check for subscribers
func (*Consumer) NewSubscriber ¶ added in v1.2.0
New subscribers
func (*Consumer) SubscribersCount ¶ added in v1.2.0
Get s subscribers
type RabbitQueue ¶
type RabbitQueue struct { Server string Exchange string Internal bool Type string Name string Passive bool Durable bool Exclusive bool Nowait bool AutoDelete bool `yaml:"autoDelete"` RoutingKey []string `yaml:"routingKey"` Arguments map[string]interface{} }
Queue configuration
type RabbitServer ¶
type RabbitServer struct { // RabbitMQx virtual host Vhost string // RabbitMQ host Host string // RabbitMQ port Port int // RabbitMQ user User string // RabbitMQ password Password string // Maximum number of connections to server MaxConnections int `yaml:"maxPublishConnections"` // Maximum lifetime for idle connection MaxIdleConnectionLifeTime time.Duration `yaml:"maxIdleConnectionLifeTime"` }
Server configuration
type ServerPool ¶ added in v1.3.0
type ServerPool struct {
// contains filtered or unexported fields
}
ServerPool RabbitMq server Pool
func NewServerPool ¶ added in v1.3.0
func NewServerPool(l gocli.Logger) *ServerPool
NewServerPool Init server pool
func (*ServerPool) GetConnectionPoolOrCreate ¶ added in v1.3.0
func (sp *ServerPool) GetConnectionPoolOrCreate(server string, maxConnections int) *ConnectionPool
GetConnectionPoolOrCreate Get connection pool If not - create