Gamend.HTTP (gamend_core v1.0.1296)

Copy Markdown View Source

Req with the declared timeout and retries, for the calls core makes to other services while a player waits: payment receipt checks (Apple, Google Play, Steam), OAuth code exchanges, Google ID-token checks and avatar mirroring.

Req's own defaults suit a script, not a request handler: 15 seconds a try and, for a GET, three retries with backoff, so one slow provider held a login or a purchase check open for about a minute. Here each try waits client_timeout_ms and a failed GET is retried client_retries times. A POST is not retried, as in Req.

get/2 and post/2 take what Req.get/2 and Req.post/2 take, so this module drops in wherever a module takes an injectable HTTP client. Options a caller passes win over the declared ones.

Summary

Functions

Req.get/2 with the declared timeout and retries.

The declared timeout and retry options, with opts over them.

Req.post/2 with the declared timeout and retries.

Functions

get(url, opts \\ [])

@spec get(String.t() | URI.t(), keyword()) ::
  {:ok, Req.Response.t()} | {:error, Exception.t()}

Req.get/2 with the declared timeout and retries.

options(opts \\ [])

@spec options(keyword()) :: keyword()

The declared timeout and retry options, with opts over them.

config :gamend_core, Gamend.HTTP, req_options: [...] is merged in too, so a test can route every provider call through a Req.Test stub. Empty in prod.

post(url, opts \\ [])

@spec post(String.t() | URI.t(), keyword()) ::
  {:ok, Req.Response.t()} | {:error, Exception.t()}

Req.post/2 with the declared timeout and retries.