Documentation
¶
Index ¶
- Constants
- Variables
- type Config
- type Delivery
- type GetStruct
- type Kafka
- func (kafka *Kafka) Acknowledge(delivery Delivery) (result bool, err error)
- func (kafka *Kafka) Connect(config *Config) (result bool, err error)
- func (kafka *Kafka) Get(get GetStruct) (msg Delivery, ok bool, err error)
- func (kafka *Kafka) Publish(pub PublishStruct) (result bool, err error)
- func (kafka *Kafka) Subscribe(sub SubscribeStruct) (delivery <-chan Delivery, err error)
- type PublishStruct
- type Queue
- type RabbitMQ
- func (rabbitmq *RabbitMQ) Acknowledge(delivery Delivery) (result bool, err error)
- func (rabbitmq *RabbitMQ) Connect(config *Config) (result bool, err error)
- func (rabbitmq *RabbitMQ) Get(get GetStruct) (msg Delivery, ok bool, err error)
- func (rabbitmq *RabbitMQ) Publish(pub PublishStruct) (result bool, err error)
- func (rabbitmq *RabbitMQ) Subscribe(sub SubscribeStruct) (delivery <-chan Delivery, err error)
- type SubscribeStruct
Constants ¶
const ( //RABBITMQ : This is used in Factory RABBITMQ = "rabbitmq" KAFKA = "kafka" )
Variables ¶
var ( //ErrCursor : This is used when cursor is pointing to nil ErrCursor = errors.New("Invalid cursor") //ErrConnection : This is used when error occurs while creating connection ErrConnection = errors.New("Failed to connect to RabbitMQ, Kindly check RMQ Server is running / reachable and config data is correct") //ErrorInvalidQueue : This is used in Init(), where user passes unsupported queue type ErrorInvalidQueue = errors.New("Unsupported queue type") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
ConString string
Scheme string
Host string
Port int
Username string
Password string
Vhost string
KafkaTopic string
KafkaPartition int
}
Config : This struct is used to define all neccessary parameters required by Supported Queue Client i.e. RabbitMQ (As of now)
type Delivery ¶
type Delivery struct {
// Properties
ContentType string // MIME content type
ContentEncoding string // MIME content encoding
DeliveryMode uint8 // queue implementation use - non-persistent (1) or persistent (2)
Priority uint8 // queue implementation use - 0 to 9
CorrelationID string // application use - correlation identifier
ReplyTo string // application use - address to reply to (ex: RPC)
Expiration string // implementation use - message expiration spec
MessageID string // application use - message identifier
Timestamp time.Time // application use - message timestamp
Type string // application use - message type name
UserID string // application use - creating user - should be authenticated user
AppID string // application use - creating application id
// Valid only with Channel.Consume
ConsumerTag string
// Valid only with Channel.Get
MessageCount uint32
DeliveryTag uint64
Redelivered bool
Exchange string // basic.publish exhange
RoutingKey string // basic.publish routing key
Body []byte
KafkaTopic string
KafkaPartition int
KafkaKey []byte
}
Delivery captures the fields for a previously delivered message resident in a queue to be delivered by the server to a consumer from Channel.Consume or Channel.Get.
type Kafka ¶
RabbitMQ : Pointer to this struct is retured in Init() if input QueueType is "rabbitmq"
func (*Kafka) Acknowledge ¶
Acknowledge : Function acknowledges a message using existing connection object. Input Parameters
DeliveryTag : uint64
func (*Kafka) Connect ¶
Connect : Function connects to Kafka Server using connection string passed in Config. Input Parameters
config : struct *Config
func (*Kafka) Get ¶
Get : Function gets a message using existing connection object. Input Parameters
get : struct GetStruct
type PublishStruct ¶
type PublishStruct struct {
Exchange string
Key string
Mandatory bool
Immediate bool
Message []byte
ContentType string
DeliveryTag uint64
Delay uint64 //Delay in milliseconds
KafkaTimeoutInSeconds time.Duration
}
PublishStruct : This struct is an input parameter for Publish()
type Queue ¶
type Queue interface {
Connect(*Config) (bool, error)
Publish(PublishStruct) (bool, error)
Subscribe(SubscribeStruct) (<-chan Delivery, error)
Get(GetStruct) (Delivery, bool, error)
Acknowledge(Delivery) (bool, error)
}
Queue : This interface is used as return type of Init()
type RabbitMQ ¶
type RabbitMQ struct {
Connection *amqp.Connection
Channel *amqp.Channel
}
RabbitMQ : Pointer to this struct is retured in Init() if input QueueType is "rabbitmq"
func (*RabbitMQ) Acknowledge ¶
Acknowledge : Function acknowledges a message using existing connection object. Input Parameters
DeliveryTag : uint64
func (*RabbitMQ) Connect ¶
Connect : Function connects to RabbitMQ Server using connection string passed in Config. Input Parameters
config : struct *Config
func (*RabbitMQ) Get ¶
Get : Function gets a message using existing connection object. Input Parameters
get : struct GetStruct
type SubscribeStruct ¶
type SubscribeStruct struct {
Queue string
Consumer string
AutoAck bool
Exclusive bool
NoLocal bool
NoWait bool
PrefetchCount int //Allows batching of messages
PrefetchSize int
ApplyPrefetchGlobally bool //apply prefetch settings to all channels - across all consumers
KafkaTopic string
KafkaConsumerGroupID string
KafkaBrokers []string
}
SubscribeStruct : This struct is an input parameter for Subscribe()