Gemini.Utils.PollingHelpers (GeminiEx v0.8.8)
View SourceShared helper functions for polling operations.
These helpers are used by API modules that need to poll for operation completion (batches, tunings, documents, etc.).
Summary
Functions
Conditionally adds a key-value pair to a keyword list if value is not nil.
Check if a polling operation has timed out.
Functions
Conditionally adds a key-value pair to a keyword list if value is not nil.
Used for building optional query parameters.
Examples
iex> PollingHelpers.maybe_add([], :page_token, "abc123")
[page_token: "abc123"]
iex> PollingHelpers.maybe_add([], :page_token, nil)
[]
Check if a polling operation has timed out.
Parameters
start_time- The start time in monotonic milliseconds (fromSystem.monotonic_time(:millisecond))timeout- The timeout duration in milliseconds
Examples
iex> start = System.monotonic_time(:millisecond)
iex> PollingHelpers.timed_out?(start, 5000)
false
iex> start = System.monotonic_time(:millisecond) - 6000
iex> PollingHelpers.timed_out?(start, 5000)
true