pubsub

package
v0.1.45 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2020 License: MIT Imports: 6 Imported by: 0

README

problem statement

lib for pub-sub style messaging

features

  • API exposed via interface
  • retroactive subscription
  • fake implementation to allow faking interactions

event stores

Three event stores have been implemented in search of performance gains. As the performance of each may change over time, they're kept here for easy re-evaluation.

The results of reading/writing 1M events (conducted on the same machine) were as follows:

implementation Write 1M events Read 1M events
badgerDBEventStore 05:53 00:15
boltDBEventStore 04:09 00:28
buntDBEventStore 01:32 00:45

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventPublisher

type EventPublisher interface {
	Publish(
		event model.Event,
	)
}

type EventStore

type EventStore interface {
	Add(event model.Event) error
	List(
		ctx context.Context,
		filter model.EventFilter,
	) (
		<-chan model.Event,
		<-chan error,
	)
}

type EventSubscriber

type EventSubscriber interface {
	// Subscribe returns a filtered event stream
	// events will be sent to the subscription until either:
	//  - ctx is canceled
	//  - returned channel is blocked for 10 seconds
	// note: method signature is based on https://medium.com/statuscode/pipeline-patterns-in-go-a37bb3a7e61d
	Subscribe(
		ctx context.Context,
		filter model.EventFilter,
	) (
		<-chan model.Event,
		<-chan error,
	)
}

type PubSub

type PubSub interface {
	EventPublisher
	EventSubscriber
}

func New

func New(
	db *badger.DB,
) PubSub

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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