domain

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package domain contains the business logic for the banking application.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountHandler

type AccountHandler struct{}

AccountHandler implements the business logic for a bank account.

It centralizes all transactions that are applied to an account in order to enforce a strict no-overdraw policy.

func (AccountHandler) Configure

Configure configures the behavior of the engine as it relates to this handler.

func (AccountHandler) HandleCommand

func (AccountHandler) HandleCommand(
	a *account,
	s dogma.AggregateCommandScope[*account],
	m dogma.Command,
)

HandleCommand handles a command message that has been routed to this handler.

func (AccountHandler) New

func (AccountHandler) New() *account

New returns a new account instance.

func (AccountHandler) RouteCommandToInstance

func (AccountHandler) RouteCommandToInstance(m dogma.Command) string

RouteCommandToInstance returns the ID of the aggregate instance that is targetted by m.

type CustomerHandler

type CustomerHandler struct{}

CustomerHandler implements the business logic for a bank customer.

func (CustomerHandler) Configure

Configure configures the behavior of the engine as it relates to this handler.

func (CustomerHandler) HandleCommand

func (CustomerHandler) HandleCommand(
	c *customer,
	s dogma.AggregateCommandScope[*customer],
	m dogma.Command,
)

HandleCommand handles a command message that has been routed to this handler.

func (CustomerHandler) New

func (CustomerHandler) New() *customer

New returns a new customer instance.

func (CustomerHandler) RouteCommandToInstance

func (CustomerHandler) RouteCommandToInstance(m dogma.Command) string

RouteCommandToInstance returns the ID of the aggregate instance that is targetted by m.

type DailyDebitLimitHandler

type DailyDebitLimitHandler struct{}

DailyDebitLimitHandler implements the business logic for an account daily debit limit policy.

It centralizes all debits that are applied to an account over a calendar day in order to enforce a policy of limited daily debits.

func (DailyDebitLimitHandler) Configure

Configure configures the behaviour of the engine as it relates to this handler.

func (DailyDebitLimitHandler) HandleCommand

func (DailyDebitLimitHandler) HandleCommand(
	d *dailyDebitLimit,
	s dogma.AggregateCommandScope[*dailyDebitLimit],
	m dogma.Command,
)

HandleCommand handles a command message that has been routed to this handler.

func (DailyDebitLimitHandler) New

func (DailyDebitLimitHandler) New() *dailyDebitLimit

New returns a new daily debit limit instance.

func (DailyDebitLimitHandler) RouteCommandToInstance

func (DailyDebitLimitHandler) RouteCommandToInstance(m dogma.Command) string

RouteCommandToInstance returns the ID of the aggregate instance that is targetted by m.

type DepositProcessHandler

DepositProcessHandler manages the process of depositing funds into an account.

func (DepositProcessHandler) Configure

Configure configures the behavior of the engine as it relates to this handler.

func (DepositProcessHandler) HandleEvent

HandleEvent handles an event message that has been routed to this handler.

func (DepositProcessHandler) RouteEventToInstance

func (DepositProcessHandler) RouteEventToInstance(
	_ context.Context,
	m dogma.Event,
) (string, bool, error)

RouteEventToInstance returns the ID of the process instance that is targeted by m.

type OpenAccountForNewCustomerProcessHandler

type OpenAccountForNewCustomerProcessHandler struct {
	dogma.StatelessProcessBehavior
	dogma.NoDeadlineMessagesBehavior[*dogma.StatelessProcessRoot]
}

OpenAccountForNewCustomerProcessHandler manages the process of opening the initial account for a new customer.

func (OpenAccountForNewCustomerProcessHandler) Configure

Configure configures the behavior of the engine as it relates to this handler.

func (OpenAccountForNewCustomerProcessHandler) HandleEvent

HandleEvent handles an event message that has been routed to this handler.

func (OpenAccountForNewCustomerProcessHandler) RouteEventToInstance

RouteEventToInstance returns the ID of the process instance that is targetted by m.

type TransactionHandler

type TransactionHandler struct{}

TransactionHandler implements the business logic for a transaction of any kind against an account.

It's sole purpose is to ensure the global uniqueness of transaction IDs.

func (TransactionHandler) Configure

Configure configures the behavior of the engine as it relates to this handler.

func (TransactionHandler) HandleCommand

func (TransactionHandler) HandleCommand(
	t *transaction,
	s dogma.AggregateCommandScope[*transaction],
	m dogma.Command,
)

HandleCommand handles a command message that has been routed to this handler.

func (TransactionHandler) New

func (TransactionHandler) New() *transaction

New returns a new transaction instance.

func (TransactionHandler) RouteCommandToInstance

func (TransactionHandler) RouteCommandToInstance(m dogma.Command) string

RouteCommandToInstance returns the ID of the aggregate instance that is targetted by m.

type TransferProcessHandler

type TransferProcessHandler struct{}

TransferProcessHandler manages the process of transferring funds between accounts.

func (TransferProcessHandler) Configure

Configure configures the behavior of the engine as it relates to this handler.

func (TransferProcessHandler) HandleDeadline

func (TransferProcessHandler) HandleDeadline(
	_ context.Context,
	t *transferProcess,
	s dogma.ProcessDeadlineScope[*transferProcess],
	m dogma.Deadline,
) error

HandleDeadline handles a deadline message that has been routed to this handler.

func (TransferProcessHandler) HandleEvent

func (TransferProcessHandler) HandleEvent(
	_ context.Context,
	t *transferProcess,
	s dogma.ProcessEventScope[*transferProcess],
	m dogma.Event,
) error

HandleEvent handles an event message that has been routed to this handler.

func (TransferProcessHandler) New

func (TransferProcessHandler) New() *transferProcess

New returns a new transfer instance.

func (TransferProcessHandler) RouteEventToInstance

func (TransferProcessHandler) RouteEventToInstance(
	_ context.Context,
	m dogma.Event,
) (string, bool, error)

RouteEventToInstance returns the ID of the process instance that is targeted by m.

type TransferReadyToProceed

type TransferReadyToProceed struct {
	TransactionID string
}

TransferReadyToProceed is a deadline message notifying that the transfer is ready to proceed.

func (*TransferReadyToProceed) MarshalBinary

func (m *TransferReadyToProceed) MarshalBinary() ([]byte, error)

MarshalBinary returns a binary representation of the message. For simplicity in this example we use JSON.

func (*TransferReadyToProceed) MessageDescription

func (m *TransferReadyToProceed) MessageDescription() string

MessageDescription returns a human-readable description of the message.

func (*TransferReadyToProceed) UnmarshalBinary

func (m *TransferReadyToProceed) UnmarshalBinary(data []byte) error

UnmarshalBinary populates the message from its binary representation. For simplicity in this example we use JSON.

func (*TransferReadyToProceed) Validate

Validate returns a non-nil error if the message is invalid.

type WithdrawalProcessHandler

WithdrawalProcessHandler manages the process of withdrawing funds from an account.

func (WithdrawalProcessHandler) Configure

Configure configures the behavior of the engine as it relates to this handler.

func (WithdrawalProcessHandler) HandleEvent

HandleEvent handles an event message that has been routed to this handler.

func (WithdrawalProcessHandler) RouteEventToInstance

func (WithdrawalProcessHandler) RouteEventToInstance(
	_ context.Context,
	m dogma.Event,
) (string, bool, error)

RouteEventToInstance returns the ID of the process instance that is targetted by m.

Jump to

Keyboard shortcuts

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