Router
Hierarchy
- Router
Implements
- Router
- Router
Index
Constructors
Properties
Methods
- handleSaveErrors
- initialize
- initializingMessageHandler
- isInitializable
- messageHandler
- setupCommandHandler
- setupEventHandler
Constructors
constructor
+ new Router(EventSourceableType?
: EventSourceableType, InitializingMessageType?
: MessageType‹Command | Event›, routedCommands?
: MessageType‹Command›[], routedEvents?
: MessageType‹Event›[]): Router
Creates an instance of Router. Creates an instance of Router.
Parameters:
Name | Type | Description |
---|---|---|
EventSourceableType? | EventSourceableType | EventSourceable type(constructor) for routing. |
InitializingMessageType? | MessageType‹Command | Event› | Initializing message of event sourceable. |
routedCommands? | MessageType‹Command›[] | Optional routed commands. |
routedEvents? | MessageType‹Event›[] | Optional routed events. |
Returns: Router
Properties
EventSourceableType
• EventSourceableType: EventSourceableType
Implementation of Router.EventSourceableType
InitializingMessageType
• InitializingMessageType: MessageType‹Command | Event›
Implementation of Router.InitializingMessageType
injector
• injector: Injector
routedCommands
• routedCommands: MessageType‹Command›[]
Implementation of Router.routedCommands
routedEvents
• routedEvents: MessageType‹Event›[]
Implementation of Router.routedEvents
Methods
handleSaveErrors
▸ handleSaveErrors(error
: Error, message
: Command | Event, eventSourceableId
: string | Guid): Promise‹void›
Handles errors related to persisting event sourceable.
async
throws
{Error}
Thrown if the error is not a instance of CommitConcurrencyError
.
Parameters:
Name | Type | Description |
---|---|---|
error | Error | Instance of Error not related to domain. |
message | Command | Event | Instance of Command or Event . |
eventSourceableId | string | Guid | Event sourceable identifier as string or instance of Guid |
Returns: Promise‹void›
initialize
▸ initialize(): void
Implementation of Router
Initializes Router.
throws
{MissingEventSourceableError}
Thrown if events sourceable is not set on router.
throws
{MissingInitializingMessageError}
Thrown if initializing message is not set on router and can't be resolved from
event sourceable.
Returns: void
initializingMessageHandler
▸ initializingMessageHandler(message
: Command | Event): Promise‹void›
Initializing message handler.
async
throws
{Error}
Thrown if non-DomainError or CommitConcurrencyError is thrown on event
sourceable message handler.
Parameters:
Name | Type | Description |
---|---|---|
message | Command | Event | Instance of Command or Event . |
Returns: Promise‹void›
isInitializable
▸ isInitializable(eventSourceableId
: string | Guid): Promise‹boolean›
Evaluates whether identifier already exists.
async
Parameters:
Name | Type | Description |
---|---|---|
eventSourceableId | string | Guid | Identifier as string or Guid instance. |
Returns: Promise‹boolean›
Returns true
if identifier is initializable(does not exists), else false
.
messageHandler
▸ messageHandler(message
: Command | Event): Promise‹void›
Default message handler.
async
throws
{Error} Will throw an error if error is thrown on event sourceable message handler and is not a DomainError or
CommitConcurrencyError error type.
Parameters:
Name | Type | Description |
---|---|---|
message | Command | Event | Instance of Command or Event . |
Returns: Promise‹void›
setupCommandHandler
▸ setupCommandHandler(CommandType
: MessageType‹Command›): void
Implementation of Router
Registers default message handler for routed command on command bus.
Parameters:
Name | Type | Description |
---|---|---|
CommandType | MessageType‹Command› | Command type constructor. |
Returns: void
setupEventHandler
▸ setupEventHandler(EventType
: MessageType‹Event›): void
Implementation of Router
Registers default message handler for routed event on event bus.
Parameters:
Name | Type | Description |
---|---|---|
EventType | MessageType‹Event› | Event type constructor. |
Returns: void