@oddnetworks/oddworks
Advanced tools
Comparing version 3.8.0 to 3.8.1
@@ -125,4 +125,3 @@ 'use strict'; | ||
get: ['admin', 'platform'], | ||
post: ['admin'], | ||
delete: ['admin'] | ||
post: ['admin'] | ||
}}), | ||
@@ -156,6 +155,5 @@ CatalogListController.create({bus, type}) | ||
get: ['admin'], | ||
post: ['admin'], | ||
delete: ['admin'] | ||
post: ['admin'] | ||
}}), | ||
CatalogSpecController.create({bus, type}) | ||
CatalogSpecListController.create({bus, type}) | ||
); | ||
@@ -170,3 +168,3 @@ | ||
}}), | ||
CatalogSpecListController.create({bus, type}) | ||
CatalogSpecController.create({bus, type}) | ||
); | ||
@@ -173,0 +171,0 @@ }); |
@@ -5,2 +5,3 @@ 'use strict'; | ||
const _ = require('lodash'); | ||
const debug = require('debug')('oddworks:catalog:query'); | ||
@@ -130,2 +131,5 @@ const RESOURCE_FEATURES = [ | ||
debug(`checkCache ${object.id} maxAge ${maxAge}`); | ||
debug(`checkCache ${object.id} spec ${Boolean(object.spec)}`); | ||
// Only go through the cache pipeline if caching is configured for | ||
@@ -139,2 +143,3 @@ // this object. | ||
const update = now > expiration; | ||
debug(`checkCache ${object.id} update ${update}`); | ||
@@ -145,6 +150,7 @@ const promise = (now > (expiration + staleWindow)) ? | ||
if (promise) { | ||
debug(`checkCache ${object.id} stale has expired`); | ||
return promise.catch(handleSourceError); | ||
} | ||
const updateFrequency = _.isNumber((object.meta || {}).updateFrequency) ? | ||
const updateFrequency = _.isNumber(object.meta.updateFrequency) ? | ||
object.meta.updateFrequency : UPDATE_FREQ; | ||
@@ -155,6 +161,10 @@ // If this is one of many nodes in the system, we don't want to send an | ||
// of 0.1 will result in this node requesting the resource 10% of the time. | ||
debug(`checkCache ${object.id} updateFrequency ${updateFrequency}`); | ||
if (update && Math.random() <= updateFrequency) { | ||
// Fetch resource in the background | ||
debug(`checkCache ${object.id} fetching in background`); | ||
fetchItemSource(channel, object).catch(handleSourceError); | ||
} | ||
} else { | ||
debug(`checkCache ${object.id} false`); | ||
} | ||
@@ -173,5 +183,7 @@ | ||
if (!spec) { | ||
debug(`fetchItemSource ${specId} not found`); | ||
return null; | ||
} | ||
debug(`fetchItemSource ${specId} using provider ${spec.source}`); | ||
return service.bus.query( | ||
@@ -191,2 +203,3 @@ {role: 'provider', cmd: 'get', source: spec.source}, | ||
debug(`fetchItemSource ${specId} got resource object ${type}:${object.id}`); | ||
return service.bus | ||
@@ -196,2 +209,4 @@ .sendCommand({role: 'catalog', cmd: 'setItem', type}, newObject); | ||
debug(`fetchItemSource ${specId} resource object not found ${type}:${object.id}`); | ||
// If the spec didn't exist, or the object did not exist at the source, | ||
@@ -198,0 +213,0 @@ // then remove it from the store. |
@@ -113,4 +113,8 @@ 'use strict'; | ||
// args.user - String | ||
// args.secret - String | ||
// args.issuer - String | ||
queries.sign = function sign(args) { | ||
args = args || {}; | ||
const secret = args.secret || JWT_SECRET; | ||
const issuer = args.issuer || JWT_ISSUER; | ||
@@ -127,6 +131,3 @@ if (!Array.isArray(args.audience)) { | ||
const options = { | ||
issuer: JWT_ISSUER, | ||
audience: args.audience | ||
}; | ||
const options = {issuer, audience: args.audience}; | ||
@@ -150,3 +151,3 @@ const payload = {}; | ||
return new Promise((resolve, reject) => { | ||
jwt.sign(payload, JWT_SECRET, options, (err, token) => { | ||
jwt.sign(payload, secret, options, (err, token) => { | ||
if (err) { | ||
@@ -153,0 +154,0 @@ return reject(err); |
{ | ||
"name": "@oddnetworks/oddworks", | ||
"version": "3.8.0", | ||
"version": "3.8.1", | ||
"description": "An extensible media platform for OTT devices.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/oddworks.js", |
141407
3134