Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions lib/ldclient-rb/impl/data_source/status_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,11 @@ def status
end

#
# The current status together with the seconds the data source has spent
# in its current state, read atomically under one lock acquisition so the
# duration can never be paired with a stale state.
# Returns the current status and the seconds it has been in that state.
#
# The duration is measured on the monotonic clock, so a wall-clock step
# cannot distort it. `status.state_since` remains the wall-clock time
# reported to applications; this duration is the value to use when it
# decides behavior.
# One lock acquisition keeps the pair consistent. The seconds are
# monotonic — use them for duration decisions instead of arithmetic on
# the wall-clock `state_since`.
#
# @private
# @return [Array(LaunchDarkly::Interfaces::DataSource::Status, Float)]
Expand Down
6 changes: 6 additions & 0 deletions lib/ldclient-rb/impl/data_system/fdv2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,9 @@ def record_environment_id(environment_id)
#
# Determine if we should fallback to the next synchronizer.
#
# The caller supplies the elapsed time because the monotonic baseline is
# private to the status provider; see StatusProviderV2#status_and_seconds_in_state.
#
# @param status [LaunchDarkly::Interfaces::DataSource::Status] Current data source status
# @param seconds_in_state [Float] monotonic seconds spent in status.state
# @return [Boolean] true if fallback condition is met
Expand All @@ -531,6 +534,9 @@ def fallback_condition(status, seconds_in_state)
#
# Determine if we should recover to the primary synchronizer.
#
# The caller supplies the elapsed time because the monotonic baseline is
# private to the status provider; see StatusProviderV2#status_and_seconds_in_state.
#
# @param status [LaunchDarkly::Interfaces::DataSource::Status] Current data source status
# @param seconds_in_state [Float] monotonic seconds spent in status.state
# @return [Boolean] true if recovery condition is met (healthy for too long)
Expand Down
Loading