kafka

package module
v0.0.0-...-ea12527 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2020 License: LGPL-2.1 Imports: 9 Imported by: 0

README

Build Status Coverage Status GoDoc Go Report Card

Event Horizon Kafka

Event Horizon Kafka is event bus for Event Horizon a CQRS/ES toolkit for Go.

Usage

See the eventbus_test.go how to initialize.

Development

To develop Event Horizon Kafka you need to have Docker and Docker Compose installed.

To start all needed services and run all tests, simply run make:

make

To manualy run the services and stop them:

make services
make stop

When the services are running testing can be done either locally or with Docker:

make test
make test_docker
go test ./...

The difference between make test and go test ./... is that make test also prints coverage info.

License

GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrCouldNotMarshalEvent

func ErrCouldNotMarshalEvent(err error) error

ErrCouldNotMarshalEvent is when an event could not be marshaled into BSON.

func ErrCouldNotPublishEvent

func ErrCouldNotPublishEvent(err error) error

ErrCouldNotPublishEvent is when kafka-client cannot send event to kafka

func ErrCouldNotUnmarshalEvent

func ErrCouldNotUnmarshalEvent(err error) error

ErrCouldNotUnmarshalEvent is when an event could not be unmarshaled into BSON.

Types

type EventBus

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

EventBus is an event bus that notifies registered EventHandlers of published events. It will use the SimpleEventHandlingStrategy by default.

func NewEventBus

func NewEventBus(brokers []string, config *sarama.Config, timeout time.Duration, topicProducer TopicProducer,
	topicsConsumer TopicsConsumer) (*EventBus, error)

NewEventBus creates a EventBus.

func NewEventBusWithMarshaller

func NewEventBusWithMarshaller(brokers []string, config *sarama.Config, timeout time.Duration, topicProducer TopicProducer,
	topicsConsumer TopicsConsumer, eventMarshaller EventMarshaller, eventUnmarshaller EventUnmarshaller) (*EventBus, error)

NewEventBusWithMarshaller creates a EventBus.

func (*EventBus) AddHandler

func (b *EventBus) AddHandler(m eh.EventMatcher, h eh.EventHandler)

AddHandler implements the AddHandler method of the eventhorizon.EventBus interface.

func (*EventBus) AddObserver

func (b *EventBus) AddObserver(m eh.EventMatcher, h eh.EventHandler)

AddObserver implements the AddObserver method of the eventhorizon.EventBus interface.

func (*EventBus) Errors

func (b *EventBus) Errors() <-chan eh.EventBusError

Errors returns an error channel where async handling errors are sent.

func (*EventBus) PublishEvent

func (b *EventBus) PublishEvent(ctx context.Context, event eh.Event) error

PublishEvent publishes an event to all handlers capable of handling it.

type EventMarshaller

type EventMarshaller func(ctx context.Context, event eh.Event) ([]byte, error)

EventMarshaller eventbus event into specific marshaling format

type EventUnmarshaller

type EventUnmarshaller func(data []byte) (eh.Event, context.Context, error)

EventUnmarshaller eventbus event from specific marshaling format

type TopicProducer

type TopicProducer func(event eh.Event) string

TopicProducer for define name of topic regarding event type

type TopicsConsumer

type TopicsConsumer func(event eh.EventHandler) []string

TopicsConsumer for define topic for consumption

Jump to

Keyboard shortcuts

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