kafka

package module
v4.1.4 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

README

Kafka Broker

Async Publish

import "github.com/Shopify/sarama"

func AsyncProduceMessage()  {
    var errorsChan = make(chan *sarama.ProducerError)
    var successesChan = make(chan *sarama.ProducerMessage)
    go func() {
        for err := range errorsChan {
            fmt.Println(err)
        }
    }
    go func() {
        for v := range successesChan {
            fmt.Println(v)
        }
    }
    b := NewBroker(AsyncProducer(errorsChan,successesChan))
    b.Publish(`topic`, &broker.Message{})
}

Documentation

Overview

Package kafka provides a kafka broker using sarama cluster

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultBrokerConfig  = sarama.NewConfig()
	DefaultClusterConfig = sarama.NewConfig()
)

Functions

func AsyncProducer

func AsyncProducer(errors chan<- *sarama.ProducerError, successes chan<- *sarama.ProducerMessage) broker.Option

func BrokerConfig

func BrokerConfig(c *sarama.Config) broker.Option

func ClusterConfig

func ClusterConfig(c *sarama.Config) broker.Option

func NewBroker

func NewBroker(opts ...broker.Option) broker.Broker

func SubscribeConfig

func SubscribeConfig(c *sarama.Config) broker.SubscribeOption

func SubscribeContext

func SubscribeContext(ctx context.Context) broker.SubscribeOption

SubscribeContext set the context for broker.SubscribeOption

Types

This section is empty.

Jump to

Keyboard shortcuts

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