Documentation
¶
Overview ¶
Package conversion handles currency conversion events and persistence logic.
Package conversion handles currency conversion events and logic.
Index ¶
- func HandleCurrencyConverted(uow repository.UnitOfWork, logger *slog.Logger) func(context.Context, events.Event) error
- func HandleRequested(bus eventbus.Bus, exchangeRegistry registry.Provider, ...) func(ctx context.Context, e events.Event) error
- func NewValidConversionInfo(fromCurrency, toCurrency string, rateValue float64) *exchange.RateInfo
- func NewValidConversionRequestedEvent(flow events.FlowEvent, transactionID uuid.UUID, amount money.Money, to string) *events.CurrencyConversionRequested
- type DepositEventFactory
- type EventFactory
- type TransferEventFactory
- type WithdrawEventFactory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandleCurrencyConverted ¶
func HandleCurrencyConverted( uow repository.UnitOfWork, logger *slog.Logger) func( context.Context, events.Event, ) error
HandleCurrencyConverted persists CurrencyConverted events.
func HandleRequested ¶
func HandleRequested( bus eventbus.Bus, exchangeRegistry registry.Provider, exchangeRateProvider exchangeprovider.Exchange, logger *slog.Logger, factories map[string]EventFactory, ) func(ctx context.Context, e events.Event) error
HandleRequested processes ConversionRequestedEvent and delegates to a flow-specific factory to create the next event.
Types ¶
type DepositEventFactory ¶
type DepositEventFactory struct{}
DepositEventFactory creates a DepositCurrencyConverted event from a CurrencyConverted event.
func (*DepositEventFactory) CreateNextEvent ¶
func (f *DepositEventFactory) CreateNextEvent( cc *events.CurrencyConverted, ) events.Event
CreateNextEvent creates DepositCurrencyConverted with converted event
type EventFactory ¶
type EventFactory interface {
// CreateNextEvent creates and returns the event that should be
// emitted after a successful currency conversion.
// It takes a CurrencyConverted event that contains all the necessary information
// including the converted amount to create the next event in the flow.
CreateNextEvent(cc *events.CurrencyConverted) events.Event
}
EventFactory defines the interface for creating the next event after a currency conversion. Each business flow (deposit, withdraw, etc.) will have its own implementation of this factory to construct the appropriate flow-specific event after currency conversion.
type TransferEventFactory ¶
type TransferEventFactory struct{}
TransferEventFactory creates a TransferCurrencyConverted event from a CurrencyConverted event.
func (*TransferEventFactory) CreateNextEvent ¶
func (f *TransferEventFactory) CreateNextEvent( cc *events.CurrencyConverted, ) events.Event
CreateNextEvent creates TransferCurrencyConverted with converted event
type WithdrawEventFactory ¶
type WithdrawEventFactory struct{}
WithdrawEventFactory creates a WithdrawCurrencyConverted event from a CurrencyConverted event.
func (*WithdrawEventFactory) CreateNextEvent ¶
func (f *WithdrawEventFactory) CreateNextEvent( cc *events.CurrencyConverted, ) events.Event
CreateNextEvent creates WithdrawCurrencyConverted with converted event