gkafka

package
v0.0.0-...-c9a36a8 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Kafka Client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Config *Config
	// contains filtered or unexported fields
}

Kafka Client(Consumer/SyncProducer/AsyncProducer)

func NewClient

func NewClient(config *Config) *Client

New a kafka client.

func (*Client) AsyncSend

func (client *Client) AsyncSend(message *Message) error

Send data to kafka in asynchronized way.

func (*Client) Close

func (client *Client) Close()

Close client.

func (*Client) Receive

func (client *Client) Receive() (*Message, error)

Receive message from kafka from specified topics in config, in BLOCKING way, gkafka will handle offset tracking automatically.

func (*Client) SyncSend

func (client *Client) SyncSend(message *Message) error

Send data to kafka in synchronized way.

func (*Client) Topics

func (client *Client) Topics() ([]string, error)

Get all topics from kafka server.

type Config

type Config struct {
	GroupId        string // group id for consumer.
	Servers        string // server list, multiple servers joined by ','.
	Topics         string // topic list, multiple topics joined by ','.
	AutoMarkOffset bool   // auto mark message read after consumer message from server
	sarama.Config
}

kafka Client based on sarama.Config

func NewConfig

func NewConfig() *Config

New a default configuration object.

type Message

type Message struct {
	Value     []byte
	Key       []byte
	Topic     string
	Partition int
	Offset    int
	// contains filtered or unexported fields
}

Kafka Message.

func (*Message) MarkOffset

func (msg *Message) MarkOffset()

自动标记已读取

Jump to

Keyboard shortcuts

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