events

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2019 License: MIT Imports: 13 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GZIPEventSender

func GZIPEventSender(filename string) (*gzipEventSender, error)

Types

type Encoder

type Encoder interface {
	// Encodes an event into some kind of binary representation.
	Encode(event Event) ([]byte, error)

	// Close the encoder.
	Close() error
}

func NewAvroEncoder

func NewAvroEncoder(registry schema.Registry) Encoder

func NewJSONEncoder

func NewJSONEncoder() Encoder

type Event

type Event interface {
	// Returns the avro schema of this event
	Schema() string

	// Writes the event (in avro format) to the given writer.
	Serialize(io.Writer) error
}

type EventSender

type EventSender interface {
	// Send the given event. This method should be non blocking and
	// must never fail. You might want to use a channel for buffering
	// events internally
	Send(event Event)

	// Close the event sender and flush all pending events.
	Close() error
}
var Events EventSender = LogrusEventSender{logrus.WithField("prefix", "events")}

Global instance to send events. Defaults to a simple sender that prints events using a logger instance.

type EventTopics

type EventTopics struct {
	EventTypes map[reflect.Type]kafka.Topic

	// This is the fallback topic if a type can not be matched to one of the event types.
	// It will be created automatically.
	Fallback string
}

func (EventTopics) TopicForType

func (topics EventTopics) TopicForType(t reflect.Type) string

func (EventTopics) Topics

func (topics EventTopics) Topics() kafka.Topics

type KafkaSender

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

func NewKafkaSender

func NewKafkaSender(kafkaClient sarama.Client, senderConfig KafkaSenderConfig) (*KafkaSender, error)

func (*KafkaSender) Close

func (kafka *KafkaSender) Close() error

func (*KafkaSender) Send

func (kafka *KafkaSender) Send(event Event)

type KafkaSenderConfig

type KafkaSenderConfig struct {
	// Set to true to block Send() if the buffers are full.
	AllowBlocking bool

	// Topics configuration
	TopicsConfig EventTopics

	// The event encoder to use
	Encoder Encoder
}

type LogrusEventSender

type LogrusEventSender struct {
	logrus.FieldLogger
}

func (LogrusEventSender) Close

func (LogrusEventSender) Close() error

func (LogrusEventSender) Send

func (l LogrusEventSender) Send(event Event)

type NoopEventSender

type NoopEventSender struct{}

func (NoopEventSender) Close

func (NoopEventSender) Close() error

func (NoopEventSender) Send

func (NoopEventSender) Send(event Event)

type TopicsFunc

type TopicsFunc func(replicationFactor int16) EventTopics

type WriterEventSender

type WriterEventSender struct {
	io.WriteCloser
}

func (WriterEventSender) Send

func (sender WriterEventSender) Send(event Event)

Jump to

Keyboard shortcuts

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