AllData HTTP client module.
JavaScript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
scripts
test
.gitignore
LICENSE
README.md
index.js
package.json

README.md

alldata-client-http

Stability: 1 - Experimental

NPM version

Client HTTP module for AllData, a distributed master-less append-only immutable event store database implementing "All Data" part of Lambda Architecture.

Usage

var AllDataClient = require('alldata-client-http');
var allDataClient = new AllDataClient({
    hostname: "localhost",
    method: "POST",
    path: "/put",
    port: 80 
});

var event1 = {customer: 1, action: "site visit"};

allDataClient.put(event1);

var event2 = {customer: 1, action: "login"};

allDataClient.put(event2, function (error) {
    if (error) {
        console.log("Saving event2 failed: " + error.message);
    } else {
        console.log("Saving event2 succeeded.");
    }
});

Test

npm test

Overview

AllDataClient is an HTTP client for AllData. Once configured, it sends HTTP requests for every event.

Documentation

AllDataClient

Public API

new AllDataClient(options)

  • options: Object
    • hostname: String (Default: localhost) HTTP hostname of the AllData server.
    • method: String (Default: POST) HTTP method.
    • path: String (Default: /) HTTP request path.
    • port: Number (Default: 80) HTTP port of remote server.

Creates a new instance of AllDataClient.

allDataClient.put(event, [callback])

  • event: Object JavaScript object representing the event to store.
  • callback: Function (Default: undefined) function (error) {} An optional callback to call in case of success or failure.

Attempts to store the event in AllData service via HTTP. If a callback is provided it will be called with an Error instance if an error occurs or with no parameters otherwise.

allDataClient.put({foo: 'bar'}, function (error) {
    if (error) console.log('put failed: ' + error.message);
});

Sources