config

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Setup

func Setup(v *viper.Viper)

Setup sets up the given viper with the defaults and env bindings

func SetupConsume

func SetupConsume(v *viper.Viper)

SetupConsume configures viper for Consume

func SetupEndpoint

func SetupEndpoint(v *viper.Viper)

SetupEndpoint configures viper for Endpoint

func SetupExchange

func SetupExchange(v *viper.Viper)

SetupExchange configures viper for Exchange

func SetupPublish

func SetupPublish(v *viper.Viper)

SetupPublish configures viper for Publish

func SetupQueue

func SetupQueue(v *viper.Viper)

SetupQueue configures viper for Queue

Types

type Config

type Config struct {
	// QueueName the name of the queue to connect to
	QueueName string
	// Queue is the configuration for the queue
	Queue Queue
	// Consume is the configuration of the consumer
	Consume Consume
	// Publish is the configuration for the publishing of messages
	Publish Publish
	// Endpoint is the configuration for the connection endpoint
	Endpoint Endpoint
	// Exchange is the configuration for the exchange, if it is created
	Exchange Exchange
}

Config is the configuration for AMQP

func Must added in v1.3.0

func Must(v *viper.Viper) Config

Must is like New but panics on error

func New

func New(v *viper.Viper) (out Config, err error)

New creates a new instance of Config from viper

func (Config) SetExchangeName added in v1.3.0

func (c Config) SetExchangeName(name string) Config

type Consume

type Consume struct {
	// Consumer is the name of the consumer
	Consumer string `mapstructure:"consumer"`
	// AutoAck causes the server to acknowledge deliveries to this consumer prior to writing the delivery to the network
	AutoAck bool
	// Exclusive: when true, the server will ensure that this is the sole consumer from this queue
	// This should always be false.
	Exclusive bool
	// NoLocal is not supported by RabbitMQ
	NoLocal bool
	// NoWait: do not wait for the server to confirm the request and immediately begin deliveries
	NoWait bool `mapstructure:"consumerNoWait"`
	// Args contains addition arguments to be provided
	Args amqp.Table
}

Consume is the configuration of the consumer of messages from the queue

func NewConsume

func NewConsume(v *viper.Viper) (Consume, error)

NewConsume gets Consume from the values in viper

type Endpoint

type Endpoint struct {
	QueueProtocol string `mapstructure:"queueProtocol"`
	QueueUser     string `mapstructure:"queueUser"`
	QueuePassword string `mapstructure:"queuePassword"`
	QueueHost     string `mapstructure:"queueHost"`
	QueuePort     int    `mapstructure:"queuePort"`
	QueueVHost    string `mapstructure:"queueVHost"`
}

Endpoint is the configuration needed to connect to a rabbitmq vhost

func NewEndpoint

func NewEndpoint(v *viper.Viper) (out Endpoint, err error)

NewEndpoint gets Endpoint from the values in viper

type Exchange

type Exchange struct {
	Name string `mapstructure:"exchangeName"`

	Kind string `mapstructure:"exchangeKind"`

	Durable bool `mapstructure:"exchangeDurable"`
	// AutoDelete tells the queue to drop messages if there are not any consumers
	AutoDelete bool `mapstructure:"exchangeAutoDelete"`
	// Exclusive queues are only accessible by the connection that declares them
	Internal bool `mapstructure:"exchangeInternal"`
	// NoWait is true, the queue will assume to be declared on the server
	NoWait bool `mapstructure:"exchangeNoWait"`

	Args amqp.Table
}

Exchange is the configuration for the exchange to be created/used

func NewExchange

func NewExchange(v *viper.Viper) (out Exchange, err error)

NewExchange gets Exchange from the values in viper

func (Exchange) AsXDelay

func (ex Exchange) AsXDelay() Exchange

AsXDelay set the exchange up as an x-delay-type

type Publish

type Publish struct {
	Mandatory bool   `mapstructure:"publishMandatory"`
	Immediate bool   `mapstructure:"publishImmediate"`
	Exchange  string `mapstructure:"exchangeName"`
}

Publish is the configuration for the publishing of messages

func NewPublish

func NewPublish(v *viper.Viper) (out Publish, err error)

NewPublish gets Publish from the values in viper

type Queue

type Queue struct {
	// Durable sets the queue to be persistent
	Durable bool `mapstructure:"queueDurable"`
	// AutoDelete tells the queue to drop messages if there are not any consumers
	AutoDelete bool `mapstructure:"queueAutoDelete"`
	// Exclusive queues are only accessible by the connection that declares them
	Exclusive bool
	// NoWait is true, the queue will assume to be declared on the server
	NoWait bool
	// Args contains addition arguments to be provided
	Args amqp.Table

	// ReConnRetries is the number of times to attempt to re-connect to a queue
	// if a connection error is found
	ReconnRetries int `mapstructure:"queueReconnRetries`

	// Retries is the number of times to retry an action before giving up
	Retries int `mapstructure:"queueRetries"`

	// RetryDelay is the delay between retries
	RetryDelay time.Duration `mapstructure:"queueRetryDelay"`
}

Queue is the configuration of the queue to be created if the queue does not yet exist

func NewQueue

func NewQueue(v *viper.Viper) (Queue, error)

NewQueue gets Queue from the values in viper

Jump to

Keyboard shortcuts

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