Skip to content
This repository has been archived by the owner on Apr 20, 2019. It is now read-only.

[Request] Config flag to force requests to run sequentially #85

Open
WesTyler opened this issue Jun 7, 2018 · 3 comments
Open

[Request] Config flag to force requests to run sequentially #85

WesTyler opened this issue Jun 7, 2018 · 3 comments
Labels

Comments

@WesTyler
Copy link

WesTyler commented Jun 7, 2018

We are currently using bassmaster, and it's working great for us. In some testing environments though it would be super helpful for dubugging if we could force the batch requests to run sequentially rather than concurrently.

I know that the code runs the reqs sequentially when there are refs from one to the next, or in certain cases with payloads, but that would require us to make some code changes on the endpoint in just this one env. If the plugin registration config could support something like the below, it would be super awesome

const bassmasterConfig = { batchEndpoint: '/batch' };
if (process.env.NODE_ENV === 'staging') {
    bassMasterConfig.forceSequential = true;
}

await server.register({
    plugin: Bassmaster,
    options: bassMasterConfig
})

Then in the source it could do something like

module.exports.config = function (settings) {

    if (settings.forceSequential) {
        internals.forceSequential = settings.forceSequential;
    }

    return { /* no changes here*/ }
};

and

if (internals.forceSequential || internals.hasRefPart(requestParts) || payloadParts.length) {
    return fnsSerial.push(
        async () => await internals.batch(request, resultsData, idx, requestParts, payloadParts)
    );
}
@WesTyler
Copy link
Author

WesTyler commented Jun 7, 2018

Feel free to tell me no if this is an anti-goal of the plugin, or if there is a better way for us to accomplish this goal :)

Just wanted to start up the conversation, just in case.

@WesTyler
Copy link
Author

WesTyler commented Jun 8, 2018

So I went ahead and started on a PR for this, and realized I could make it even easier by making forceSequential a bool flag on the /batch request itself with a false default. That way the sequential running can be done on a per-request basis rather than a per-registration basis.

PR incoming shortly.

@cadecairos
Copy link
Contributor

Hi @WesTyler Thanks for the PR, and sorry for the radio-silence on it. I'll have a look at the PR asap.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants