Skip to content
New issue

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

Feature Request: support async fitting-factory #21

Open
osher opened this issue Nov 13, 2016 · 0 comments
Open

Feature Request: support async fitting-factory #21

osher opened this issue Nov 13, 2016 · 0 comments

Comments

@osher
Copy link

osher commented Nov 13, 2016

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... :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant