Fivetrex.Models.SyncStatus (Fivetrex v0.2.1)

View Source

Represents 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")
end

Examples

{: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...")
end

See Also

Summary

Types

t()

A sync status summary struct.

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

t()

@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

from_connector(connector)

@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]

paused?(sync_status)

@spec paused?(t()) :: boolean()

Returns true if the sync state is "paused".

Parameters

  • status - A %Fivetrex.Models.SyncStatus{} struct

Returns

  • true - If the connector is paused
  • false - 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

scheduled?(sync_status)

@spec scheduled?(t()) :: boolean()

Returns true if the sync state is "scheduled".

Parameters

  • status - A %Fivetrex.Models.SyncStatus{} struct

Returns

  • true - If the connector is scheduled for sync
  • false - 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

syncing?(sync_status)

@spec syncing?(t()) :: boolean()

Returns true if the sync state is "syncing".

Parameters

  • status - A %Fivetrex.Models.SyncStatus{} struct

Returns

  • true - If the connector is actively syncing data
  • false - 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