Here’s the translation of the Go rate limiting example to Scheme, formatted in Markdown suitable for Hugo:
Rate limiting is an important mechanism for controlling resource utilization and maintaining quality of service. Scheme can implement rate limiting using threads and synchronization primitives.
Running our program, we would see the first batch of requests handled once every ~200 milliseconds as desired.
For the second batch of requests, we would serve the first 3 immediately because of the burstable rate limiting, then serve the remaining 2 with some delay between them.
Note that Scheme doesn’t have built-in concurrency primitives like Go’s goroutines and channels. Instead, we’ve used a queue to simulate the channel behavior and implemented custom functions for rate limiting. The time related functions are also implementation-dependent and may vary based on the Scheme implementation you’re using.
This example demonstrates how to implement basic and bursty rate limiting in Scheme, achieving similar functionality to the original Go example.