event

package
v0.0.0-...-a0e5b65 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2019 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close()

Close .

func OnMeowCreated

func OnMeowCreated(f func(MeowCreatedMessage)) error

OnMeowCreated - Trigger on MeowCreated event

func PublishMeowCreated

func PublishMeowCreated(meow schema.Meow) error

PublishMeowCreated - Push MeowCreated event to the EventStore

func SetEventStore

func SetEventStore(es EventStore)

SetEventStore .

func SubscribeMeowCreated

func SubscribeMeowCreated() (<-chan MeowCreatedMessage, error)

SubscribeMeowCreated - Receives MeowCreated events

Types

type EventStore

type EventStore interface {
	Close()
	PublishMeowCreated(meow schema.Meow) error
	SubscribeMeowCreated() (<-chan MeowCreatedMessage, error)
	OnMeowCreated(f func(MeowCreatedMessage)) error
}

EventStore .

type MeowCreatedMessage

type MeowCreatedMessage struct {
	ID        string
	Body      string
	CreatedAt time.Time
}

MeowCreatedMessage Meow messag

func (*MeowCreatedMessage) Key

func (m *MeowCreatedMessage) Key() string

Key gets message key

type Message

type Message interface {
	Key() string
}

Message interface

type NatEventStore

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

NatEventStore NATS implementation for EventStore interface

func NewNats

func NewNats(url string) (*NatEventStore, error)

NewNats creates stream connection with NATS

func (*NatEventStore) Close

func (e *NatEventStore) Close()

Close NATS connection

func (*NatEventStore) OnMeowCreated

func (e *NatEventStore) OnMeowCreated(fn func(MeowCreatedMessage)) (err error)

OnMeowCreated attach a function to handle MeowCreated event

func (*NatEventStore) PublishMeowCreated

func (e *NatEventStore) PublishMeowCreated(meow schema.Meow) error

PublishMeowCreated inserts MeowCreated event

func (*NatEventStore) SubscribeMeowCreated

func (e *NatEventStore) SubscribeMeowCreated() (<-chan MeowCreatedMessage, error)

SubscribeMeowCreated Decode events from NATS and routes to a channel with MeowCreated event

Jump to

Keyboard shortcuts

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