fact

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2025 License: MIT Imports: 9 Imported by: 1

Documentation

Overview

Package fact contains structures that represents internal engine events. They are named facts to prevent ambiguity with Dogma application events.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AggregateInstanceCreated

type AggregateInstanceCreated struct {
	Handler    *config.Aggregate
	InstanceID string
	Root       dogma.AggregateRoot
	Envelope   *envelope.Envelope
}

AggregateInstanceCreated indicates that an aggregate message handler created an aggregate instance while handling a command.

type AggregateInstanceLoaded

type AggregateInstanceLoaded struct {
	Handler    *config.Aggregate
	InstanceID string
	Root       dogma.AggregateRoot
	Envelope   *envelope.Envelope
}

AggregateInstanceLoaded indicates that an aggregate message handler has loaded an existing instance in order to handle a command.

type AggregateInstanceNotFound

type AggregateInstanceNotFound struct {
	Handler    *config.Aggregate
	InstanceID string
	Envelope   *envelope.Envelope
}

AggregateInstanceNotFound indicates that an aggregate message handler was unable to load an existing instance while handling a command.

type Buffer

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

Buffer is an Observer that buffers facts in-memory.

It may be used by multiple goroutines simultaneously.

func (*Buffer) Facts

func (b *Buffer) Facts() []Fact

Facts returns the facts that have been buffered so far.

func (*Buffer) Notify

func (b *Buffer) Notify(f Fact)

Notify appends f to b.Facts.

type CommandExecutedByProcess

type CommandExecutedByProcess struct {
	Handler         *config.Process
	InstanceID      string
	Root            dogma.ProcessRoot
	Envelope        *envelope.Envelope
	CommandEnvelope *envelope.Envelope
}

CommandExecutedByProcess indicates that a process executed a command while handling an event or timeout.

type DispatchBegun

type DispatchBegun struct {
	Envelope *envelope.Envelope
}

DispatchBegun indicates that Engine.Dispatch() has been called with a message that is able to be routed to at least one handler.

type DispatchCompleted

type DispatchCompleted struct {
	Envelope *envelope.Envelope
	Error    error
}

DispatchCompleted indicates that a call Engine.Dispatch() has completed.

type DispatchCycleBegun

type DispatchCycleBegun struct {
	Envelope            *envelope.Envelope
	EngineTime          time.Time
	EnabledHandlerTypes map[config.HandlerType]bool
	EnabledHandlers     map[string]bool
}

DispatchCycleBegun indicates that Engine.Dispatch() has been called with a message that is able to be routed to at least one handler.

type DispatchCycleCompleted

type DispatchCycleCompleted struct {
	Envelope            *envelope.Envelope
	Error               error
	EnabledHandlerTypes map[config.HandlerType]bool
	EnabledHandlers     map[string]bool
}

DispatchCycleCompleted indicates that a call Engine.Dispatch() has completed.

type EventRecordedByAggregate

type EventRecordedByAggregate struct {
	Handler       *config.Aggregate
	InstanceID    string
	Root          dogma.AggregateRoot
	Envelope      *envelope.Envelope
	EventEnvelope *envelope.Envelope
}

EventRecordedByAggregate indicates that an aggregate recorded an event while handling a command.

type EventRecordedByIntegration

type EventRecordedByIntegration struct {
	Handler       *config.Integration
	Envelope      *envelope.Envelope
	EventEnvelope *envelope.Envelope
}

EventRecordedByIntegration indicates that an integration recorded an event while handling a command.

type Fact

type Fact interface {
}

Fact is an interface for internal engine events that occur while handling Dogma messages.

type HandlerSkipReason

type HandlerSkipReason byte

HandlerSkipReason is an enumeration of the reasons a handler can be skipped while dispatching a message or ticking.

const (
	// HandlerTypeDisabled indicates that a handler was skipped because all
	// handlers of that type have been disabled using an engine option.
	HandlerTypeDisabled HandlerSkipReason = 'T'

	// IndividualHandlerDisabled indicates that a handler was skipped because
	// that specific handler was disabled using an engine option.
	IndividualHandlerDisabled HandlerSkipReason = 'I'

	// IndividualHandlerDisabledByConfiguration indicates that a handler was
	// skipped because it was disabled by a call to Disable() in its Configure()
	// method.
	IndividualHandlerDisabledByConfiguration HandlerSkipReason = 'C'
)

type HandlingBegun

type HandlingBegun struct {
	Handler  config.Handler
	Envelope *envelope.Envelope
}

HandlingBegun indicates that a message is about to be handled by a specific handler.

type HandlingCompleted

type HandlingCompleted struct {
	Handler  config.Handler
	Envelope *envelope.Envelope
	Error    error
}

HandlingCompleted indicates that a message has been handled by a specific handler, either successfully or unsuccessfully.

type HandlingSkipped

type HandlingSkipped struct {
	Handler  config.Handler
	Envelope *envelope.Envelope
	Reason   HandlerSkipReason
}

HandlingSkipped indicates that a message has been not been handled by a specific handler, either because all handlers of that type are or the handler itself is disabled.

type Logger

type Logger struct {
	Log func(string)
}

Logger is an observer that logs human-readable messages to a log function.

func NewLogger

func NewLogger(log func(string)) *Logger

NewLogger returns a new observer that logs human-readable descriptions of facts to the given log function.

func (*Logger) Notify

func (l *Logger) Notify(f Fact)

Notify the observer of a fact.generates the log message for f.

type MessageLoggedByAggregate

type MessageLoggedByAggregate struct {
	Handler      *config.Aggregate
	InstanceID   string
	Root         dogma.AggregateRoot
	Envelope     *envelope.Envelope
	LogFormat    string
	LogArguments []any
}

MessageLoggedByAggregate indicates that an aggregate wrote a log message while handling a command.

type MessageLoggedByIntegration

type MessageLoggedByIntegration struct {
	Handler      *config.Integration
	Envelope     *envelope.Envelope
	LogFormat    string
	LogArguments []any
}

MessageLoggedByIntegration indicates that an integration wrote a log message while handling a command.

type MessageLoggedByProcess

type MessageLoggedByProcess struct {
	Handler      *config.Process
	InstanceID   string
	Root         dogma.ProcessRoot
	Envelope     *envelope.Envelope
	LogFormat    string
	LogArguments []any
}

MessageLoggedByProcess indicates that a process wrote a log message while handling an event or timeout.

type MessageLoggedByProjection

type MessageLoggedByProjection struct {
	Handler      *config.Projection
	Envelope     *envelope.Envelope
	LogFormat    string
	LogArguments []any
}

MessageLoggedByProjection indicates that a projection wrote a log message while handling an event or compacting the projection.

Envelope is nil if the message was logged during compaction.

type Observer

type Observer interface {
	// Notify the observer of a fact.
	Notify(Fact)
}

Observer is an interface that is notified when facts are recorded.

type ObserverFunc

type ObserverFunc func(Fact)

ObserverFunc is an adaptor to allow the use of a regular function as an observer.

If f is a function with the appropriate signature, ObserverFunc(f) is an Observer that calls f.

var Ignore ObserverFunc = func(Fact) {}

Ignore is an observer that ignores fact notifications.

func (ObserverFunc) Notify

func (fn ObserverFunc) Notify(f Fact)

Notify calls fn(f).

type ObserverGroup

type ObserverGroup []Observer

ObserverGroup is a collection of observers that can be notified as a group.

func (ObserverGroup) Notify

func (s ObserverGroup) Notify(f Fact)

Notify notifies all of the observers in the set of each of the given fact.

type ProcessEventIgnored

type ProcessEventIgnored struct {
	Handler  *config.Process
	Envelope *envelope.Envelope
}

ProcessEventIgnored indicates that a process message handler chose not to route an event to any instance.

type ProcessEventRoutedToEndedInstance added in v0.19.0

type ProcessEventRoutedToEndedInstance struct {
	Handler    *config.Process
	InstanceID string
	Envelope   *envelope.Envelope
}

ProcessEventRoutedToEndedInstance indicates that a process message handler ignored an event message because it was routed to an instance that no longer exists.

type ProcessInstanceBegun

type ProcessInstanceBegun struct {
	Handler    *config.Process
	InstanceID string
	Root       dogma.ProcessRoot
	Envelope   *envelope.Envelope
}

ProcessInstanceBegun indicates that a process message handler began a process instance while handling an event.

type ProcessInstanceEnded

type ProcessInstanceEnded struct {
	Handler    *config.Process
	InstanceID string
	Root       dogma.ProcessRoot
	Envelope   *envelope.Envelope
}

ProcessInstanceEnded indicates that a process message handler destroyed a process instance while handling an event or timeout.

type ProcessInstanceEndingReverted added in v0.13.0

type ProcessInstanceEndingReverted struct {
	Handler    *config.Process
	InstanceID string
	Root       dogma.ProcessRoot
	Envelope   *envelope.Envelope
}

ProcessInstanceEndingReverted indicates that a process message handler "reverted" ending a process instance by executing a new command or scheduling a new timeout.

type ProcessInstanceLoaded

type ProcessInstanceLoaded struct {
	Handler    *config.Process
	InstanceID string
	Root       dogma.ProcessRoot
	Envelope   *envelope.Envelope
}

ProcessInstanceLoaded indicates that a process message handler has loaded an existing instance in order to handle an event or timeout.

type ProcessInstanceNotFound

type ProcessInstanceNotFound struct {
	Handler    *config.Process
	InstanceID string
	Envelope   *envelope.Envelope
}

ProcessInstanceNotFound indicates that a process message handler was unable to load an existing instance while handling an event or timeout.

type ProcessTimeoutRoutedToEndedInstance added in v0.19.0

type ProcessTimeoutRoutedToEndedInstance struct {
	Handler    *config.Process
	InstanceID string
	Envelope   *envelope.Envelope
}

ProcessTimeoutRoutedToEndedInstance indicates that a process message handler ignored a timeout message because its instance no longer exists.

type ProjectionCompactionBegun

type ProjectionCompactionBegun struct {
	Handler *config.Projection
}

ProjectionCompactionBegun indicates that a projection is about to be compacted.

type ProjectionCompactionCompleted

type ProjectionCompactionCompleted struct {
	Handler *config.Projection
	Error   error
}

ProjectionCompactionCompleted indicates that projection compaction has been performed, either successfully or unsuccessfully.

type TickBegun

type TickBegun struct {
	Handler config.Handler
}

TickBegun indicates that a call to Controller.Tick() is being made.

type TickCompleted

type TickCompleted struct {
	Handler config.Handler
	Error   error
}

TickCompleted indicates that a call to Controller.Tick() has completed.

type TickCycleBegun

type TickCycleBegun struct {
	EngineTime          time.Time
	EnabledHandlerTypes map[config.HandlerType]bool
	EnabledHandlers     map[string]bool
}

TickCycleBegun indicates that Engine.Tick() has been called.

type TickCycleCompleted

type TickCycleCompleted struct {
	Error               error
	EnabledHandlerTypes map[config.HandlerType]bool
	EnabledHandlers     map[string]bool
}

TickCycleCompleted indicates that a call Engine.Tick() has completed.

type TickSkipped

type TickSkipped struct {
	Handler config.Handler
	Reason  HandlerSkipReason
}

TickSkipped indicates that a call to Controller.Tick() has been skipped.

type TimeoutScheduledByProcess

type TimeoutScheduledByProcess struct {
	Handler         *config.Process
	InstanceID      string
	Root            dogma.ProcessRoot
	Envelope        *envelope.Envelope
	TimeoutEnvelope *envelope.Envelope
}

TimeoutScheduledByProcess indicates that a process scheduled a timeout while handling an event or timeout.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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