kafka

package
v0.0.0-...-31f5ead Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(Options)

Option type

type Options

type Options struct {
	URL                    string
	TopicPartition         int
	TopicReplicationFactor int
	ProducerPartition      int32
	ConsumerGroupID        string
	SocketTimeout          string
	Offset                 string
	Consumer               *kafka.Consumer
	Producer               *kafka.Producer
}

Options for kafka transport

type Transport

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

Transport object

func New

func New(options ...Option) *Transport

New returns client for Kafka messaging

func (*Transport) Close

func (t *Transport) Close()

Close connection

func (*Transport) Handle

func (t *Transport) Handle(path string, group string, handler func([]byte, func([]byte))) error

Handle path

func (*Transport) Listen

func (t *Transport) Listen(callback func())

Listen to kafka

func (*Transport) OnClose

func (t *Transport) OnClose(handler interface{})

OnClose adds a handler when the transport is closed. Passes error as an argument

func (*Transport) Publish

func (t *Transport) Publish(topic string, data []byte) error

Publish to topic

func (*Transport) Request

func (t *Transport) Request(path string, payload []byte, timeOut int) ([]byte, error)

Request path

func (*Transport) Subscribe

func (t *Transport) Subscribe(topic, serviceName string, handler func([]byte)) error

Subscribe for topic Messages will be committed automatically

func (*Transport) SubscribeForRawMsg

func (t *Transport) SubscribeForRawMsg(topic, serviceName string, handler func(interface{})) error

SubscribeForRawMsg for topic Messages have te be committed manually

Jump to

Keyboard shortcuts

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