events

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidEvent   = errors.New("invalid event")
	ErrUnknownPayload = errors.New("unknown event payload")
)

Functions

This section is empty.

Types

type Collector added in v0.2.0

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

func NewCollector added in v0.2.0

func NewCollector() *Collector

func (*Collector) Drain added in v0.2.0

func (c *Collector) Drain() []*Event

func (*Collector) Events added in v0.2.0

func (c *Collector) Events() []*Event

func (*Collector) Record added in v0.2.0

func (c *Collector) Record(publishable Publishable) error

type ErrDeserializingEvent added in v0.2.0

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

ErrDeserializingEvent

func (*ErrDeserializingEvent) Error added in v0.2.0

func (e *ErrDeserializingEvent) Error() string

func (*ErrDeserializingEvent) Unwrap added in v0.2.0

func (e *ErrDeserializingEvent) Unwrap() error

type ErrDeserializingPayload added in v0.2.0

type ErrDeserializingPayload struct {
	Event *Event
	// contains filtered or unexported fields
}

ErrDeserializingPâyload

func (*ErrDeserializingPayload) Error added in v0.2.0

func (e *ErrDeserializingPayload) Error() string

func (*ErrDeserializingPayload) Unwrap added in v0.2.0

func (e *ErrDeserializingPayload) Unwrap() error

type ErrPublishingEvent added in v0.2.0

type ErrPublishingEvent struct {
	Event *Event
	// contains filtered or unexported fields
}

ErrPublishingEvent

func (*ErrPublishingEvent) Error added in v0.2.0

func (e *ErrPublishingEvent) Error() string

func (*ErrPublishingEvent) Unwrap added in v0.2.0

func (e *ErrPublishingEvent) Unwrap() error

type ErrSerializingEvent added in v0.2.0

type ErrSerializingEvent struct {
	Event *Event
	// contains filtered or unexported fields
}

ErrSerializingEvent

func (*ErrSerializingEvent) Error added in v0.2.0

func (e *ErrSerializingEvent) Error() string

func (*ErrSerializingEvent) Unwrap added in v0.2.0

func (e *ErrSerializingEvent) Unwrap() error

type ErrSerializingPayload added in v0.2.0

type ErrSerializingPayload struct {
	Event *Event
	// contains filtered or unexported fields
}

ErrSerializingPayload

func (*ErrSerializingPayload) Error added in v0.2.0

func (e *ErrSerializingPayload) Error() string

func (*ErrSerializingPayload) Unwrap added in v0.2.0

func (e *ErrSerializingPayload) Unwrap() error

type ErrSubscribingToSubject added in v0.2.0

type ErrSubscribingToSubject struct {
	Subject string
	// contains filtered or unexported fields
}

ErrSubscribingToEvent

func (*ErrSubscribingToSubject) Error added in v0.2.0

func (e *ErrSubscribingToSubject) Error() string

func (*ErrSubscribingToSubject) Unwrap added in v0.2.0

func (e *ErrSubscribingToSubject) Unwrap() error

type Event

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

func CreateEvent

func CreateEvent(
	entityId string,
	topic string,
	payload interface{},
) (*Event, error)

func NewEvent

func NewEvent(
	id string,
	entityId string,
	topic string,
	payload interface{},
	timestamp time.Time,
) (*Event, error)

func (*Event) EntityId

func (e *Event) EntityId() string

func (*Event) Id

func (e *Event) Id() string

func (*Event) Payload

func (e *Event) Payload() interface{}

func (*Event) Timestamp

func (e *Event) Timestamp() time.Time

func (*Event) Topic

func (e *Event) Topic() string

func (*Event) UnmarshalPayload

func (e *Event) UnmarshalPayload(v interface{}) error

type Handler

type Handler interface {
	Handle(ctx context.Context, event *Event) error
}

type LocalEventBus

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

func NewLocalEventBus

func NewLocalEventBus() *LocalEventBus

func (*LocalEventBus) Publish

func (eb *LocalEventBus) Publish(ctx context.Context, events ...*Event) error

func (*LocalEventBus) Subscribe

func (eb *LocalEventBus) Subscribe(ctx context.Context, subject string, handler Handler) error

type NatsEvent

type NatsEvent struct {
	Id        string      `json:"id"`
	EntityId  string      `json:"entity_id"`
	Topic     string      `json:"topic"`
	Payload   interface{} `json:"payload"`
	Timestamp time.Time   `json:"timestamp"`
}

type NatsEventBus

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

func NewNatsEventBus

func NewNatsEventBus(
	consumerGroup string,
	conn *nats.Conn,
) *NatsEventBus

func (*NatsEventBus) Publish

func (eb *NatsEventBus) Publish(ctx context.Context, events ...*Event) error

func (*NatsEventBus) Subscribe

func (eb *NatsEventBus) Subscribe(ctx context.Context, subject string, handler Handler) error

type Publishable

type Publishable interface {
	EntityId() string
	Topic() string
}

type Publisher

type Publisher interface {
	Publish(ctx context.Context, events ...*Event) error
}

type Subscriber

type Subscriber interface {
	Subscribe(ctx context.Context, topic string, handler Handler) error
}

Jump to

Keyboard shortcuts

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