producer

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2017 License: MIT Imports: 11 Imported by: 25

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultMessageProducer

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

DefaultMessageProducer defines default implementation of a message producer

func (*DefaultMessageProducer) ConnectivityCheck

func (p *DefaultMessageProducer) ConnectivityCheck() (string, error)

ConnectivityCheck verifies if the kakfa proxy is availabe

func (*DefaultMessageProducer) SendMessage

func (p *DefaultMessageProducer) SendMessage(uuid string, message Message) (err error)

SendMessage is the producer method that takes care of sending a message on the queue

func (*DefaultMessageProducer) SendRawMessage

func (p *DefaultMessageProducer) SendRawMessage(uuid string, message string) (err error)

SendRawMessage is the producer method that takes care of sending a raw message on the queue

type Message

type Message struct {
	Headers map[string]string
	Body    string
}

Message is the higher-level representation of messages from the queue: containing headers and message body

type MessageProducer

type MessageProducer interface {
	SendMessage(string, Message) error
	ConnectivityCheck() (string, error)
}

MessageProducer defines the interface for message producer - which writes to kafka through the proxy

SendMessage implements the logic to sending a Message to a queue. The input string should be the UUID that identifies the message. An error should be returned in case of failure in sending a message.

ConnectivityCheck implements the logic to check the current connectivity to the queue. The method should return a message about the status of the connection and an error in case of connectivity failure.

func NewMessageProducer

func NewMessageProducer(config MessageProducerConfig) MessageProducer

NewMessageProducer returns a producer instance

func NewMessageProducerWithHTTPClient

func NewMessageProducerWithHTTPClient(config MessageProducerConfig, httpClient *http.Client) MessageProducer

NewMessageProducerWithHTTPClient returns a producer instance with specified http client instance

type MessageProducerConfig

type MessageProducerConfig struct {
	//proxy address
	Addr  string `json:"address"`
	Topic string `json:"topic"`
	//the name of the queue
	//leave it empty for requests to UCS kafka-proxy
	Queue         string `json:"queue"`
	Authorization string `json:"authorization"`
}

MessageProducerConfig specifies the configuration for message producer

type MessageRecord

type MessageRecord struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

MessageRecord is a Message format required by Kafka-Proxy

type MessageWithRecords

type MessageWithRecords struct {
	Records []MessageRecord `json:"records"`
}

MessageWithRecords is a message format required by Kafka-Proxy containing all the Messages

Jump to

Keyboard shortcuts

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