To focus the search input from anywhere on the page, press the 'S' key.
in-package search v0.1.0
Connection manages the connection to Reddit, including authentication and rate limiting behavior.
It is responsible for taking the endpoint specifications in
Reddit_api_kernel.Api and actually performing HTTP requests.
Consider wrapping your
Connection in a
Retry_manager if you are writing a long-running process and want to just retry forever on transient errors.
Connection currently only supports the "script" app type. See Reddit's documentation on app types.
Connection enforces two different forms of rate-limiting:
HTTP rate-limiting headers
Reddit tracks API usage and requires that a client make no more than 600 requests in a 10 minute period.
Rather than simply keeping a counter of requests internally,
Connection reads Reddit's API response headers to learn about the request quota, including the number of remaining requests and the time until the quota resets. This allows multiple
Connection.ts with the same credentials to run in parallel, accounting for each others' quota usage without explicit coordination.
Minimum time between requests
In order to abide by /u/kemitche's request to "be reasonable" and not slam all 600 requests in as quickly as possible,
Connection also enforces a 100ms delay between requests.
module Credentials : sig ... end
val sexp_of_t : t -> Ppx_sexp_conv_lib.Sexp.t
val create : Credentials.t -> user_agent:string -> t
val call : t -> 'a Reddit_api_kernel.Api.t -> ('a, Reddit_api_kernel.Api.Api_error.t) Core.Result.t Async.Deferred.t
val call_exn : t -> 'a Reddit_api_kernel.Api.t -> 'a Async.Deferred.t
val call_raw : t -> 'a Reddit_api_kernel.Api.t -> (Cohttp.Response.t * Cohttp.Body.t, Core.Exn.t) Core.Result.t Async.Deferred.t
call_raw returns the raw HTTP response from Reddit, or any exception that was raised by Cohttp.
module Remote : sig ... end
Any connection can be turned into an RPC server, acting as a shared connection for multiple client
Connection.ts. Rate limiting is managed on the server side.
module For_testing : sig ... end