go_events

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2019 License: MIT Imports: 1 Imported by: 1

README

# go-events A simple library to allow for pub/sub events in golang.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event interface {
	// Type returns the event type.
	Type() string
}

Event marks items that can be sent as events.

type PublishableEvent

type PublishableEvent interface {
	Event
	// Payload returns the serialized payload for this event.
	Payload() ([]byte, error)
}

type Publisher

type Publisher interface {
	// Write an event to the Publisher. If no error is returned, the caller will
	// assume that all events have been committed to the publisher. If an error is
	// received, the caller may retry sending the event.
	Write(event PublishableEvent) error
}

Publisher accepts and sends events.

type SubscribableEvent

type SubscribableEvent interface {
	Event
	// WithPayload takes a serialized event and un-serializes it
	WithPayload(payload []byte) error
}

type Subscriber

type Subscriber interface {
	AddHandler(eventTypes []string, handler SubscriberHandlerFunc) error
	Subscribe(ctx context.Context) error
}

type SubscriberHandlerFunc

type SubscriberHandlerFunc func(eventType string, payload []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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