Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GZIPEventSender ¶
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 NewJSONEncoder ¶
func NewJSONEncoder() Encoder
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)
Click to show internal directories.
Click to hide internal directories.