simply

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitMongoOrExit

func InitMongoOrExit(cfg *DBConfig) (entityStore *mongo.Database)

func InitPostgresOrExit

func InitPostgresOrExit(cfg *DBConfig) (db *gorm.DB, err error)

func StartEntityGenerator

func StartEntityGenerator(evs EventStore, eg EntityGenerator, cfg *KafkaConfig)

Types

type AppConfig

type AppConfig struct {
	Name string
}

type Command

type Command struct {
	AutoMigration bool
	EventStoreDB  *DBConfig
	Kafka         *KafkaConfig
}

type DBConfig

type DBConfig struct {
	Host     string
	Port     string
	User     string
	Password string
	Database string
}

type EntityGenerator

type EntityGenerator interface {
	CreateEntityAnsSave(events []*EventEntity) error
}

type Event

type Event interface {
	ID() uuid.UUID
	Type() string
	Time() time.Time
}

type EventEntity

type EventEntity struct {
	ID          uint            `gorm:"primarykey"`
	UserNo      uint            `gorm:"index"`
	EventType   string          `gorm:"index"`
	AggregateId uuid.UUID       `gorm:"type:uuid;index"`
	Payload     json.RawMessage `gorm:"type:json"`
}

func (EventEntity) TableName

func (EventEntity) TableName() string

type EventModel

type EventModel struct {
	AggregateID uuid.UUID `json:"id" gorm:"type:uuid;column:id;index"`
	EventType   string    `json:"event_type" gorm:"index"`
	AppliedAt   time.Time `json:"applied_at"`
}

func (*EventModel) ID

func (ev *EventModel) ID() uuid.UUID

func (*EventModel) Time

func (ev *EventModel) Time() time.Time

func (*EventModel) Type

func (ev *EventModel) Type() string

type EventStore

type EventStore interface {
	AddAndPublishEvent(userNo uint, event Event) (*EventEntity, error)
	GetAllEvents(aggregateId uuid.UUID) ([]*EventEntity, error)
	GetLastEvent(aggregateId uuid.UUID) (*EventEntity, error)
}

func CreateCommander

func CreateCommander(cfg *Command, ec chan Event) EventStore

func NewEventStore

func NewEventStore(db *gorm.DB, ec chan Event) EventStore

type KafkaConfig

type KafkaConfig struct {
	BootstrapServers string
	Topic            string
	ConsumerGroup    string
}

type Observer

type Observer interface {
	Run()
}

func CreateProjector

func CreateProjector(cfg *Projector, ec <-chan Event) Observer

func NewObserver

func NewObserver(cfg *KafkaConfig, ec <-chan Event) (Observer, error)

type Projector

type Projector struct {
	AutoMigration bool
	Kafka         *KafkaConfig
}

type Query

type Query struct {
	AutoMigration bool
	EntityStoreDB *DBConfig
}

Jump to

Keyboard shortcuts

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