We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Abstractions that should be provided:
Should be generic. Users should be able to provide message and response types.
export abstract class Command<T, R> { // ... }
The Command can be executed in a way that is more approach you or convenient from the client's perspective.
Command
await new Command<T, R>(/*parameters*/).execute(dispatcher); await dispatcher.execute(await new Command<T, R>(/*parameters*/));
Should be generic. Users should be able to provide message type. To get the Event publishing result users should register Handler.
Event
Handler
export abstract class Event<T> { // ... }
The Event can be executed in a way that is more approach you or convenient from the client's perspective.
await new Event <T>(/*parameters*/).publish(dispatcher); await dispatcher.publish(await new Event<T>(/*parameters*/));
Users can use CommandDispatcher to synchronously execute commands
CommandDispatcher
export interface CommandDispatcher { execute<T, R>(command: Command<T, R>): Promise<R | undefined>; }
Users can use EventDispatcher to asynchronously publish events
EventDispatcher
export interface EventDispatcher { publish<T>(event: Event<T>): Promise<void>; }
Users can use Handler to handle events dispatched from the application
export interface Handler<T, R> { handle(argument: T): Promise<R>; }
Users can be able to use retries in the case when the connection is lost
export interface RetryStrategy { acquire<T extends (...args: unknown[]) => unknown>( task: T ): Promise<ReturnType<T>>; }
Users can use EventBus to communicate between the service. EventBus should extend from EventDispatcher and CommandDispatcher
EventBus
export interface EventBus extends EventDispatcher, CommandDispatcher { register<T extends Event<R>, R>( type: new (...args: unknown[]) => EventHandler<T> ): Promise<void>; unregister<T extends Event<R>, R>( type: new (...args: unknown[]) => EventHandler<T> ): Promise<void>; init?(): Promise<void>; destroy?(): Promise<void>; }
The text was updated successfully, but these errors were encountered:
feat(core): provide message abstractions (#12)
6e44b1f
closes #11
feat(core): introduce the event constructor type
b7c3b53
RomanReznichenko
Successfully merging a pull request may close this issue.
Abstractions that should be provided:
Command
Should be generic. Users should be able to provide message and response types.
The
Command
can be executed in a way that is more approach you or convenient from the client's perspective.Event
Should be generic. Users should be able to provide message type. To get the
Event
publishing result users should registerHandler
.The
Event
can be executed in a way that is more approach you or convenient from the client's perspective.CommandDispatcher
Users can use
CommandDispatcher
to synchronously execute commandsEventDispatcher
Users can use
EventDispatcher
to asynchronously publish eventsHandler
Users can use
Handler
to handle events dispatched from the applicationRetryStrategy
Users can be able to use retries in the case when the connection is lost
EventBus
Users can use
EventBus
to communicate between the service.EventBus
should extend fromEventDispatcher
andCommandDispatcher
The text was updated successfully, but these errors were encountered: