enforce asynchrony in new database offset methods

pull/1/head
ansuz 4 years ago
parent 466072d03b
commit d4e6d86961

@ -1222,17 +1222,18 @@ module.exports.create = function (conf, _cb) {
// OFFSETS // OFFSETS
// these exist strictly as an optimization // these exist strictly as an optimization
// you can always remove them without data loss // you can always remove them without data loss
clearOffset: function (channelName, cb) { clearOffset: function (channelName, _cb) {
var cb = Util.once(Util.mkAsync(_cb));
if (!isValidChannelId(channelName)) { return void cb(new Error('EINVAL')); } if (!isValidChannelId(channelName)) { return void cb(new Error('EINVAL')); }
clearOffset(env, channelName, cb); clearOffset(env, channelName, cb);
}, },
writeOffset: function (channelName, data, _cb) { writeOffset: function (channelName, data, _cb) {
var cb = Util.mkAsync(_cb); var cb = Util.once(Util.mkAsync(_cb));
if (!isValidChannelId(channelName)) { return void cb(new Error('EINVAL')); } if (!isValidChannelId(channelName)) { return void cb(new Error('EINVAL')); }
writeOffset(env, channelName, data, cb); writeOffset(env, channelName, data, cb);
}, },
getOffset: function (channelName, _cb) { getOffset: function (channelName, _cb) {
var cb = Util.mkAsync(_cb); var cb = Util.once(Util.mkAsync(_cb));
if (!isValidChannelId(channelName)) { return void cb(new Error('EINVAL')); } if (!isValidChannelId(channelName)) { return void cb(new Error('EINVAL')); }
getOffset(env, channelName, cb); getOffset(env, channelName, cb);
}, },

Loading…
Cancel
Save