parser

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Consumer

type Consumer interface {
	Messages() <-chan *sarama.ConsumerMessage
	Errors() <-chan error
	Notifications() <-chan *cluster.Notification
}

Consumer is the interface for a Kafka consumer By using an interface that matches bsm/sarama-cluster instead of passing in an instance, testing is made easy

type Decoder

type Decoder interface {
	// ValidateSchemas takes in the path(s) to schema files
	// and returns an error if the schemas are invalid. If
	// schemas are not required by the decoder implementation
	// return nil
	ValidateSchemas(schemas string) error

	// Decode takes in a Kafka message value and returns an interface{}
	// which can be read by json.Marshal() and an error
	Decode([]byte) (interface{}, error)
}

Decoder is the interface used by go-kafka-consumer to decode kafka messages into printable interfaces

type Parser

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

Parser consumes from a Kafka topic, calls message decoders, and prints the message to the console in JSON format

func New

func New(consumer Consumer, topic string, schemas string, decoder Decoder, log *logrus.Logger) (*Parser, error)

New intializes a new Parser struct

func (*Parser) Serve

func (p *Parser) Serve() chan struct{}

Serve calls a kafka consumer loop that will listen for messages, decode them, and print them to the console

Jump to

Keyboard shortcuts

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