-
Notifications
You must be signed in to change notification settings - Fork 30
Description
Currently, the fittings are produced by a synchronous factory.
The factory is provided with fcty(fittingDef, bagpipes)
.
I would like to be able to introduce fittings that employ asynchronous initiation, and should be able to fail fast in the meaning of stop the process gracefully if any of their data-sources are not available.
A simplified example:
my-paramount-must-be-init-dal
initiates itself with a map of values, and subscribes to a channel to be notified whenever they change. outside of it, any access to this map of values is synchronous.
The data-source and the subscription channels, are provided in fittingDef.dalCfg
const dal = require('./my-paramount-must-be-init-dal');
module.exports = myFittingFactory(fittingDef, bagpipes, cb) {
dal.init(fittingDef.dalCfg, function(err) {
if (err) return cb(err);
cb( null, { get: (id,cb) => cb(null, dal.repo[id]) } ) //not a mistake. sync access to object key
})
}
To do this without asycn loading of the fitting I have to implement a deferring mechanism to each of the featured dal methods - and that's annoying... :/