I have a function that handles multiple transactional requests. So response to each request should be within 5 seconds.
I don’t quite understand this question. Could you please describe in more detail how the flow of control shall work?
- How is initating the transactions?
- At the same time or at different times?
- Can the happen one after the other or do the have to happen parallel?
- Does ‘response’ mean a response from each transaction or an overall response?
There is a universal function that receives transactions anytime of day.
I want this function to serve response parallely to each transaction not sequentially within 5 seconds.
If this function is taking longer than 5 seconds to response to any of the parallel transactions, I want to return false immediately.
Maybe you want something like this : https://play.golang.org/p/BMYpJ2cRj0r
The principle is to run asyncronously your transaction and launch a “timer” in parallel.
The first to complete will send a message that will be captured by the select block.
You’ve got the idea. Play with the pause time in the function to verify the timeout occurs correctly.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.