hansa
Create leagues of Argosy micro-services; connected via pipes.
example
var argosy = hansa = var service1 = service2 = client = league = service1accept greet: argosypatternmatchstring service2accept max: argosypatternmatcharray league
api
var league =
league.connect(argosyEndpoint)
Connect an Argosy endpoint to the league
. This is a convenience function that does for you:
var port = leagueportargosyEndpoint
In addition it maintains relationship between endpoint and port to make disconnection easier. Attempting to connect the same endpoint twice will have no effect.
league.disconnect(argosyEndpoint)
Disconnect an Argosy endpoint from the league
. This is a convenience function that does for you:
argosyEndpoint
... where the league knows the port, so that you do not need to maintain a reference to it.
var leagueStream = league.createStream()
Add an unpaired Argosy stream to the league, to be connected to another Argosy endpoint or hansa league. This behaves just like any other Argosy stream, except it appears to provide all services that are provided by any Argosy endpoint piped to a league port. It's possible to connect two league
objects this way, by piping them together.
Example of manually connecting an Argosy stream to a league (without using
league.connect
):
var league = argosy = argosy
Only one Argosy stream should be connected to a given Hansa league stream. Upon connecting, the league will request to be notified of services offered by (now or in the future) the Argosy stream, and any Argosy stream connected to the league will see those services, as well as the services of all other connected streams
league.connectionOpened(cb)
An eventuate representing a
new Argosy stream being connected to the league. Handler functions, cb
,
associated with the eventuate receive the local (league-side) Argosy stream.
league.connectionClosed(cb)
An eventuate representing an Argosy stream being disconnected from the league.
Handler functions, cb
, associated with the eventuate receive the local
(league-side) Argosy stream.
league.connectionFailed(cb)
An eventuate representing a failure while attempting to connect a new Argosy
stream to the league. Handler functions, cb
, associated with the eventuate
receive the local (league-side) Argosy strean.
league.patternAdded(cb)
An eventuate representing a new service pattern being defined by one of the
Argosy streams belonging to the league. Handler functions, cb
, associated
with the eventuate receive the Argosy
pattern object.
league.patternRemoved(cb)
An eventuate representing the removal of a previously accepted service pattern.
Handler functions, cb
, associated with the eventuate receive the Argosy
pattern object.
league.error(cb)
An eventuate representing an error condition within the league
. Handler functions associated with this eventuate receive the Error
object as the payload. This eventuate requires consumption, i.e. if no handler is associated with this eventuate when an Error
is produced, the Error
will be thrown.
league.id
The unique ID (UUID) of the league
.
league.connections
An array containing all streams created via league.createStream()
.
league.patterns
An array of all service patterns (represented by Argosy pattern objects) offered by the league
.
testing
npm test [--dot | --spec] [--grep=pattern]
Specifying --dot
or --spec
will change the output from the default TAP style.
Specifying --grep
will only run the test files that match the given pattern.
coverage
npm run coverage [--html]
This will output a textual coverage report. Including --html
will also open
an HTML coverage report in the default browser.