Fivetrex.Models.SyncStatus (Fivetrex v0.2.1)
View SourceRepresents the sync status summary for a Fivetran Connector.
This struct provides a structured view of a connector's current sync state,
including timing information and sync progress. It's returned by
Fivetrex.Connectors.get_sync_status/2.
Fields
:sync_state- Current sync state of the connector:succeeded_at- DateTime of the last successful sync (parsed from ISO 8601):failed_at- DateTime of the last failed sync (parsed from ISO 8601):is_historical_sync- Whether a historical sync is currently in progress:update_state- The update status of the connector
Sync State Values
The :sync_state field can be one of:
"syncing"- Connector is actively syncing data"scheduled"- Connector is waiting for its next scheduled sync"paused"- Connector has been manually paused"rescheduled"- Sync was rescheduled (e.g., due to rate limiting)
Update State Values
The :update_state field indicates the connector's update status:
"on_schedule"- Connector is syncing on its normal schedule"delayed"- Connector sync is delayed
Helper Functions
This module provides helper functions to check sync state:
if SyncStatus.syncing?(status) do
IO.puts("Sync in progress...")
end
if SyncStatus.paused?(status) do
IO.puts("Connector is paused")
endExamples
{:ok, status} = Fivetrex.Connectors.get_sync_status(client, "connector_id")
IO.puts("Current state: #{status.sync_state}")
IO.puts("Last success: #{status.succeeded_at}")
if SyncStatus.syncing?(status) do
IO.puts("Sync in progress...")
endSee Also
Fivetrex.Connectors.get_sync_status/2- Retrieves sync status for a connectorFivetrex.Models.Connector- The full connector struct
Summary
Functions
Creates a SyncStatus struct from a Connector struct.
Returns true if the sync state is "paused".
Returns true if the sync state is "scheduled".
Returns true if the sync state is "syncing".
Types
@type t() :: %Fivetrex.Models.SyncStatus{ failed_at: DateTime.t() | nil, is_historical_sync: boolean() | nil, succeeded_at: DateTime.t() | nil, sync_state: String.t() | nil, update_state: String.t() | nil }
A sync status summary struct.
All fields may be nil if not provided in the API response.
Functions
@spec from_connector(Fivetrex.Models.Connector.t()) :: t()
Creates a SyncStatus struct from a Connector struct.
Extracts the relevant sync status fields from a full Connector struct.
Parameters
connector- A%Fivetrex.Models.Connector{}struct
Returns
A %Fivetrex.Models.SyncStatus{} struct with fields populated from the connector.
Examples
iex> connector = %Fivetrex.Models.Connector{
...> status: %{"sync_state" => "syncing", "is_historical_sync" => false, "update_state" => "on_schedule"},
...> succeeded_at: "2024-01-01T00:00:00Z",
...> failed_at: nil
...> }
iex> status = Fivetrex.Models.SyncStatus.from_connector(connector)
iex> status.sync_state
"syncing"
iex> status.succeeded_at
~U[2024-01-01 00:00:00Z]
Returns true if the sync state is "paused".
Parameters
status- A%Fivetrex.Models.SyncStatus{}struct
Returns
true- If the connector is pausedfalse- If the connector is not paused
Examples
iex> status = %Fivetrex.Models.SyncStatus{sync_state: "paused"}
iex> Fivetrex.Models.SyncStatus.paused?(status)
true
iex> status = %Fivetrex.Models.SyncStatus{sync_state: "syncing"}
iex> Fivetrex.Models.SyncStatus.paused?(status)
false
Returns true if the sync state is "scheduled".
Parameters
status- A%Fivetrex.Models.SyncStatus{}struct
Returns
true- If the connector is scheduled for syncfalse- If the connector is not in scheduled state
Examples
iex> status = %Fivetrex.Models.SyncStatus{sync_state: "scheduled"}
iex> Fivetrex.Models.SyncStatus.scheduled?(status)
true
iex> status = %Fivetrex.Models.SyncStatus{sync_state: "syncing"}
iex> Fivetrex.Models.SyncStatus.scheduled?(status)
false
Returns true if the sync state is "syncing".
Parameters
status- A%Fivetrex.Models.SyncStatus{}struct
Returns
true- If the connector is actively syncing datafalse- If the connector is not syncing
Examples
iex> status = %Fivetrex.Models.SyncStatus{sync_state: "syncing"}
iex> Fivetrex.Models.SyncStatus.syncing?(status)
true
iex> status = %Fivetrex.Models.SyncStatus{sync_state: "scheduled"}
iex> Fivetrex.Models.SyncStatus.syncing?(status)
false