ddd

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: MIT Imports: 2 Imported by: 0

README

design pattern

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Aggregate

type Aggregate[T any, ID any] interface {
	Root() Entity[T, ID]
}

type AggregateRoot

type AggregateRoot interface {
}

type DomainEvent

type DomainEvent[T any, ID any] interface {

	// SameEventAs return true if the given domain event and this event are regarded as being the same event.
	SameEventAs(other T) bool

	ID() ID
	Kind() string
	When() time.Time
}

DomainEvent is something that is unique, but does not have a lifecycle. The identity may be explicit, for example the sequence number of a payment, or it could be derived from various aspects of the event such as where, when and what has happened.

type Entity

type Entity[T any, ID any] interface {

	// SameIdentityAs return true if the identities are the same, regardless of other attributes.
	SameIdentityAs(other T) bool

	// Identity return the identity of this entity.
	Identity() ID
}

Entity as explained in the DDD book. Entities compare by identity, not by attributes.

type EventDescriptor added in v1.2.1

type EventDescriptor struct {
	ID         int64
	Body       string
	OccurredAt time.Time
	Kind       string
}

func EventDescriptorFromEvent added in v1.2.1

func EventDescriptorFromEvent[T any, ID any](e DomainEvent[T, ID]) *EventDescriptor

func NewEventDescriptor added in v1.2.1

func NewEventDescriptor(body string, occurredAt time.Time, kind string) *EventDescriptor

type ValueObject

type ValueObject[T any] interface {

	// SameValueAs return ture if the given value object's and this value object's attributes are the same.
	SameValueAs(other T) bool

	// Copy return A safe, deep copy of this value object.
	Copy() T
}

ValueObject as described in the DDD book. Value objects compare by the values of their attributes, they don't have an identity.

Jump to

Keyboard shortcuts

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