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

expose better api for post-import config mutating #48

Open
jasisk opened this issue May 11, 2015 · 9 comments
Open

expose better api for post-import config mutating #48

jasisk opened this issue May 11, 2015 · 9 comments

Comments

@jasisk
Copy link
Contributor

jasisk commented May 11, 2015

@aredridel and I were chatting about a potential new feature inside kraken to prevent us from having to broganize (wrap kraken opts). One step we could take would be exposing a better signature for config post-import normalization, plus registering more protocols after init but before create.

The first part of that we basically already have. The only change required would be to push the final import into the constructor (and either out of the create method or in addition to it, in order to support asynchronous imports). Then, we could simply add a method in place of using the .promise.

The second part would be a simple method to write.

We already do similar behaviors elsewhere (at least for the second part—double confit stuff in kraken), this would just expose a better api for it.

Thoughts?

@jasisk jasisk changed the title expose better api for post-import config mutating. expose better api for post-import config mutating May 11, 2015
@pvenkatakrishnan
Copy link
Member

interesting thoughts. one i immediately get is being able to add protocols any time before create...
The other 2 about moving import resolution per The only change required would be to push the final import into the constructor and extra merge of config methods, i am unsure i understand completely the needs. More info ?

@jasisk
Copy link
Contributor Author

jasisk commented May 11, 2015

More info ?

Duplicate this under this. That way, imports that exist on env and argv happen before that promise is considered resolved.

Then, exposing something a little more legible than:

var config = confit(opts);
config.promise.then(function () {
  // imports have happened at this point
  config.create(function (config) {
    // everything has happened at this point
  });
})

@pvenkatakrishnan
Copy link
Member

hmmm today the interface is:

confit(opts).create(function(err, config) {

   ...
});

The create related processing after promise resolution happens transparently within confit. Do you have a sample snippet as to what you were thinking as the desired interface.

@jasisk
Copy link
Contributor Author

jasisk commented May 12, 2015

That's totally clear. What I'm describing is a new lifecycle event. @aredridel and I were talking about the ability for modules to self-register in kraken. Having the ability to break into the config after imports are resolved but before other shortstop handlers would help facilate that.

@pvenkatakrishnan
Copy link
Member

interesting idea.. Maybe we can chat more in detail. as long as all these modules which want to add into the config signs on the promise (which, I agree, they will need an interface for), we can still maintain the above interface. But how the modules will get access to merge into the app's config is the tougher part...

@aredridel
Copy link
Contributor

Agreed. A set-only interface would be interesting.

@aredridel
Copy link
Contributor

Another possibility is exposing the ability to add shortstop protocols from a config entry itself (yay reflexivity!).

@grawk
Copy link
Member

grawk commented Mar 17, 2016

+1

@jasisk
Copy link
Contributor Author

jasisk commented Mar 17, 2016

Nice necrobump, @grawk.

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

No branches or pull requests

4 participants