@node-ts/bus-core
Advanced tools
Comparing version 0.1.12 to 0.1.13
import { Event, Command } from '@node-ts/bus-messages'; | ||
import { TransportMessage } from './transport-message'; | ||
import { HandlerRegistry } from '../handler'; | ||
/** | ||
* A transport adapter interface that enables the service bus to use a messaging technology. | ||
*/ | ||
export interface Transport<TransportMessageType = {}> { | ||
/** | ||
* Publishes an event to the underlying transport. This is generally done to a topic or some other | ||
* mechanism that consumers can subscribe themselves to | ||
* @param event A domain event to be published | ||
*/ | ||
publish<TEvent extends Event>(event: TEvent): Promise<void>; | ||
/** | ||
* Sends a command to the underlying transport. This is generally done to a topic or some other | ||
* mechanism that consumers can subscribe themselves to | ||
* @param command A domain command to be sent | ||
*/ | ||
send<TCommand extends Command>(command: TCommand): Promise<void>; | ||
/** | ||
* Fetch the next message from the underlying queue. If there are no messages, then `undefined` | ||
* should be returned. | ||
* | ||
* @returns The message construct from the underlying transport, that inclues both the raw message envelope | ||
* plus the contents or body that contains the `@node-ts/bus-messages` message. | ||
*/ | ||
readNextMessage(): Promise<TransportMessage<TransportMessageType> | undefined>; | ||
/** | ||
* Removes a message from the underlying transport. This will be called once a message has been | ||
* successfully handled by any of the message handling functions. | ||
* @param message The message to be removed from the transport | ||
*/ | ||
deleteMessage(message: TransportMessage<TransportMessageType>): Promise<void>; | ||
/** | ||
* Returns a message to the queue for retry. This will be called if an error was thrown when | ||
* trying to process a message. | ||
* @param message The message to be returned to the queue for reprocessing | ||
*/ | ||
returnMessage(message: TransportMessage<TransportMessageType>): Promise<void>; | ||
/** | ||
* An optional function that will be called when the service bus is starting. This is an | ||
* opportunity for the transport to see what messages need to be handled so that subscriptions | ||
* to the topics can be created. | ||
* @param handlerRegistry The list of messages being handled by the bus that the transport needs to subscribe to. | ||
*/ | ||
initialize?(handlerRegistry: HandlerRegistry): Promise<void>; | ||
/** | ||
* An optional function that will be called when the service bus is shutting down. This is an | ||
* opportunity for the transport to close out any open requests to fetch messages etc. | ||
*/ | ||
dispose?(): Promise<void>; | ||
} |
{ | ||
"name": "@node-ts/bus-core", | ||
"version": "0.1.12", | ||
"version": "0.1.13", | ||
"description": "A message bus abstraction to build simple distributed applications in Node.", | ||
@@ -47,3 +47,3 @@ "main": "./dist/index.js", | ||
], | ||
"gitHead": "465c48eaf15495aa61b9bdb6bc2aac48f39629e9" | ||
"gitHead": "d32f3f632ea0f242333bc518325812dbad4e9aff" | ||
} |
@@ -5,10 +5,56 @@ import { Event, Command } from '@node-ts/bus-messages' | ||
/** | ||
* A transport adapter interface that enables the service bus to use a messaging technology. | ||
*/ | ||
export interface Transport<TransportMessageType = {}> { | ||
/** | ||
* Publishes an event to the underlying transport. This is generally done to a topic or some other | ||
* mechanism that consumers can subscribe themselves to | ||
* @param event A domain event to be published | ||
*/ | ||
publish<TEvent extends Event> (event: TEvent): Promise<void> | ||
/** | ||
* Sends a command to the underlying transport. This is generally done to a topic or some other | ||
* mechanism that consumers can subscribe themselves to | ||
* @param command A domain command to be sent | ||
*/ | ||
send<TCommand extends Command> (command: TCommand): Promise<void> | ||
/** | ||
* Fetch the next message from the underlying queue. If there are no messages, then `undefined` | ||
* should be returned. | ||
* | ||
* @returns The message construct from the underlying transport, that inclues both the raw message envelope | ||
* plus the contents or body that contains the `@node-ts/bus-messages` message. | ||
*/ | ||
readNextMessage (): Promise<TransportMessage<TransportMessageType> | undefined> | ||
/** | ||
* Removes a message from the underlying transport. This will be called once a message has been | ||
* successfully handled by any of the message handling functions. | ||
* @param message The message to be removed from the transport | ||
*/ | ||
deleteMessage (message: TransportMessage<TransportMessageType>): Promise<void> | ||
/** | ||
* Returns a message to the queue for retry. This will be called if an error was thrown when | ||
* trying to process a message. | ||
* @param message The message to be returned to the queue for reprocessing | ||
*/ | ||
returnMessage (message: TransportMessage<TransportMessageType>): Promise<void> | ||
/** | ||
* An optional function that will be called when the service bus is starting. This is an | ||
* opportunity for the transport to see what messages need to be handled so that subscriptions | ||
* to the topics can be created. | ||
* @param handlerRegistry The list of messages being handled by the bus that the transport needs to subscribe to. | ||
*/ | ||
initialize? (handlerRegistry: HandlerRegistry): Promise<void> | ||
/** | ||
* An optional function that will be called when the service bus is shutting down. This is an | ||
* opportunity for the transport to close out any open requests to fetch messages etc. | ||
*/ | ||
dispose? (): Promise<void> | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
102204
107
1907