domain

package
v0.0.0-...-1d4a79d Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CompanyAggregate        = "company"
	CompanyCreatedEvent     = "peof.organization.CompanyCreated"
	CompanyNameChangedEvent = "peof.organization.CompanyNameChanged"
)
View Source
const (
	EventTypeKey      = "eventType"
	EventVersionKey   = "eventVersion"
	EventTimestampKey = "eventTimestamp"
	AggregateIdKey    = "aggregateId"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Aggregate

type Aggregate interface {
	Events() []Event
}
aggregates accumulate domain events generated by business logic execution

following the execution of business logic these events should be stored as an event log and dispatched as messages to other interested parties

type Company

type Company struct {
	Id   string
	Name string
	// contains filtered or unexported fields
}

func (*Company) ChangeName

func (c *Company) ChangeName(name string)

func (*Company) Create

func (c *Company) Create(name string)

func (*Company) Events

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

func (*Company) From

func (c *Company) From(events []Event) *Company

type CompanyCreated

type CompanyCreated struct {
	EventRoot   `bson:",inline"`
	CompanyName string `bson:"companyName" json:"companyName"`
}

func (CompanyCreated) FromMap

func (e CompanyCreated) FromMap(mapEvent map[string]interface{}) Event

func (CompanyCreated) Root

func (e CompanyCreated) Root() EventRoot

type CompanyNameChanged

type CompanyNameChanged struct {
	EventRoot   `bson:",inline"`
	CompanyName string `bson:"companyName" json:"companyName"`
}

func (CompanyNameChanged) FromMap

func (e CompanyNameChanged) FromMap(mapEvent map[string]interface{}) Event

func (CompanyNameChanged) Root

func (e CompanyNameChanged) Root() EventRoot

type Event

type Event interface {
	Root() EventRoot
	FromMap(mapEvent map[string]interface{}) Event
}

domain events provide access to common root properties

type EventPublisher

type EventPublisher interface {
	Dispatch(events []Event) (err error)
}

domain event dispatcher

type EventRoot

type EventRoot struct {
	EventType   string  `bson:"eventType" json:"eventType"`
	Version     float32 `bson:"eventVersrsionion" json:"eventVe"`
	Timestamp   int64   `bson:"eventTimestamp" json:"eventTimestamp"`
	AggregateId string  `bson:"aggregateId" json:"aggregateId"`
}

domain events have these root properties

func (EventRoot) FromMap

func (e EventRoot) FromMap(mapEvent map[string]interface{}) Event

func (EventRoot) Root

func (e EventRoot) Root() EventRoot

type EventStore

type EventStore interface {
	Append(events []Event, aggregateType string) (err error)
	EventsOf(aggregateId string, aggregateType string) (err error, events []map[string]interface{})
}

append only domain event store

Jump to

Keyboard shortcuts

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