Guardsix.Core.SearchRunner (guardsix v1.2.2)

Copy Markdown View Source

Blocking polling for Guardsix searches.

The Guardsix search API is asynchronous — submit a query, then poll for results. run/3 handles the polling loop, including resubmitting expired searches automatically.

Summary

Functions

Run a search and block until final results arrive.

Functions

run(client, query, opts \\ [])

@spec run(Guardsix.Data.Client.t(), Guardsix.Data.SearchParams.t(), keyword()) ::
  {:ok, map()} | {:error, term()}

Run a search and block until final results arrive.

Polls Search.get_result/2 until the response contains "final" => true. When the API returns a "Forgotten search" error (expired search), the original query is resubmitted automatically.

Options

  • :polling_interval — milliseconds between polls (default: 1000)
  • :max_attempts — maximum poll iterations (default: 30)

Examples

{:ok, result} = SearchRunner.run(client, query)
{:ok, result} = SearchRunner.run(client, query, polling_interval: 2_000, max_attempts: 30)