kafka

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package kafka provides a kafka broker using sarama cluster

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broker

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

func New

func New(opts ...Option) *Broker

func (*Broker) Close

func (k *Broker) Close(ctx context.Context) error

func (*Broker) Open

func (k *Broker) Open(context.Context) error

func (*Broker) Publish

func (k *Broker) Publish(ctx context.Context, topic string, msg *broker.Message, opts ...broker.PublishOption) error

func (*Broker) String

func (k *Broker) String() string

func (*Broker) Subscribe

func (k *Broker) Subscribe(ctx context.Context, topic string, handler broker.Handler, opts ...broker.SubscribeOption) (broker.Subscriber, error)

type JSONCodec

type JSONCodec struct{}

func (JSONCodec) Marshal

func (m JSONCodec) Marshal(v interface{}) ([]byte, error)

func (JSONCodec) Unmarshal

func (m JSONCodec) Unmarshal(data []byte, v interface{}) error

type Option

type Option func(*Broker)

func Address

func Address(addrs []string) Option

func AsyncPublish

func AsyncPublish() Option

func Codec

func Codec(c codec) Option

func Config

func Config(conf *sarama.Config) Option

func Logger

func Logger(l logger) Option

func OnAsyncPublishFailure

func OnAsyncPublishFailure(f func(*PublishError)) Option

func OnAsyncPublishSuccess

func OnAsyncPublishSuccess(f func(*broker.Message)) Option

type PublishError

type PublishError struct {
	Error   error
	Message *broker.Message
}

Jump to

Keyboard shortcuts

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