Skip to content

Commit cda8a19

Browse files
committed
transport: Allow registering implementations for a URL scheme
1 parent 62f3c5a commit cda8a19

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,13 @@ You can enable (all) logging using:
6767

6868
export DEBUG=msgflo*
6969

70+
## Supporting other transports
71+
72+
msgflo-nodejs has a transport abstraction layer. So to support a new messaging system,
73+
implement `Client` and `MessageBroker` [interfaces](./src/interfaces.coffee).
74+
75+
You can then pass these into a `Participant`.
76+
77+
Or you can use `msgflo.transport.register('mytransport', myTransportModule)`, and then `msgflo.transport.getClient('mysystem://somehost:666')`.
78+
This will also work for specifying `msgflo-nodejs --broker` and for `MSGFLO_BROKER=` environment variable.
79+

src/transport.coffee

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@ exports.getBroker = (address, options) ->
1717
scheme = address.split('://')[0]
1818
throw new Error 'Unsupported scheme: ' + scheme if not supportsScheme scheme
1919
return new transports[scheme].MessageBroker address, options
20+
21+
# @module: Must have Client and MessageBroker constructors, implementing these interfaces
22+
export.register = (scheme, module) ->
23+
transports[scheme] = module

0 commit comments

Comments
 (0)