mixmaxhq/batchelor

Concurrency issues?

bradvogel opened this issue · 4 comments

I'm running a HTTP server that accepts user requests. So I'm trying to use multiple instances of Batchelor to service different users. However, the API is entirely singleton, so calling Batchelor.init() with a different user will overwrite the previous call.

What's your recommended way to create two instances of Batchelor at the same time?

I fixed this locally here: https://github.com/mixmaxhq/batchelor/pull/1/files?w=1, but it's a breaking API change. Let me know if you'd like me to submit a PR for that (although it'll require readme changes also).

The new API would be:

var batchelor = new Batchelor({
    'uri':'https://www.googleapis.com/batch',
    'method':'POST',
    'auth': {
        'bearer': [... Google API Token ...]
    },
    'headers': {
        'Content-Type': 'multipart/mixed;'
    }
});

batchelor.add()...

@bradvogel Have invite you to contribute. Feel free to add a new branch for version 1 and include your changes in that. We'll make that a major release feature.

Cheers Bud.