0.1.1 • Published 11 years ago

alldata-client-http v0.1.1

Weekly downloads
3
License
-
Repository
github
Last release
11 years ago

alldata-client-http

Stability: 1 - Experimental

NPM version

Client HTTP module for AllData, a distributed master-less write-once 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) 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

0.1.1

11 years ago

0.1.0

11 years ago