kafka

package
v0.1.27 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2021 License: CC0-1.0, CC0-1.0, CC0-1.0, + 1 more Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultBrokerAddr = "localhost:9092" // The default broker address to use if no broker addresses are specified.
	DefaultLifetime   = time.Minute
)

The default option values.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection struct {
	log.BasicLogable
	// contains filtered or unexported fields
}

Connection represents a connection to Kafka.

func New

func New(options ...Option) (*Connection, error)

New connects to the Kafka server.

func (*Connection) Close

func (c *Connection) Close() error

Close closes the connection to Kafka.

func (*Connection) IsLogName

func (c *Connection) IsLogName(_ context.Context, name string) (bool, error)

IsLogName returns true iff the given string is a log name.

func (*Connection) LogNames

func (c *Connection) LogNames(_ context.Context) ([]string, error)

LogNames returns the log names.

func (*Connection) Stream

func (c *Connection) Stream(_ context.Context, name string, start *monitor.Time, finish *monitor.Time) (monitor.Iterator, error)

Stream returns an iterator down which entries from the log 'name' are passed. Only entries falling into the range determined by start and finish will be returned. If start is unassigned then the start of the log will be used; if end is unassigned then no end is used. The caller should ensure that the returned Iterator is closed, otherwise a resource leak will result.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option sets options on a Kafka logger.

func AddBrokerAddr

func AddBrokerAddr(addr ...string) Option

AddBrokerAddr adds the given addresses to the slice of Kafka broker address. Broker addresses should be in the format "hostname:port". DefaultBrokerAddr if and only if no broker addresses are added.

func Formatter

func Formatter(f logger.Formatter) Option

Formatter sets the formatter to use when converting strings to log messages.

func Lifetime

func Lifetime(d time.Duration) Option

Lifetime sets the lifetime of a Kafka client connection in the connection pool.

Jump to

Keyboard shortcuts

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