-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
305 additions
and
944 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,6 @@ config/runtime.json | |
|
||
apiary.out.html | ||
|
||
config/oo.yml | ||
config/oo.yml | ||
config/development.yml | ||
config/certs/goo.pem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
docs/technical-documentation/architecture/The-Datastore-Subsystem.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
[HOME](Home) > [TECHNICAL DOCUMENTATION](technical-documentation) > [ARCHITECTURE](architecture) > **DATASTORE** | ||
|
||
joola.io uses a datastore to support its need for storing documents, querying, analyzing, etc... | ||
We've designed joola.io so it is agnostic to the datastore provider, it uses a logical layer that exposes API endpoints for pushing documents ([beacon](the-beacon-subsystem)) and querying analytics ([query](the-query-subsystem)). | ||
|
||
These are the current datastore providers joola.io supports: | ||
- [MongoDB](http://github.com/joola/joola.io.datastore-mongodb) | ||
|
||
There's a wealth of datastore providers, ranging from Google Datastore to influxdb. We invite the community to contribute plugins to extend the support of joola.io. | ||
|
||
### Datastore Plugins | ||
Extending joola.io with additional datastore plugins is not an overly complex task. The framework supports easy integration of additional plugins. | ||
|
||
##### Install the plugin | ||
When joola.io boots, it tries to load all relevant datastore plugins and initialize them. Discovery of datastores is done by inspecting configuration under the `store:datastore` key. | ||
Each datastore found is initialized by requiring the plugin `require('joola.io.datastore-<datastorename>')`. If the plugin is not installed, an error is shown and the boot is terminated. | ||
|
||
For this example, we'll use the `joola.io.datastore-mongodb` plugin. | ||
|
||
```bash | ||
$ npm install joola.io.datastore-mongodb | ||
``` | ||
|
||
##### Add to configuration | ||
```yaml | ||
store: | ||
datastore: | ||
mongodb: | ||
dsn: mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]] | ||
``` | ||
|
||
When you'll run joola.io, it will attempt to `require('joola.io.datastore-mongodb')` and then initialize it with the dsn provided in the configuration. | ||
|
||
### Writing Plugins | ||
In order to allow communication between joola.io and the plugin it's required for the plugin to follow strict guidelines and syntax. | ||
|
||
We have created a template repository named [joola.io.datastore-template](http://github.com/joola/joola.io.datastore-template). Please fork this repository to use as the basis for the plugin you are about to develop. | ||
The template implements all required exports for communication back and forth between joola.io and your plugin. | ||
|
||
A working example is the [joola.io.datastore-mongodb](http://github.com/joola/joola.io.datastore-mongodb) provider plugin. | ||
|
||
The template is rich with comments to support your development, please feel free to submit pull-request to the template repository with additional know-how, examples and comments to support the community development. | ||
|
||
#### Exports | ||
|
||
The following exports are needed from each plugin. The template includes more in-depth comments relevant to each export. | ||
|
||
###### `init` | ||
|
||
###### `destroy` | ||
|
||
###### `openConnection` | ||
|
||
###### `closeConnection` | ||
|
||
###### `checkConnection` | ||
|
||
###### `insert` | ||
|
||
###### `find` | ||
|
||
###### `delete` | ||
|
||
###### `update` | ||
|
||
###### `query` | ||
|
||
###### `drop` | ||
|
||
###### `purge` |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/** | ||
* @title joola.io | ||
* @overview the open-source data analytics framework | ||
* @copyright Joola Smart Solutions, Ltd. <info@joo.la> | ||
* @license GPL-3.0+ <http://spdx.org/licenses/GPL-3.0+> | ||
* | ||
* Licensed under GNU General Public License 3.0 or later. | ||
* Some rights reserved. See LICENSE, AUTHORS. | ||
**/ | ||
|
||
'use strict'; | ||
|
||
var | ||
joola = require('../joola.io'), | ||
|
||
domain = require('domain'), | ||
async = require('async'), | ||
_ = require('underscore'); | ||
|
||
var datastore = module.exports; | ||
|
||
datastore.providers = {}; | ||
|
||
datastore.init = function (callback) { | ||
//find out what datastores we have in config | ||
var stores = joola.config.get('store:datastore'); | ||
|
||
var calls = []; | ||
Object.keys(stores).forEach(function (key) { | ||
var store = stores[key]; | ||
if (store.enabled !== false) { | ||
try { | ||
var call = function (callback) { | ||
var Provider = require('joola.io.datastore-' + key); | ||
if (!Provider) | ||
return callback(new Error('Provider [' + key + '] cannot be required. Did you forget to `npm install` it?')); | ||
|
||
joola.logger.trace('Initializing datastore provider [' + key + '].'); | ||
new Provider(store, {logger: joola.logger, common: joola.common}, function (err, provider) { | ||
if (err) | ||
return callback(err); | ||
joola.logger.debug('Datastore [' + key + '] is now ready.'); | ||
datastore.providers[key] = provider; | ||
if (!datastore.providers.default) | ||
datastore.providers.default = provider; | ||
return callback(null, provider); | ||
}); | ||
}; | ||
calls.push(call); | ||
} | ||
catch (ex) { | ||
return callback(ex); | ||
} | ||
} | ||
}); | ||
|
||
async.series(calls, function (err) { | ||
if (err) | ||
return callback(err); | ||
|
||
return callback(null, stores); | ||
}); | ||
}; | ||
|
||
datastore.destroy = function (callback) { | ||
var calls = []; | ||
Object.keys(datastore.providers).forEach(function (key) { | ||
var call = function (callback) { | ||
joola.logger.trace('Destroying datastore provider [' + key + '].'); | ||
var provider = datastore.providers[key]; | ||
provider.destroy(callback); | ||
}; | ||
calls.push(call); | ||
}); | ||
async.series(calls, function (err) { | ||
if (err) | ||
return callback(err); | ||
return callback(null); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.