Skip to content
This repository has been archived by the owner on Feb 25, 2023. It is now read-only.

Modularize internal commands #58

Closed
woodruffw opened this issue Dec 16, 2017 · 4 comments
Closed

Modularize internal commands #58

woodruffw opened this issue Dec 16, 2017 · 4 comments

Comments

@woodruffw
Copy link
Member

Right now, the kbsecret command calls internal commands (like list) via exec, just like external commands:

elsif external?(command) || internal?(command)
  exec expand(command), *args

This is slow, since it requires Ruby (and all dependent libraries) to be loaded twice: once in kbsecret itself, and once in the exec'd subcommand. It also makes it harder to generate code coverage on the CLI.

In order to avoid this reloading, all internal kbsecret commands should become first class objects under the KBSecret::CLI namespace. Some options:

  • Subclass KBSecret::CLI in each, like KBsecret::CLI::New to kbsecret new.
  • Create a new subhierarchy with a consistent mapping, like KBSecret::CLI::Command::New to kbsecret new.
@woodruffw
Copy link
Member Author

woodruffw commented Dec 26, 2017

Based on local testing, this results in a decent performance boost: require "kbsecret" takes about 400ms in total, so preventing a subcommand from needing its own brings a ~30% speedup in many cases.

And a solid half of require "kbsecret" is just making sure KBFS is mounted:
4920bc9 addresses this:

@woodruffw woodruffw added this to the 1.1 milestone Jan 17, 2018
@naveenanilabs
Copy link

Anyone working on this i want to help you guys.

@woodruffw
Copy link
Member Author

Nope, nobody is. Feel free to take a stab!

@woodruffw
Copy link
Member Author

Began work on this as #67.

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

No branches or pull requests

2 participants