Comparing version 13.0.0-6 to 13.0.0-7
@@ -13,3 +13,3 @@ # Dependency Licenses | ||
debug@2.2.0 : MIT | ||
include-all@1.0.1 : MIT | ||
include-all@1.0.2 : MIT | ||
lodash@3.10.1 : MIT | ||
@@ -16,0 +16,0 @@ rttc@^9.8.1 : MIT |
@@ -17,3 +17,3 @@ /** | ||
* @param {String} hash - the hash string representing this particular input configuration | ||
* @param {Dictionary} machine | ||
* @param {Dictionary} machine - the live machine instance | ||
* @return {Dictionary} of new callbacks which intercept the configured callback functions | ||
@@ -51,10 +51,15 @@ */ | ||
} | ||
_cache.model.create({ | ||
hash: hash, | ||
data: data | ||
}).exec(cb); | ||
try { | ||
_cache.model.create({ | ||
hash: hash, | ||
data: value | ||
}).exec(cb); | ||
} catch (e) { | ||
return cb(new Error('Consistency violation: Unexpected error when attempting to communicate with the cache via the provided model. Error details: '+e.stack+'\n- - - - - - - - - - - - - - - - - - - - - - - ')); | ||
} | ||
})(function afterPotentiallyCaching(err){ | ||
if (err) { | ||
// If cache write encounters an error, emit a warning but | ||
// continue with sending back the output | ||
// continue with sending back the output. | ||
machine.warn(err); | ||
@@ -61,0 +66,0 @@ } |
@@ -106,2 +106,23 @@ /** | ||
// ██╗ ██╗ █████╗ ██╗ ██╗██████╗ █████╗ ████████╗███████╗ | ||
// ██║ ██║██╔══██╗██║ ██║██╔══██╗██╔══██╗╚══██╔══╝██╔════╝ | ||
// ██║ ██║███████║██║ ██║██║ ██║███████║ ██║ █████╗ | ||
// ╚██╗ ██╔╝██╔══██║██║ ██║██║ ██║██╔══██║ ██║ ██╔══╝ | ||
// ╚████╔╝ ██║ ██║███████╗██║██████╔╝██║ ██║ ██║ ███████╗ | ||
// ╚═══╝ ╚═╝ ╚═╝╚══════╝╚═╝╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝ | ||
// | ||
// ██╗ ██████╗ ██████╗ ███████╗██████╗ ██████╗███████╗ | ||
// ██║ ██╔════╝██╔═══██╗██╔════╝██╔══██╗██╔════╝██╔════╝ | ||
// ████████╗ ██║ ██║ ██║█████╗ ██████╔╝██║ █████╗ | ||
// ██╔═██╔═╝ ██║ ██║ ██║██╔══╝ ██╔══██╗██║ ██╔══╝ | ||
// ██████║ ╚██████╗╚██████╔╝███████╗██║ ██║╚██████╗███████╗ | ||
// ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═════╝╚══════╝ | ||
// | ||
// █████╗ ██████╗ ██████╗ ██╗███╗ ██╗███████╗ | ||
// ██╔══██╗██╔══██╗██╔════╝ ██║████╗ ██║██╔════╝ | ||
// ███████║██████╔╝██║ ███╗██║██╔██╗ ██║███████╗ | ||
// ██╔══██║██╔══██╗██║ ██║██║██║╚██╗██║╚════██║ | ||
// ██║ ██║██║ ██║╚██████╔╝██║██║ ╚████║███████║ | ||
// ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚═╝╚═╝ ╚═══╝╚══════╝ | ||
// | ||
// If `unsafeMode` is disabled... | ||
@@ -162,2 +183,23 @@ if (!self._unsafeMode) { | ||
// █████╗ ██████╗ ██████╗ ██╗ ██╗ ██╗ | ||
// ██╔══██╗██╔══██╗██╔══██╗██║ ╚██╗ ██╔╝ | ||
// ███████║██████╔╝██████╔╝██║ ╚████╔╝ | ||
// ██╔══██║██╔═══╝ ██╔═══╝ ██║ ╚██╔╝ | ||
// ██║ ██║██║ ██║ ███████╗██║ | ||
// ╚═╝ ╚═╝╚═╝ ╚═╝ ╚══════╝╚═╝ | ||
// | ||
// ██████╗ ███████╗███████╗ █████╗ ██╗ ██╗██╗ ████████╗███████╗████████╗ ██████╗ | ||
// ██╔══██╗██╔════╝██╔════╝██╔══██╗██║ ██║██║ ╚══██╔══╝██╔════╝╚══██╔══╝██╔═══██╗ | ||
// ██║ ██║█████╗ █████╗ ███████║██║ ██║██║ ██║ ███████╗ ██║ ██║ ██║ | ||
// ██║ ██║██╔══╝ ██╔══╝ ██╔══██║██║ ██║██║ ██║ ╚════██║ ██║ ██║ ██║ | ||
// ██████╔╝███████╗██║ ██║ ██║╚██████╔╝███████╗██║ ███████║ ██║ ╚██████╔╝ | ||
// ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚══════╝ ╚═╝ ╚═════╝ | ||
// | ||
// ████████╗ ██████╗ █████╗ ██████╗ ██████╗ ██╗███╗ ██╗███████╗ | ||
// ╚══██╔══╝██╔═══██╗ ██╔══██╗██╔══██╗██╔════╝ ██║████╗ ██║██╔════╝ | ||
// ██║ ██║ ██║ ███████║██████╔╝██║ ███╗██║██╔██╗ ██║███████╗ | ||
// ██║ ██║ ██║ ██╔══██║██╔══██╗██║ ██║██║██║╚██╗██║╚════██║ | ||
// ██║ ╚██████╔╝ ██║ ██║██║ ██║╚██████╔╝██║██║ ╚████║███████║ | ||
// ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚═╝╚═╝ ╚═══╝╚══════╝ | ||
// | ||
// Apply `defaultsTo` for input defs that use it. | ||
@@ -219,10 +261,17 @@ // TODO: consider whether `defaultsTo` values should be automatically validated/coerced too (that would need to go in Machine.build) | ||
// Prune any configured exit callbacks that have `undefined` on the RHS. | ||
_.each(_.keys(self._configuredExits), function (exitCodeName) { | ||
if (self._configuredExits[exitCodeName] === undefined) { | ||
delete self._configuredExits[exitCodeName]; | ||
} | ||
});//</_.each() :: each key in dictionary of configured exit callbacks> | ||
// █████╗ ██████╗ ███████╗ ██████╗ ██████╗ ██████╗ ██████╗ █████╗ ██████╗██╗ ██╗███████╗ | ||
// ██╔══██╗██╔══██╗██╔════╝██╔═══██╗██╔══██╗██╔══██╗ ██╔════╝██╔══██╗██╔════╝██║ ██║██╔════╝ | ||
// ███████║██████╔╝███████╗██║ ██║██████╔╝██████╔╝ ██║ ███████║██║ ███████║█████╗ | ||
// ██╔══██║██╔══██╗╚════██║██║ ██║██╔══██╗██╔══██╗ ██║ ██╔══██║██║ ██╔══██║██╔══╝ | ||
// ██║ ██║██████╔╝███████║╚██████╔╝██║ ██║██████╔╝ ╚██████╗██║ ██║╚██████╗██║ ██║███████╗ | ||
// ╚═╝ ╚═╝╚═════╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚═════╝ ╚═════╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝╚══════╝ | ||
// | ||
// ███████╗███████╗████████╗████████╗██╗███╗ ██╗ ██████╗ ███████╗ | ||
// ██╔════╝██╔════╝╚══██╔══╝╚══██╔══╝██║████╗ ██║██╔════╝ ██╔════╝ | ||
// ███████╗█████╗ ██║ ██║ ██║██╔██╗ ██║██║ ███╗███████╗ | ||
// ╚════██║██╔══╝ ██║ ██║ ██║██║╚██╗██║██║ ██║╚════██║ | ||
// ███████║███████╗ ██║ ██║ ██║██║ ╚████║╚██████╔╝███████║ | ||
// ╚══════╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚══════╝ | ||
// | ||
// For convenience, set up a couple of local variables for use below: | ||
@@ -247,3 +296,8 @@ // | ||
// If a cache model was supplied, but it is not valid, then emit a warning. | ||
if (!_.isUndefined(_cache.model) && !areCacheSettingsValid) { | ||
self.warn(new Error('Invalid cache settings: If `.cache()` is in use, then `model` must be provided as a Waterline model. For example: `.cache({ model: TweetSearchResultsCache })`. Proceeding to execute this machine, but skipping all cache reads and writes...')); | ||
} | ||
// If cache settings are NOT valid, then set `_cache` | ||
@@ -294,3 +348,23 @@ // to `false` & leave `Cache` undefined. | ||
// ██╗ ██████╗ ██████╗ ██╗ ██╗ ██╗ ██╗██████╗ ██████╗ ███████╗███████╗██╗ ██╗██╗ ████████╗ | ||
// ██║ ██╔═══██╗██╔═══██╗██║ ██╔╝ ██║ ██║██╔══██╗ ██╔══██╗██╔════╝██╔════╝██║ ██║██║ ╚══██╔══╝ | ||
// ██║ ██║ ██║██║ ██║█████╔╝ ██║ ██║██████╔╝ ██████╔╝█████╗ ███████╗██║ ██║██║ ██║ | ||
// ██║ ██║ ██║██║ ██║██╔═██╗ ██║ ██║██╔═══╝ ██╔══██╗██╔══╝ ╚════██║██║ ██║██║ ██║ | ||
// ███████╗╚██████╔╝╚██████╔╝██║ ██╗ ╚██████╔╝██║ ██║ ██║███████╗███████║╚██████╔╝███████╗██║ | ||
// ╚══════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝ ╚═════╝ ╚══════╝╚═╝ | ||
// | ||
// ██╗███╗ ██╗ ██████╗ █████╗ ██████╗██╗ ██╗███████╗ | ||
// ██║████╗ ██║ ██╔════╝██╔══██╗██╔════╝██║ ██║██╔════╝ | ||
// ██║██╔██╗ ██║ ██║ ███████║██║ ███████║█████╗ | ||
// ██║██║╚██╗██║ ██║ ██╔══██║██║ ██╔══██║██╔══╝ | ||
// ██║██║ ╚████║ ╚██████╗██║ ██║╚██████╗██║ ██║███████╗ | ||
// ╚═╝╚═╝ ╚═══╝ ╚═════╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝╚══════╝ | ||
// | ||
// ██╗██╗███████╗ ██████╗ ███████╗██╗ ███████╗██╗ ██╗ █████╗ ███╗ ██╗████████╗██╗ | ||
// ██╔╝██║██╔════╝ ██╔══██╗██╔════╝██║ ██╔════╝██║ ██║██╔══██╗████╗ ██║╚══██╔══╝╚██╗ | ||
// ██║ ██║█████╗ ██████╔╝█████╗ ██║ █████╗ ██║ ██║███████║██╔██╗ ██║ ██║ ██║ | ||
// ██║ ██║██╔══╝ ██╔══██╗██╔══╝ ██║ ██╔══╝ ╚██╗ ██╔╝██╔══██║██║╚██╗██║ ██║ ██║ | ||
// ╚██╗██║██║ ██║ ██║███████╗███████╗███████╗ ╚████╔╝ ██║ ██║██║ ╚████║ ██║ ██╔╝ | ||
// ╚═╝╚═╝╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═╝ ╚═╝ | ||
// | ||
// Below, we'll use a hash function to create a unique hash (aka checksum) for every distinct set | ||
@@ -318,31 +392,36 @@ // of argins. We'll store this in this local variable (`hash`). | ||
// Now call `.find()` on the provided Cache model in order to look up the cached return value | ||
// for the hash representing this particular set of argins. | ||
Cache.find({ | ||
where: { | ||
createdAt: { '>': _cache.expirationDate }, | ||
hash: hash | ||
}, | ||
sort: 'createdAt DESC', | ||
limit: 1 | ||
}) | ||
.exec(function (err, cached) { | ||
if (err) { return cb(err); } | ||
try { | ||
// --• If this was a cache hit... | ||
if (cached.length && typeof cached[0].data !== 'undefined') { | ||
// console.log('cache hit', cached); | ||
var newestCacheEntry = cached[0]; | ||
// Fourth argument (`true`) tells switchback to run synchronously | ||
return switchback(self._configuredExits, undefined, undefined, true)(null, newestCacheEntry.data); | ||
} | ||
// Now call `.find()` on the provided Cache model in order to look up the cached return value | ||
// for the hash representing this particular set of argins. | ||
Cache.find({ | ||
where: { | ||
createdAt: { '>': _cache.expirationDate }, | ||
hash: hash | ||
}, | ||
sort: 'createdAt DESC', | ||
limit: 1 | ||
}) | ||
.exec(function (err, cached) { | ||
if (err) { return cb(err); } | ||
// --• If this was a cache miss... | ||
return cb(); | ||
// --• If this was a cache hit... | ||
if (cached.length && typeof cached[0].data !== 'undefined') { | ||
// console.log('cache hit', cached); | ||
var newestCacheEntry = cached[0]; | ||
// Fourth argument (`true`) tells switchback to run synchronously | ||
return switchback(self._configuredExits, undefined, undefined, true)(null, newestCacheEntry.data); | ||
} | ||
});//</Cache.find() :: finding records in cache model> | ||
// --• If this was a cache miss... | ||
return cb(); | ||
});//</Cache.find() :: finding records in cache model> | ||
} catch (e) { | ||
return cb(new Error('Consistency violation: Unexpected error when attempting to communicate with the cache via the provided model. Error details: '+e.stack+'\n- - - - - - - - - - - - - - - - - - - - - - - ')); | ||
} | ||
})(function afterwards(err){ | ||
if (err) { | ||
// If cache lookup encounters a fatal error, emit a warning | ||
// but continue (i.e. we fall back to running the machine) | ||
// but continue (i.e. we fall back to running the machine normally, without trying to mess w/ the cache.) | ||
self.warn(err); | ||
@@ -352,2 +431,31 @@ } | ||
// >- | ||
// | ||
// ██╗ ██╗██╗██████╗ ███████╗ ███████╗██╗ ██╗██████╗ ██╗██████╗ ███████╗██████╗ | ||
// ██║ ██║██║██╔══██╗██╔════╝ ██╔════╝╚██╗██╔╝██╔══██╗██║██╔══██╗██╔════╝██╔══██╗ | ||
// ██║ █╗ ██║██║██████╔╝█████╗ █████╗ ╚███╔╝ ██████╔╝██║██████╔╝█████╗ ██║ ██║ | ||
// ██║███╗██║██║██╔═══╝ ██╔══╝ ██╔══╝ ██╔██╗ ██╔═══╝ ██║██╔══██╗██╔══╝ ██║ ██║ | ||
// ╚███╔███╔╝██║██║ ███████╗ ███████╗██╔╝ ██╗██║ ██║██║ ██║███████╗██████╔╝ | ||
// ╚══╝╚══╝ ╚═╝╚═╝ ╚══════╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═════╝ | ||
// | ||
// ██████╗ ███████╗ ██████╗ ██████╗ ██████╗ ██████╗ ███████╗ ███████╗██████╗ ██████╗ ███╗ ███╗ | ||
// ██╔══██╗██╔════╝██╔════╝██╔═══██╗██╔══██╗██╔══██╗██╔════╝ ██╔════╝██╔══██╗██╔═══██╗████╗ ████║ | ||
// ██████╔╝█████╗ ██║ ██║ ██║██████╔╝██║ ██║███████╗ █████╗ ██████╔╝██║ ██║██╔████╔██║ | ||
// ██╔══██╗██╔══╝ ██║ ██║ ██║██╔══██╗██║ ██║╚════██║ ██╔══╝ ██╔══██╗██║ ██║██║╚██╔╝██║ | ||
// ██║ ██║███████╗╚██████╗╚██████╔╝██║ ██║██████╔╝███████║ ██║ ██║ ██║╚██████╔╝██║ ╚═╝ ██║ | ||
// ╚═╝ ╚═╝╚══════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═════╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ | ||
// | ||
// ██████╗ █████╗ ██████╗██╗ ██╗███████╗ | ||
// ██╔════╝██╔══██╗██╔════╝██║ ██║██╔════╝ | ||
// ██║ ███████║██║ ███████║█████╗ | ||
// ██║ ██╔══██║██║ ██╔══██║██╔══╝ | ||
// ╚██████╗██║ ██║╚██████╗██║ ██║███████╗ | ||
// ╚═════╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝╚══════╝ | ||
// | ||
// ██╗██╗███████╗ ██████╗ ███████╗██╗ ███████╗██╗ ██╗ █████╗ ███╗ ██╗████████╗██╗ | ||
// ██╔╝██║██╔════╝ ██╔══██╗██╔════╝██║ ██╔════╝██║ ██║██╔══██╗████╗ ██║╚══██╔══╝╚██╗ | ||
// ██║ ██║█████╗ ██████╔╝█████╗ ██║ █████╗ ██║ ██║███████║██╔██╗ ██║ ██║ ██║ | ||
// ██║ ██║██╔══╝ ██╔══██╗██╔══╝ ██║ ██╔══╝ ╚██╗ ██╔╝██╔══██║██║╚██╗██║ ██║ ██║ | ||
// ╚██╗██║██║ ██║ ██║███████╗███████╗███████╗ ╚████╔╝ ██║ ██║██║ ╚████║ ██║ ██╔╝ | ||
// ╚═╝╚═╝╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═╝ ╚═╝ | ||
// | ||
// Perform garbage collection on cache, if necessary. | ||
@@ -365,27 +473,4 @@ // | ||
Cache.count({ | ||
where: { | ||
createdAt: { | ||
'<=': _cache.expirationDate | ||
}, | ||
hash: hash | ||
} | ||
}).exec(function (err, numOldCacheEntries){ | ||
if (err) { | ||
// If this garbage collection diagnostic query encounters a fatal error, | ||
// emit a warning and then don't do anything else for now. | ||
self.warn(err); | ||
return; | ||
} | ||
// --• | ||
// If there aren't enough expired cache entries for this hash to warrant a wipe, just bail. | ||
if (numOldCacheEntries <= _cache.maxOldEntriesBuffer) { | ||
return; | ||
} | ||
// --• | ||
// Otherwise, there are enough expired cache records for this exact set of argins | ||
// to warrant a wipe. So destroy all expired cache records with this hash. | ||
Cache.destroy({ | ||
try { | ||
Cache.count({ | ||
where: { | ||
@@ -396,9 +481,8 @@ createdAt: { | ||
hash: hash | ||
}, | ||
sort: 'createdAt DESC', | ||
skip: _cache.maxOldEntriesBuffer | ||
}).exec(function (err, oldCacheEntries) { | ||
} | ||
}).exec(function (err, numOldCacheEntries){ | ||
if (err) { | ||
// If garbage collection encounters a fatal error, emit a warning | ||
// and then don't do anything else for now. | ||
// If this garbage collection diagnostic query encounters a fatal error, | ||
// emit a warning and don't try to proceed with garbage collection. | ||
// (That's because the rest of the code isn't waiting on this!!) | ||
self.warn(err); | ||
@@ -408,15 +492,87 @@ return; | ||
// --• | ||
// Sucessfully wiped all expired cache records for this exact set of argins! | ||
try { | ||
});//</.destroy() :: destroying expired cache records for this exact set of argins> | ||
});//</.count() :: counting expired cache records for this exact set of argins (to see if it's worth it to wipe them)> | ||
// --• | ||
// If there aren't enough expired cache entries for this hash to warrant a wipe, just bail. | ||
if (numOldCacheEntries <= _cache.maxOldEntriesBuffer) { | ||
return; | ||
} | ||
// --• | ||
// Otherwise, there are enough expired cache records for this exact set of argins | ||
// to warrant a wipe. So destroy all expired cache records with this hash. | ||
Cache.destroy({ | ||
where: { | ||
createdAt: { | ||
'<=': _cache.expirationDate | ||
}, | ||
hash: hash | ||
}, | ||
sort: 'createdAt DESC', | ||
skip: _cache.maxOldEntriesBuffer | ||
}).exec(function (err, oldCacheEntries) { | ||
if (err) { | ||
// If garbage collection encounters a fatal error, emit a warning | ||
// and then don't do anything else as far as garbage collection of | ||
// expired cache entries (remember, the rest of the code isn't waiting | ||
// on this!) | ||
self.warn(err); | ||
return; | ||
} | ||
// --• | ||
// Sucessfully wiped all expired cache records for this exact set of argins! | ||
});//</.destroy() :: destroying expired cache records for this exact set of argins> | ||
} catch (e) { self.warn(new Error('Consistency violation: Unexpected error when attempting to communicate with the cache via the provided model. Error details: '+e.stack+'\n- - - - - - - - - - - - - - - - - - - - - - - ')); } | ||
});//</.count() :: counting expired cache records for this exact set of argins (to see if it's worth it to wipe them)> | ||
} catch (e) { self.warn(new Error('Consistency violation: Unexpected error when attempting to communicate with the cache via the provided model. Error details: '+e.stack+'\n- - - - - - - - - - - - - - - - - - - - - - - ')); } | ||
}//</if `_cache` is truthy, then we just started destroying expired cache entries> | ||
// _∏_ | ||
// ██████╗ ██╗ ██╗██╗██╗ ██████╗ ███████╗██╗ ██╗██████╗ ██╗███╗ ██╗ ██████╗ | ||
// ██╔══██╗██║ ██║██║██║ ██╔══██╗ ██╔════╝██║ ██║██╔══██╗██║████╗ ██║██╔════╝ | ||
// ██████╔╝██║ ██║██║██║ ██║ ██║ █████╗ ██║ █╗ ██║██║ ██║██║██╔██╗ ██║██║ ███╗ | ||
// ██╔══██╗██║ ██║██║██║ ██║ ██║ ██╔══╝ ██║███╗██║██║ ██║██║██║╚██╗██║██║ ██║ | ||
// ██████╔╝╚██████╔╝██║███████╗██████╔╝ ██║ ╚███╔███╔╝██████╔╝██║██║ ╚████║╚██████╔╝ | ||
// ╚═════╝ ╚═════╝ ╚═╝╚══════╝╚═════╝ ╚═╝ ╚══╝╚══╝ ╚═════╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝ | ||
// | ||
// ██████╗ █████╗ ██╗ ██╗ ██████╗ █████╗ ██████╗██╗ ██╗███████╗ ███████╗ ██████╗ ██████╗ | ||
// ██╔════╝██╔══██╗██║ ██║ ██╔══██╗██╔══██╗██╔════╝██║ ██╔╝██╔════╝ ██╔════╝██╔═══██╗██╔══██╗ | ||
// ██║ ███████║██║ ██║ ██████╔╝███████║██║ █████╔╝ ███████╗ █████╗ ██║ ██║██████╔╝ | ||
// ██║ ██╔══██║██║ ██║ ██╔══██╗██╔══██║██║ ██╔═██╗ ╚════██║ ██╔══╝ ██║ ██║██╔══██╗ | ||
// ╚██████╗██║ ██║███████╗███████╗██████╔╝██║ ██║╚██████╗██║ ██╗███████║ ██║ ╚██████╔╝██║ ██║ | ||
// ╚═════╝╚═╝ ╚═╝╚══════╝╚══════╝╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ | ||
// | ||
// ███╗ ███╗██╗███████╗ ██████╗ ███████╗██╗ ██╗██╗████████╗███████╗ | ||
// ████╗ ████║██║██╔════╝██╔════╝ ██╔════╝╚██╗██╔╝██║╚══██╔══╝██╔════╝ | ||
// ██╔████╔██║██║███████╗██║ █████╗ ╚███╔╝ ██║ ██║ ███████╗ | ||
// ██║╚██╔╝██║██║╚════██║██║ ██╔══╝ ██╔██╗ ██║ ██║ ╚════██║ | ||
// ██║ ╚═╝ ██║██║███████║╚██████╗ ███████╗██╔╝ ██╗██║ ██║ ███████║▄█╗ | ||
// ╚═╝ ╚═╝╚═╝╚══════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚══════╝╚═╝ | ||
// | ||
// ██╗ ██████╗ ██████╗ ██╗ ██╗███╗ ██╗███████╗ | ||
// ██║ ██╔══██╗██╔══██╗██║ ██║████╗ ██║██╔════╝ | ||
// ████████╗ ██████╔╝██████╔╝██║ ██║██╔██╗ ██║█████╗ | ||
// ██╔═██╔═╝ ██╔═══╝ ██╔══██╗██║ ██║██║╚██╗██║██╔══╝ | ||
// ██████║ ██║ ██║ ██║╚██████╔╝██║ ╚████║███████╗▄█╗ | ||
// ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝╚═╝ | ||
// | ||
// ██╗ ██╗███╗ ██╗████████╗███████╗██████╗ ██████╗███████╗██████╗ ████████╗ | ||
// ██║ ██║████╗ ██║╚══██╔══╝██╔════╝██╔══██╗██╔════╝██╔════╝██╔══██╗╚══██╔══╝ | ||
// ████████╗ ██║██╔██╗ ██║ ██║ █████╗ ██████╔╝██║ █████╗ ██████╔╝ ██║ | ||
// ██╔═██╔═╝ ██║██║╚██╗██║ ██║ ██╔══╝ ██╔══██╗██║ ██╔══╝ ██╔═══╝ ██║ | ||
// ██████║ ██║██║ ╚████║ ██║ ███████╗██║ ██║╚██████╗███████╗██║ ██║ | ||
// ╚═════╝ ╚═╝╚═╝ ╚═══╝ ╚═╝ ╚══════╝╚═╝ ╚═╝ ╚═════╝╚══════╝╚═╝ ╚═╝ | ||
// | ||
// Before proceeding, ensure error exit is still configured w/ a callback. | ||
// If it is not, then get crazy and **throw** BEFORE calling the machine's `fn`. | ||
// | ||
// This is just a failsafe-- better to potentially terminate the process than | ||
// This is just yet another failsafe-- better to potentially terminate the process than | ||
// open up the possibility of silently swallowing errors later. | ||
@@ -427,4 +583,11 @@ if (!self._configuredExits.error){ | ||
// Then prune any configured exit callbacks that have `undefined` on the RHS. | ||
_.each(_.keys(self._configuredExits), function (exitCodeName) { | ||
if (self._configuredExits[exitCodeName] === undefined) { | ||
delete self._configuredExits[exitCodeName]; | ||
} | ||
});//</_.each() :: each key in dictionary of configured exit callbacks> | ||
// Fill in anonymous forwarding callbacks for any unhandled exits (ignoring the default exit) | ||
// Now, fill in anonymous forwarding callbacks for any unhandled exits (ignoring the default `success` and `error` exits) | ||
// and have them redirect to the `error` (i.e. catchall) exit | ||
@@ -491,6 +654,27 @@ _.each(_.keys(self.exits), function (exitCodeName) { | ||
// Now it's time to run the machine fn. | ||
// Now it's almost time to run the machine fn. | ||
// > Use a try/catch to protect against any unexpected errors. | ||
try { | ||
// ██████╗ ██╗ ██╗██╗██╗ ██████╗ | ||
// ██╔══██╗██║ ██║██║██║ ██╔══██╗ | ||
// ██████╔╝██║ ██║██║██║ ██║ ██║ | ||
// ██╔══██╗██║ ██║██║██║ ██║ ██║ | ||
// ██████╔╝╚██████╔╝██║███████╗██████╔╝ | ||
// ╚═════╝ ╚═════╝ ╚═╝╚══════╝╚═════╝ | ||
// | ||
// ██╗███╗ ███╗██████╗ ██╗ ███████╗███╗ ███╗███████╗███╗ ██╗████████╗ ██████╗ ██████╗ | ||
// ██║████╗ ████║██╔══██╗██║ ██╔════╝████╗ ████║██╔════╝████╗ ██║╚══██╔══╝██╔═══██╗██╔══██╗ | ||
// ██║██╔████╔██║██████╔╝██║ █████╗ ██╔████╔██║█████╗ ██╔██╗ ██║ ██║ ██║ ██║██████╔╝ | ||
// ██║██║╚██╔╝██║██╔═══╝ ██║ ██╔══╝ ██║╚██╔╝██║██╔══╝ ██║╚██╗██║ ██║ ██║ ██║██╔══██╗ | ||
// ██║██║ ╚═╝ ██║██║ ███████╗███████╗██║ ╚═╝ ██║███████╗██║ ╚████║ ██║ ╚██████╔╝██║ ██║ | ||
// ╚═╝╚═╝ ╚═╝╚═╝ ╚══════╝╚══════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═══╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ | ||
// | ||
// ███████╗██╗ ██╗██╗████████╗ ██████╗██╗ ██╗██████╗ █████╗ ██████╗██╗ ██╗ | ||
// ██╔════╝██║ ██║██║╚══██╔══╝██╔════╝██║ ██║██╔══██╗██╔══██╗██╔════╝██║ ██╔╝ | ||
// ███████╗██║ █╗ ██║██║ ██║ ██║ ███████║██████╔╝███████║██║ █████╔╝ | ||
// ╚════██║██║███╗██║██║ ██║ ██║ ██╔══██║██╔══██╗██╔══██║██║ ██╔═██╗ | ||
// ███████║╚███╔███╔╝██║ ██║ ╚██████╗██║ ██║██████╔╝██║ ██║╚██████╗██║ ██╗ | ||
// ╚══════╝ ╚══╝╚══╝ ╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ | ||
// | ||
// We'll create the ***implementor*** switchback. | ||
@@ -500,2 +684,17 @@ // (fourth argument (`true`) tells the switchback to run synchronously) | ||
// ███████╗███████╗████████╗ ████████╗██╗███╗ ███╗███████╗ ██████╗ ██╗ ██╗████████╗ | ||
// ██╔════╝██╔════╝╚══██╔══╝ ╚══██╔══╝██║████╗ ████║██╔════╝██╔═══██╗██║ ██║╚══██╔══╝ | ||
// ███████╗█████╗ ██║ ██║ ██║██╔████╔██║█████╗ ██║ ██║██║ ██║ ██║ | ||
// ╚════██║██╔══╝ ██║ ██║ ██║██║╚██╔╝██║██╔══╝ ██║ ██║██║ ██║ ██║ | ||
// ███████║███████╗ ██║ ██║ ██║██║ ╚═╝ ██║███████╗╚██████╔╝╚██████╔╝ ██║ | ||
// ╚══════╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝ ╚═════╝ ╚═════╝ ╚═╝ | ||
// | ||
// █████╗ ██╗ █████╗ ██████╗ ███╗ ███╗ | ||
// ██╔══██╗██║ ██╔══██╗██╔══██╗████╗ ████║ | ||
// ███████║██║ ███████║██████╔╝██╔████╔██║ | ||
// ██╔══██║██║ ██╔══██║██╔══██╗██║╚██╔╝██║ | ||
// ██║ ██║███████╗██║ ██║██║ ██║██║ ╚═╝ ██║ | ||
// ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ | ||
// | ||
// Before calling function, set up a `setTimeout` function that will fire | ||
@@ -548,2 +747,17 @@ // when the runtime duration exceeds the configured `timeout` property. | ||
// --• | ||
// | ||
// █████╗ ██████╗████████╗██╗ ██╗ █████╗ ██╗ ██╗ ██╗ ██╗ ██████╗ ██╗ ██╗███╗ ██╗ | ||
// ██╔══██╗██╔════╝╚══██╔══╝██║ ██║██╔══██╗██║ ██║ ╚██╗ ██╔╝ ██╔══██╗██║ ██║████╗ ██║ | ||
// ███████║██║ ██║ ██║ ██║███████║██║ ██║ ╚████╔╝ ██████╔╝██║ ██║██╔██╗ ██║ | ||
// ██╔══██║██║ ██║ ██║ ██║██╔══██║██║ ██║ ╚██╔╝ ██╔══██╗██║ ██║██║╚██╗██║ | ||
// ██║ ██║╚██████╗ ██║ ╚██████╔╝██║ ██║███████╗███████╗██║ ██║ ██║╚██████╔╝██║ ╚████║ | ||
// ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ | ||
// | ||
// ███╗ ███╗ █████╗ ██████╗██╗ ██╗██╗███╗ ██╗███████╗ ███████╗███╗ ██╗ | ||
// ████╗ ████║██╔══██╗██╔════╝██║ ██║██║████╗ ██║██╔════╝ ██╔════╝████╗ ██║ | ||
// ██╔████╔██║███████║██║ ███████║██║██╔██╗ ██║█████╗ █████╗ ██╔██╗ ██║ | ||
// ██║╚██╔╝██║██╔══██║██║ ██╔══██║██║██║╚██╗██║██╔══╝ ██╔══╝ ██║╚██╗██║ | ||
// ██║ ╚═╝ ██║██║ ██║╚██████╗██║ ██║██║██║ ╚████║███████╗ ██║ ██║ ╚████║ | ||
// ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝╚══════╝ ╚═╝ ╚═╝ ╚═══╝ | ||
// | ||
// Then call the machine's `fn`. | ||
@@ -550,0 +764,0 @@ self.fn.apply(self._configuredEnvironment, [self._configuredInputs, implementorSwitchback, self._configuredEnvironment]); |
{ | ||
"name": "machine", | ||
"version": "13.0.0-6", | ||
"version": "13.0.0-7", | ||
"description": "Configure and execute machines", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
165194
2893