(Unless you're using the payload as a stream.)
I find that using the payload as a string is quite awkward as it means another layer of indirection to either promise or concat the stream. It would be nice to be able to register the worker such that you get the payload at initial call time. In that scenario the task wouldn't be readable, but it would still be writable. There are a few ways we might do this... a task.payload property or an additional argument to the callback both come to mind.
I kind of want to just trigger off of the callback's function signature, even though my "maybe this is too magical" alarm is going off:
gm.registerWorker('test', function (task) {
// Task is exactly as today, a readable, writable stream that can
// also be resolved as a promise
});
gm.registerWorker('test', function (task,payload) {
// Task is a writable stream only, with no promise
});
Alternatively we could pass in an option, for example:
gm.registerWorker('test',{nostream: true}, function (task,payload) {
(Unless you're using the payload as a stream.)
I find that using the payload as a string is quite awkward as it means another layer of indirection to either promise or concat the stream. It would be nice to be able to register the worker such that you get the payload at initial call time. In that scenario the task wouldn't be readable, but it would still be writable. There are a few ways we might do this... a task.payload property or an additional argument to the callback both come to mind.
I kind of want to just trigger off of the callback's function signature, even though my "maybe this is too magical" alarm is going off:
Alternatively we could pass in an option, for example: