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

Dynamically-loadable drivers #8

Open
GochoMugo opened this issue Sep 11, 2016 · 2 comments
Open

Dynamically-loadable drivers #8

GochoMugo opened this issue Sep 11, 2016 · 2 comments

Comments

@GochoMugo
Copy link
Member

Since there may be numerous drivers in the wild, and the average user may not use most of the drivers, we need a way to only install and load the drivers the user is only interested in.

@GochoMugo
Copy link
Member Author

Dynamic-loadable drivers can be installed using npm. For example,

$ npm install fpush-ssh-driver

Then to use the newly-installed driver, we can pass the CLI flag --dynamic-driver <driver>. For example,

$ fpush --dynamic-driver fpush-ssh-driver

The value passed (through dynamicDriver option in the API), is passed to require(), with the return value expected to be an object, with Driver property assigned to the Driver's class. For example,

// ... snip ...

try {
    const dynamicDriver = require('fpush-ssh-driver');
    typeof dynamicDriver === "object"; // true
    typeof dynamicDriver.Driver === "function"; // true; the class constructor
} catch (ex) {
    // ... snip ...
}

Note: we are using an object, instead of returning the constructor from require(), to allow future additions to the drivers, without breaking the API.

@GochoMugo
Copy link
Member Author

As agreed above (... future additions ...), we can add properties to the driver interface.

A driver must export .protocol property key, purposefully for accessing configurations for the driver. Examples include "ftp", "sftp", etc.

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

1 participant