@clevercloud/client
Advanced tools
Comparing version 3.1.1 to 3.1.2
# Clever Client changelog | ||
## 3.1.2 (2020-03-18) | ||
* Fix access logs continuous mechanism in `getContinuousAccessLogsFromWarp10()` use microseconds precision | ||
## 3.1.1 (2020-03-18) | ||
@@ -4,0 +8,0 @@ |
@@ -68,3 +68,3 @@ "use strict"; | ||
// 3. Data arrives | ||
// 4. Schedule next loop in 1000ms later with fetch from="last to + 1ms" to="now" | ||
// 4. Schedule next loop in 1000ms later with fetch from="last" to="now" | ||
// The from/to timeframe will be around (fetch roundtrip) + 1000ms | ||
@@ -90,3 +90,3 @@ | ||
setTimeout(() => doCall(to + 1, Date.now()), 1000); | ||
setTimeout(() => doCall(to, Date.now()), 1000); | ||
}).catch(e => emitter.emit('error', e)); | ||
@@ -93,0 +93,0 @@ } // Trigger batch "loop" mechanism |
@@ -16,4 +16,15 @@ "use strict"; | ||
function asWarp10Timespan(from, to) { | ||
return `'${new Date(from).toISOString()}' '${new Date(to).toISOString()}'`; | ||
function toISOStringWithMicrosecondPrecision(microseconds) { | ||
const milliseconds = Math.floor(microseconds / 1000); | ||
const isoStringMilli = new Date(milliseconds).toISOString(); | ||
const microPrecisionString = String(microseconds % 1000).padStart(3, '0'); | ||
return isoStringMilli.replace(/Z$/, `${microPrecisionString}Z`); | ||
} // Converts "from" and "to" ms timestamps to ISO 8601 with µs precision | ||
// also removes 1µs to "to" because Warp10 timespan are inclusive | ||
function asWarp10Timespan(fromMilli, toMilli) { | ||
const fromMicro = fromMilli * 1000; | ||
const toMicro = toMilli * 1000 - 1; | ||
return `'${toISOStringWithMicrosecondPrecision(fromMicro)}' '${toISOStringWithMicrosecondPrecision(toMicro)}'`; | ||
} |
@@ -51,3 +51,3 @@ import Emitter from 'component-emitter'; | ||
// 3. Data arrives | ||
// 4. Schedule next loop in 1000ms later with fetch from="last to + 1ms" to="now" | ||
// 4. Schedule next loop in 1000ms later with fetch from="last" to="now" | ||
// The from/to timeframe will be around (fetch roundtrip) + 1000ms | ||
@@ -66,3 +66,3 @@ export function getContinuousAccessLogsFromWarp10 ({ appId, realAddonId, warpToken }, sendToWarp10) { | ||
// Prevent huge recursive call stack | ||
setTimeout(() => doCall(to + 1, Date.now()), 1000); | ||
setTimeout(() => doCall(to, Date.now()), 1000); | ||
}) | ||
@@ -69,0 +69,0 @@ .catch((e) => emitter.emit('error', e)); |
@@ -7,4 +7,15 @@ export const ONE_HOUR = 60 * 60 * 1000; | ||
export function asWarp10Timespan (from, to) { | ||
return `'${(new Date(from)).toISOString()}' '${(new Date(to)).toISOString()}'`; | ||
function toISOStringWithMicrosecondPrecision (microseconds) { | ||
const milliseconds = Math.floor(microseconds / 1000); | ||
const isoStringMilli = new Date(milliseconds).toISOString(); | ||
const microPrecisionString = String(microseconds % 1000).padStart(3, '0'); | ||
return isoStringMilli.replace(/Z$/, `${microPrecisionString}Z`); | ||
} | ||
// Converts "from" and "to" ms timestamps to ISO 8601 with µs precision | ||
// also removes 1µs to "to" because Warp10 timespan are inclusive | ||
export function asWarp10Timespan (fromMilli, toMilli) { | ||
const fromMicro = fromMilli * 1000; | ||
const toMicro = (toMilli * 1000) - 1; | ||
return `'${toISOStringWithMicrosecondPrecision(fromMicro)}' '${toISOStringWithMicrosecondPrecision(toMicro)}'`; | ||
} |
{ | ||
"name": "@clevercloud/client", | ||
"version": "3.1.1", | ||
"version": "3.1.2", | ||
"description": "JavaScript REST client and utils for Clever Cloud's API", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/CleverCloud/clever-client.js", |
397209
12494