Here’s the translation of the rate limiting example from Go to Lisp, formatted in Markdown suitable for Hugo:
Rate limiting is an important mechanism for controlling resource utilization and maintaining quality of service. Common Lisp supports rate limiting through the use of threads and timing functions.
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 ~200ms delays each.
This Lisp implementation uses the bordeaux-threads library for threading and the local-time library for timestamp operations. The make-queue, enqueue, dequeue, and queue-empty-p functions are assumed to be implemented elsewhere or could be replaced with a standard Lisp list for simplicity.
The token bucket algorithm is used to implement the bursty limiter, which allows for short bursts of requests while maintaining the overall rate limit. This approach is more idiomatic in Lisp compared to the channel-based approach in the original example.
Note that the exact timing and output format may differ slightly from the original due to differences in how Lisp and Go handle concurrency and time, but the core concepts of rate limiting are preserved.