Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Easy way to disable batcher for development and testing #13

Closed
sarg3nt opened this issue Apr 17, 2015 · 6 comments
Closed

Easy way to disable batcher for development and testing #13

sarg3nt opened this issue Apr 17, 2015 · 6 comments

Comments

@sarg3nt
Copy link

sarg3nt commented Apr 17, 2015

I've ran into a case where the batcher is breaking our login checking system. As part of troubleshooting this I wanted to shut off the batcher but can't find an easy of doing so (without commenting out the main js file, the config js file and the line where we inject it into the app, which is kind of painful.
Is there a way to do this in the config? I tried setting maxBatchedRequestPerCall to 1 but that didn't do it.
If not, can we get a config option that would completely turn off batching for testing?

@jonsamwell
Copy link
Owner

This seems sensible although I would have thought setting maxBatchedRequestPerCall to 0 would have done the trick. Let me investigate.

Jon

@sarg3nt
Copy link
Author

sarg3nt commented Apr 20, 2015

Me too, but it doesn't instead it batches each request into a single one to /batch

@sarg3nt sarg3nt closed this as completed Apr 20, 2015
@sarg3nt sarg3nt reopened this Apr 20, 2015
@sarg3nt
Copy link
Author

sarg3nt commented Apr 20, 2015

Whops sorry, that close and comment button is way to easy to hit.

@sarg3nt
Copy link
Author

sarg3nt commented Apr 24, 2015

This was becoming more and more of an issue as we troubhshoot things so I mucked around in your code and did the following:

this.canBatchCall = function (url, method) {
            var config = this.getBatchConfig(url);
            return config !== undefined &&
                config.batchEndpointUrl !== url &&
                config.ignoredVerbs.indexOf(method.toLowerCase()) === -1 &&
                config.maxBatchedRequestPerCall > 0;
        };

See the last line. If maxBatchedRequestPerCall is zero, it will now not batch the any requests.
Not sure if that's the way you would do it or not, but works for me for now.

@jonsamwell
Copy link
Owner

This seems a reasonable approach. Sorry I have been so busy lately at work and outside. Things are starting to settle down from next week so I will be able to tackle these issues.

@jonsamwell
Copy link
Owner

The config option now has an enabled flag. Set to false to disable.

    app.config([
            'httpBatchConfigProvider',
            function (httpBatchConfigProvider) {
                httpBatchConfigProvider.setAllowedBatchEndpoint(
                        'http://localhost:8080',
                        'http://localhost:8080/api/batch', {
                            batchRequestCollectionDelay: 500,
                            minimumBatchSize: 2,
                            sendCookies: true,
                            enabled: false
                        });
            }
    ]);

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

No branches or pull requests

2 participants