HTTP client for the Fly Machines log API.
Fetches from GET https://api.machines.dev/v1/apps/{app_name}/logs and
parses the NDJSON body into ExAtlas.Fly.Logs.LogEntry structs.
The base URL is overridable via config :ex_atlas, :fly, log_endpoint: "..."
or the :base_url option (useful for Bypass in tests).
Summary
Functions
Fetches logs for app_name using token.
Fetches logs with a single 401-driven retry.
Returns the next start_time cursor value for pagination.
Functions
@spec fetch_logs(String.t(), String.t(), keyword()) :: {:ok, [ExAtlas.Fly.Logs.LogEntry.t()]} | {:error, term()}
Fetches logs for app_name using token.
Options
:region— filter by Fly region code.:instance— filter by machine instance id.:start_time— integer nanoseconds-since-epoch, for pagination.:base_url— override the endpoint (default::ex_atlas, :fly, log_endpointorhttps://api.machines.dev/v1/apps).:timeout_ms— request timeout.:http_client— optional(url, headers) -> {:ok, status, body} | {:error, reason}override. When omitted, usesReq.
@spec fetch_logs_with_retry( String.t(), keyword() ) :: {:ok, [ExAtlas.Fly.Logs.LogEntry.t()]} | {:error, term()}
Fetches logs with a single 401-driven retry.
If the server returns 401, the token is invalidated, a new one is acquired, and the fetch is retried once.
Options
:token_fn—(app_name -> {:ok, token} | {:error, reason}). Defaults toExAtlas.Fly.Tokens.get/1.:invalidate_fn—(app_name -> :ok). Defaults toExAtlas.Fly.Tokens.invalidate/1.- All other options pass through to
fetch_logs/3.
@spec next_start_time([ExAtlas.Fly.Logs.LogEntry.t()]) :: non_neg_integer() | nil
Returns the next start_time cursor value for pagination.
Given a list of LogEntry structs, returns the max timestamp in nanoseconds
plus 1 (to avoid re-fetching the last entry). Returns nil for an empty list.