bench-rest icon indicating copy to clipboard operation
bench-rest copied to clipboard

Client Polling

Open sellis opened this issue 9 years ago • 3 comments

Hi Jeff,

Great node module you made here! Very impressive work.

I have a rest work flow that involves a client starting with a post request to submit a job, getting redirected to a job status page, and then polling that page (get) until a certain json element on it has the value "Complete".

I see everything I need in your API except the client polling part.

I don't see a way to tell bench-rest to loop and perform the same get request over and over again in the after hook until the verification step passes (job is complete). Maybe I'm missing something

Any advice you have would be most appreciated.

Thanks again for a creating a great node module!

Cheers, Scott Ellis

sellis avatar Sep 15 '15 15:09 sellis

Thanks Scott.

I don't currently have a way to do polling in the flow. The hooks API is synchronous so it doesn't have a way to poll.

I did create an experimental branch for another user which you can install using npm install jeffbski/bench-rest#delayAfter which adds a delayAfter option in milliseconds that it will delay before doing the next item in the flow.

So if you can have it delay x msecs then continue and hopefully the item is there.

I'm not sure this is a good solution since under load it can vary how long it takes for something to complete. So polling like you mentioned would be better, but I'm not sure about benchmarking with something like that. It seems like if it ends up taking an extra poll or two for something to show up the benchmarking would be all over the place.

I'll give it some thought, but I'm not sure I have a good idea about a solution.

jeffbski avatar Sep 16 '15 00:09 jeffbski

Thanks a lot for your response Jeff. I understand the complications. I wonder if it would be possible to call the before and after hooks in an async manner?

sellis avatar Sep 17 '15 22:09 sellis

@sellis I guess that might be a possibility. Let me go down that route and see if that will work.

jeffbski avatar Sep 18 '15 10:09 jeffbski