When using this library in a CLI tool, I like to connect a context to CTRL-C signal allowing for early interruption. The problem is that with very long second rate limit, you can get the CLI lock in a sleep that can not be interrupted which is not ideal. This PR address that problem by using the context from the request and a timer channel to handle this scenario.
This comes with test for verifying that SleepWithContext behave as expected. I have introduced the use of testify by habit mostly, but the test look nicer with it in my opinion. Let me know if you prefer a different approach for the test.
When using this library in a CLI tool, I like to connect a context to CTRL-C signal allowing for early interruption. The problem is that with very long second rate limit, you can get the CLI lock in a sleep that can not be interrupted which is not ideal. This PR address that problem by using the context from the request and a timer channel to handle this scenario.
This comes with test for verifying that SleepWithContext behave as expected. I have introduced the use of testify by habit mostly, but the test look nicer with it in my opinion. Let me know if you prefer a different approach for the test.