0.1.0-alpha • Published 6 years ago

energyhub-events v0.1.0-alpha

Weekly downloads
3
License
UNLICENSED
Repository
github
Last release
6 years ago

energyhub-events

An attempted solution for the EnergyHub Coding Sample.

Dependencies

NPM is required to install this package. Node.js required to execute this package.

This package was developed with Node v6.11.2 and NPM v3.10.10 on macOS Sierra 10.12.16. This package has been tested with Node v6.11.2 and Node v10.12.0 on macOS Sierra 10.12.16.

For directions on installing Node (which bundles NPM), visit the Node.js website.

Installation

$ npm install -g energyhub-events

Execution

The general format for executing the package is:

$ energyhub-events [--field <field>[...]]            \
                   [--driver-option <key=value>[...] \
                   [--optimize <optimization>]       \
                   <uri> <date-time>

To see the available optimizations:

$ energyhub-events --help

The available drivers can by seen with:

$ energyhub-events driver list

To see the options accepted by a driver:

$ energyhub-events driver describe <driver>

Reading Local Files

$ energyhub-events --field schedule     \
                   --field ambientTemp  \
                   audit-data.tar.gz    \
                   2016-05-04T10:15:32
{"state":{"ambientTemp":73,"schedule":true},"ts":"2016-05-04T10:15:32"}

Reading S3 Objects

$ energyhub-events --driver-option accessKeyId=<accessKeyId>         \
                   --driver-option secretAccessKey=<secretAccessKey> \
                   --field schedule     \
                   --field ambientTemp  \
                   s3://net.energyhub.assets/public/dev-exercises/audit-data.tar.gz \
                   2016-05-04T10:15:32
{"state":{"ambientTemp":73,"schedule":true},"ts":"2016-05-04T10:15:32"}

Note the appearance in the above command of two --driver-option flags.

Caching remote files

By default, reading an S3 object will result in the object being saved to the local cache directory (by default, $HOME/.cache/energyhub-events).

Subsequent requests for that S3 object will be directed to the local cache directory rather that the remote S3 endpoint.

To use a cache directory other than the default, supply a --cache-dir flag, e.g.:

$ energyhub-events --cache-dir /tmp/.energyhub-events-cache \
                   --driver-option accessKeyId=<accessKeyId>         \
                   --driver-option secretAccessKey=<secretAccessKey> \
                   --field schedule                         \
                   --field ambientTemp                      \
                   s3://net.energyhub.assets/public/dev-exercises/audit-data.tar.gz \
                   2016-05-04T10:15:32

To disable the use of caching, supply either the no-cache-remote-data or none optimizations, e.g.:

$ energyhub-events --optimize no-cache-remote-data     \
                   --driver-option accessKeyId=<accessKeyId>         \
                   --driver-option secretAccessKey=<secretAccessKey> \
                   --field schedule    \
                   --field ambientTemp \
                   s3://net.energyhub.assets/public/dev-exercises/audit-data.tar.gz \
                   2016-05-04T10:15:32

Development and Testing

Download Sources

To download sources, some additional dependencies may be required.

With Git

$ git clone git@github.com:maxenglander/energyhub-events
$ cd energyhub-events

For directions on installing Git, visit the Git website.

With cURL and tar

$ curl -sL https://github.com/maxenglander/energyhub-events/tarball/master.tar.gz | tar xzf -
$ cd energyhub-events-master

Installing cURL and tar is outside of the scope of this project.

Install Additional Dependencies

After downloading sources, change directory into the source code folder and run npm install. For example, if you downloaded sources with Git:

$ cd energyhub-events
$ npm install

Run Tests

$ npm test