Skip to content
Merged
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
23 changes: 17 additions & 6 deletions ldclient/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,12 +464,23 @@ def is_offline(self) -> bool:
return self._config.offline

def is_initialized(self) -> bool:
"""Returns true if the client has successfully connected to LaunchDarkly.

If this returns false, it means that the client has not yet successfully connected to LaunchDarkly.
It might still be in the process of starting up, or it might be attempting to reconnect after an
unsuccessful attempt, or it might have received an unrecoverable error (such as an invalid SDK key)
and given up.
"""Returns whether the client is initialized and has flag data available to serve requests.

If this returns true, it means the client has data it can use to evaluate flags. That could be
because it connected to LaunchDarkly at least once and received flag data, or because it has
cached data from a persistent store, or because it was configured for offline or LDD (daemon)
mode. It could still have encountered a connection problem after that point, and cached data may
not be current, so this does not guarantee that the flag data is up to date; if you need to know
the connection status in more detail, use :attr:`data_source_status_provider`.

If this returns false, it means the client has not yet obtained any flag data. It might still be
starting up, or attempting to reconnect after an unsuccessful attempt, or it might have received
an unrecoverable error (such as an invalid SDK key) and given up. In this state, feature flag
evaluations will return default values -- unless you are using a persistent store integration and

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part about persistent stores conflicts or at least can be a little confusing here since it is mentioned in the paragraph when it returns true.

flag data had already been stored by a successfully connected SDK in the past. You can use
:attr:`data_source_status_provider` to get information on errors, or to wait for a successful retry.

:return: true if the client is initialized and has flag data available
"""
if self.is_offline() or self._config.use_ldd:
return True
Expand Down
Loading