title: Future with RateLimiter
body: <p>Suppose I've got a simple blocking HTTP client like this:</p>
  <pre><code>def httpGet(url: URL): Future[String] = ??? 
  </code></pre>
  <p>Now I want to use <code>httpGet</code> to call a server with a request rate limit; e.g. 1000 requests/sec. Since the standard library does not provide a rate limiter I will use <a href="https://github.com/google/guava/blob/master/guava/src/com/google/common/util/concurrent/RateLimiter.java" rel="nofollow noreferrer">RateLimiter</a> of <a href="https://guava.dev/" rel="nofollow noreferrer">Guava</a>:</p>
  <pre><code>import com.google.common.util.concurrent.RateLimiter
  import scala.concurrent.{ExecutionContext, Future, blocking}
  
  def throttled[A](fut: =&gt; Future[A], rateLimiter: RateLimiter)
                  (implicit ec: ExecutionContext): Future[A] = {
    Future(blocking(rateLimiter.acquire())).flatMap(_ =&gt; fut)
  }
  
  implicit val ec = ExecutionContext.global
  val rateLimiter = RateLimiter.create(permitsPerSeconds = 1000.0)
  val throttledFuture = throttled(httpGet(url), rateLimiter)
  </code></pre>
  <p>Does it make sense ?<br />
  Would you use another execution context to execute <code>rateLimiter.acquire()</code> ?</p>