poll

package
v6.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2018 License: Apache-2.0 Imports: 13 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AggregateMeta

type AggregateMeta struct {
	ID          objectid.ObjectID `bson:"_id,omitempty" json:"_id,omitempty"`
	AggregateID int8              `bson:"aggregateID,omitempty" json:"aggregateID,omitempty"`
	Version     int64             `bson:"version,omitempty" json:"version,omitempty"`
}

AggregateMeta contains current versions for Aggregates. This version is updated everytime an Aggregate receives an associated Event.

type EventResponse

type EventResponse struct {
	Event model.Event
	Error error
}

EventResponse is the response distributed over the EventsIO channels.

type EventsIO

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

EventsIO allows interacting with the EventsPoll service. This is the medium through which the new events are distributed.

func Init

func Init(config IOConfig) (*EventsIO, error)

Init initializes the EventPoll service.

func (*EventsIO) Close

func (e *EventsIO) Close()

Close closes any open routines associated with EventsPoll service, such as Kafka Producers and Consumers. Use this when the service is no longer required.

func (*EventsIO) Context

func (e *EventsIO) Context() context.Context

Context returns the errgroup-context used for EventsPoll-routines.

func (*EventsIO) Events

func (e *EventsIO) Events() <-chan *EventResponse

Events channel. New events from EventStoreQuery are received here.

func (*EventsIO) RoutinesGroup

func (e *EventsIO) RoutinesGroup() *errgroup.Group

RoutinesGroup returns the errgroup used for EventsPoll-routines.

func (*EventsIO) Wait

func (e *EventsIO) Wait() <-chan error

Wait is a wrapper for errgroup.Wait, and will wait for all EventsPoll and RoutinesGroup routines to exit, and propagate the error from errgroup.Wait. This is not meant to do FanOut, it always returns the same channel. FanOut logic must be implemented by library-user. Note: The resulting channel will get data only once, and is then closed.

type IOConfig

type IOConfig struct {
	KafkaConfig KafkaConfig
	MongoConfig MongoConfig
}

IOConfig is the configuration for EventPoll service.

type KafkaConfig

type KafkaConfig struct {
	// Consumer for EventStoreQuery-response
	ESQueryResCons *kafka.ConsumerConfig
	// Consumer for Event
	EventCons *kafka.ConsumerConfig

	// Producer for making requests to ESQuery
	ESQueryReqProd *kafka.ProducerConfig
	// Topic on which requests to EventStoreQuery should be sent.
	ESQueryReqTopic string
}

KafkaConfig is the configuration for Kafka, such as brokers and topics.

type MongoConfig

type MongoConfig struct {
	AggregateID   int8
	AggCollection *mongo.Collection
	// Collection/Database in which Aggregate metadata is stored.
	Connection         *mongo.ConnectionConfig
	MetaDatabaseName   string
	MetaCollectionName string
}

MongoConfig is the configuration for MongoDB client.

type ReadConfig

type ReadConfig struct {
	EnableDelete bool
	EnableInsert bool
	EnableQuery  bool
	EnableUpdate bool
}

ReadConfig allows choosing what type of events should be processed. Warning: Be sure to read the associated EventsIO channel if it is enabled here. Otherwise it will result in a deadlock!

Jump to

Keyboard shortcuts

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