Skip to content

Instantly share code, notes, and snippets.

@wolfeidau
Last active December 24, 2015 23:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wolfeidau/6882870 to your computer and use it in GitHub Desktop.
Save wolfeidau/6882870 to your computer and use it in GitHub Desktop.
NodeJS stdlib Post
'use strict';
var url = require('url');
var creds = require('./creds.js');
var https = require('https');
var scheme = 'https';
var hostname = 'api.tempo-db.com';
var baseUrl = scheme + '://' + hostname;
var auth = 'Basic ' + new Buffer(creds.key + ':' + creds.secret).toString('base64');
var seriesKey = '1_D90343085872CA9C_687_0_2000';
function uploadEntry(cb){
var data = [];
data.push({t: new Date(), v: Math.random() * 50});
var body = JSON.stringify(data);
var headers = {
Authorization: auth,
'Content-Type': 'application/json',
'Content-Length': body.length
};
var opts = {
host: hostname,
port: 443,
path: '/v1/series/key/' + seriesKey + '/data/',
method: 'POST',
agent: false,
headers: headers
};
// console.log('sending', data[0]);
var req = https.request(opts,cb);
req.on('error', function(e) {
console.err('error', e);
});
req.write(body);
req.end();
};
function callback(result){
console.log('statusCode', result.statusCode);
}
setInterval(uploadEntry.bind(null, callback), 1000);
setInterval(gc, 1000);
@wolfeidau
Copy link
Author

This is master without the GC routine.

    2818f234f1d1       15        5 Array
    2818f2306a61       24        0
     d882e60f5b1       37        4 NativeModule: filename, id, exports, ...
    277956007409      563        5 TCP: writeQueueSize, owner, onread, ...
    277956009a11      564        6 Object: headers, statusCode, ...
    27795600c779      564        9 Object: subject, issuer, subjectaltname, ...
     d882e61d9c9      565        2 Buffer: length, parent
    27795600cd41      565        3 Object: C, O, CN
    277956007611      565        3 Object: callback, family, oncomplete
    277956007329      565        3 Object: port, host, localAddress
    277956007fe9      565        6 Object: sentConnectionHeader, ...
    27795600ced9      565        6 Object: serialNumber, C, ST, L, O, CN
    277956004ab9      565        7 Object: host, port, path, method, ...
    277956004461      566        6 Object: host, port, path, method, agent, ...
    277956004591      566        7 Object: agent, keepAlive, headers, ...
    27795600e4a9      568        2 Object: t, v
    277956004639     1131        6 Array
    277956004b61     1132        7 Array
    2212d9698cf1     1133        3 Object: oncomplete, bytes, cb
    1492e1289791     1142        1 NativeBuffer: length
     6fc56c967b9     1257       25 IncomingMessage: _readableState, ...
     6bdc9104461     1258        1 Object: free
     5c87182ad61     1258        3 TLSWrap: onhandshakestart, ...
     e920a6099a9     1258       19 WritableState: highWaterMark, ...
     5c87182acf9     1258       29 ClientRequest: domain, _events, ...
     6bdc9104479     1259        1 Object: path
     5c87189f869     1259        5 Object: end, connect, free, close, ...
     5c87182b449     1259        8 Object: agent, keepAlive, headers, ...
     e920a646271     1259       35 TLSSocket: _connecting, _hadError, ...
     e920a609a91     1260        1 Credentials: context
     7bdce6e3a81     1260        9 Object: rejectUnauthorized, servername, ...
     e920a646231     1261        5 Object: credentials, isServer, ...
     5c8718a5fe1     1261       13 Agent: domain, _events, _maxListeners, ...
     d882e607841     1293        6 Object: end, error, connect, free, ...
     5c87189f899     2386        8 Array
     5c87189f7a9     2515       21 ReadableState: highWaterMark, buffer, ...
     7bdce653751     2660        0 SecureContext
    27795600a5c1     2817        1 Arguments: length
    277956004eb9     2840        3 Array
    2779560078a9     3946        2 Object: callback, domain
    277956007c69     5650        4 Array
     d882e606f41     7889        2 Arguments: length, callee
     5c8718c0919     8797        2 Array
     5c8718bc4a9     9264        1 Array
     5c87182aec1    17270        0 Object
     5c87182aed9    17466        0 Array
          OBJECT #OBJECTS   #PROPS CONSTRUCTOR: PROPS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment