Documentation
¶
Index ¶
- Variables
- func ConsumeBatch(ctx context.Context, client sarama.ConsumerGroup, topics []string, ...) []sarama.ConsumerMessage
- func ConsumeBatchPriority(ctx context.Context, client sarama.ConsumerGroup, topics []string, ...) ([]sarama.ConsumerMessage, string)
- func ConsumeChan(ctx context.Context, wg *sync.WaitGroup, client sarama.ConsumerGroup, ...)
- func NewConsumerGroup(brokers []string, groupId string) (sarama.ConsumerGroup, error)
- func NewProducer(brokers []string, maxMegabytes int) (sarama.SyncProducer, error)
- func ProduceBatch(ctx context.Context, client sarama.SyncProducer, messages interface{}, ...) error
- func ProduceChan(ctx context.Context, wg *sync.WaitGroup, client sarama.SyncProducer, ...)
Constants ¶
This section is empty.
Variables ¶
var ErrCantProduce = errors.New("cant produce the message")
var ErrNoBrokers = errors.New("brokers is not defined")
var ErrNoGroupID = errors.New("groupID is not defined")
var ErrNotAllowed = errors.New("input is not allowed")
var ErrNotAllowedType = errors.New("not allowed type")
Functions ¶
func ConsumeBatch ¶
func ConsumeBatch(ctx context.Context, client sarama.ConsumerGroup, topics []string, batchCount int) []sarama.ConsumerMessage
ConsumeBatch takes messages as much as batchCount by using given sarama.ConsumerGroup. Re-tries every 5 seconds until the success. Returns as sarama.ConsumerMessage slice. Runs 1 minutes at most. (if there is no message, time will may be exceed.)
func ConsumeBatchPriority ¶ added in v0.1.5
func ConsumeBatchPriority(ctx context.Context, client sarama.ConsumerGroup, topics []string, batchCount int) ([]sarama.ConsumerMessage, string)
ConsumeBatchPriority takes messages by implementing Priority structure. Loop over topics and tries to take message. If there is any message consumed The first item in the "topics" slice is considered the highest topic. Returns the messages when as much as batchCount is arrived or time exceed, (if there is no message on any priority stage, time will may be exceed.)
func ConsumeChan ¶
func ConsumeChan(ctx context.Context, wg *sync.WaitGroup, client sarama.ConsumerGroup, topics []string, outChan chan sarama.ConsumerMessage)
ConsumeChan starts consuming messages and write messages to outChan.
func NewConsumerGroup ¶
func NewConsumerGroup(brokers []string, groupId string) (sarama.ConsumerGroup, error)
NewConsumerGroup returns a sarama.ConsumerGroup.
func NewProducer ¶
func NewProducer(brokers []string, maxMegabytes int) (sarama.SyncProducer, error)
NewProducer returns a sarama.SyncProducer.
func ProduceBatch ¶
func ProduceBatch(ctx context.Context, client sarama.SyncProducer, messages interface{}, topic string) error
ProduceBatch produces given data with the client. It supports multi-type. Supported Types:
- bytesSlice: [][]byte, topic must be set
- consumerMessages: []sarama.ConsumerMessage, topic must be set
- producerMessages: []*sarama.ProducerMessage, topic's not needed. Set your topic in the messages.
func ProduceChan ¶
func ProduceChan(ctx context.Context, wg *sync.WaitGroup, client sarama.SyncProducer, inChan chan interface{}, errChan chan error, topic string)
ProduceChan produces by reading messages from inChan. It supports multi-type. Supported Types:
- bytesSlice: []byte, topic must be set
- consumerMessage: sarama.ConsumerMessage, topic must be set
- producerMessage: *sarama.ProducerMessage, topic's not needed. Set your topic in the messages.
Types ¶
This section is empty.
