def __init__(self, sdk_key, config=None, start_wait=5): check_uwsgi() self._sdk_key = sdk_key self._config = config or Config.default() self._session = CacheControl(requests.Session()) self._queue = queue.Queue(self._config.events_max_pending) self._event_consumer = None self._lock = Lock() self._store = self._config.feature_store """ :type: FeatureStore """ if self._config.offline: self._config.events_enabled = False log.info("Started LaunchDarkly Client in offline mode") return if self._config.events_enabled: self._event_consumer = self._config.event_consumer_class( self._queue, self._sdk_key, self._config) self._event_consumer.start() if self._config.use_ldd: if self._store.__class__ == "RedisFeatureStore": log.info("Started LaunchDarkly Client in LDD mode") return log.error("LDD mode requires a RedisFeatureStore.") return if self._config.feature_requester_class: self._feature_requester = self._config.feature_requester_class( sdk_key, self._config) else: self._feature_requester = FeatureRequesterImpl(sdk_key, self._config) """ :type: FeatureRequester """ update_processor_ready = threading.Event() if self._config.update_processor_class: self._update_processor = self._config.update_processor_class( sdk_key, self._config, self._feature_requester, self._store, update_processor_ready) else: if self._config.stream: self._update_processor = StreamingUpdateProcessor( sdk_key, self._config, self._feature_requester, self._store, update_processor_ready) else: self._update_processor = PollingUpdateProcessor( sdk_key, self._config, self._feature_requester, self._store, update_processor_ready) """ :type: UpdateProcessor """ self._update_processor.start() log.info("Waiting up to " + str(start_wait) + " seconds for LaunchDarkly client to initialize...") update_processor_ready.wait(start_wait) if self._update_processor.initialized: log.info("Started LaunchDarkly Client: OK") else: log.info("Initialization timeout exceeded for LaunchDarkly Client. Feature Flags may not yet be available.")
def __init__(self, sdk_key=None, config=None, start_wait=5): """Constructs a new LDClient instance. :param string sdk_key: the SDK key for your LaunchDarkly environment :param ldclient.config.Config config: optional custom configuration :param float start_wait: the number of seconds to wait for a successful connection to LaunchDarkly """ check_uwsgi() if config is not None and config.sdk_key is not None and sdk_key is not None: raise Exception( "LaunchDarkly client init received both sdk_key and config with sdk_key. " "Only one of either is expected") if sdk_key is not None: log.warning( "Deprecated sdk_key argument was passed to init. Use config object instead." ) self._config = Config(sdk_key=sdk_key) else: self._config = config or Config.default() self._config._validate() self._event_processor = None self._lock = Lock() self._event_factory_default = _EventFactory(False) self._event_factory_with_reasons = _EventFactory(True) self._store = _FeatureStoreClientWrapper(self._config.feature_store) """ :type: FeatureStore """ if self._config.offline: log.info("Started LaunchDarkly Client in offline mode") if self._config.use_ldd: log.info("Started LaunchDarkly Client in LDD mode") diagnostic_accumulator = self._set_event_processor(self._config) update_processor_ready = threading.Event() self._update_processor = self._make_update_processor( self._config, self._store, update_processor_ready, diagnostic_accumulator) self._update_processor.start() if start_wait > 0 and not self._config.offline and not self._config.use_ldd: log.info("Waiting up to " + str(start_wait) + " seconds for LaunchDarkly client to initialize...") update_processor_ready.wait(start_wait) if self._update_processor.initialized() is True: log.info("Started LaunchDarkly Client: OK") else: log.warning( "Initialization timeout exceeded for LaunchDarkly Client or an error occurred. " "Feature Flags may not yet be available.")
def __init__(self, config: Config, start_wait: float = 5): """Constructs a new LDClient instance. :param config: optional custom configuration :param start_wait: the number of seconds to wait for a successful connection to LaunchDarkly """ check_uwsgi() self._config = config self._config._validate() self._event_processor = None self._lock = Lock() self._event_factory_default = _EventFactory(False) self._event_factory_with_reasons = _EventFactory(True) self._store = _FeatureStoreClientWrapper(self._config.feature_store) """ :type: FeatureStore """ if self._config.offline: log.info("Started LaunchDarkly Client in offline mode") if self._config.use_ldd: log.info("Started LaunchDarkly Client in LDD mode") diagnostic_accumulator = self._set_event_processor(self._config) update_processor_ready = threading.Event() self._update_processor = self._make_update_processor( self._config, self._store, update_processor_ready, diagnostic_accumulator) self._update_processor.start() if start_wait > 0 and not self._config.offline and not self._config.use_ldd: log.info("Waiting up to " + str(start_wait) + " seconds for LaunchDarkly client to initialize...") update_processor_ready.wait(start_wait) if self._update_processor.initialized() is True: log.info("Started LaunchDarkly Client: OK") else: log.warning( "Initialization timeout exceeded for LaunchDarkly Client or an error occurred. " "Feature Flags may not yet be available.")
def __init__(self, api_key, config=None): check_uwsgi() self._api_key = api_key self._config = config or Config.default() self._session = CacheControl(requests.Session()) self._queue = queue.Queue(self._config.capacity) self._consumer = None self._offline = False self._lock = Lock() self._store = config.feature_store_class() """ :type: FeatureStore """ self._feature_requester = config.feature_requester_class(api_key, config) """ :type: FeatureRequester """ self._stream_processor = None if self._config.stream: self._stream_processor = config.stream_processor_class(api_key, config, self._store) self._stream_processor.start()
def __init__(self, api_key, config=None): check_uwsgi() self._api_key = api_key self._config = config or Config.default() self._session = CacheControl(requests.Session()) self._queue = queue.Queue(self._config.capacity) self._consumer = None self._offline = False self._lock = Lock() self._store = config.feature_store_class() """ :type: FeatureStore """ self._feature_requester = config.feature_requester_class( api_key, config) """ :type: FeatureRequester """ self._stream_processor = None if self._config.stream: self._stream_processor = config.stream_processor_class( api_key, config, self._store) self._stream_processor.start()
def __init__(self, sdk_key=None, config=None, start_wait=5): """Constructs a new LDClient instance. :param string sdk_key: the SDK key for your LaunchDarkly environment :param ldclient.config.Config config: optional custom configuration :param float start_wait: the number of seconds to wait for a successful connection to LaunchDarkly """ check_uwsgi() if config is not None and config.sdk_key is not None and sdk_key is not None: raise Exception( "LaunchDarkly client init received both sdk_key and config with sdk_key. " "Only one of either is expected") if sdk_key is not None: log.warn( "Deprecated sdk_key argument was passed to init. Use config object instead." ) self._config = Config(sdk_key=sdk_key) else: self._config = config or Config.default() self._config._validate() self._event_processor = None self._lock = Lock() self._store = _FeatureStoreClientWrapper(self._config.feature_store) """ :type: FeatureStore """ if self._config.offline or not self._config.send_events: self._event_processor = NullEventProcessor() else: self._event_processor = self._config.event_processor_class( self._config) if self._config.offline: log.info("Started LaunchDarkly Client in offline mode") return if self._config.use_ldd: log.info("Started LaunchDarkly Client in LDD mode") return update_processor_ready = threading.Event() if self._config.update_processor_class: log.info("Using user-specified update processor: " + str(self._config.update_processor_class)) self._update_processor = self._config.update_processor_class( self._config, self._store, update_processor_ready) else: if self._config.feature_requester_class: feature_requester = self._config.feature_requester_class( self._config) else: feature_requester = FeatureRequesterImpl(self._config) """ :type: FeatureRequester """ if self._config.stream: self._update_processor = StreamingUpdateProcessor( self._config, feature_requester, self._store, update_processor_ready) else: log.info("Disabling streaming API") log.warn( "You should only disable the streaming API if instructed to do so by LaunchDarkly support" ) self._update_processor = PollingUpdateProcessor( self._config, feature_requester, self._store, update_processor_ready) """ :type: UpdateProcessor """ self._update_processor.start() log.info("Waiting up to " + str(start_wait) + " seconds for LaunchDarkly client to initialize...") update_processor_ready.wait(start_wait) if self._update_processor.initialized() is True: log.info("Started LaunchDarkly Client: OK") else: log.warn( "Initialization timeout exceeded for LaunchDarkly Client or an error occurred. " "Feature Flags may not yet be available.")
def __init__(self, sdk_key=None, config=None, start_wait=5): check_uwsgi() if config is not None and config.sdk_key is not None and sdk_key is not None: raise Exception( "LaunchDarkly client init received both sdk_key and config with sdk_key. " "Only one of either is expected") if sdk_key is not None: log.warn( "Deprecated sdk_key argument was passed to init. Use config object instead." ) self._config = Config(sdk_key=sdk_key) else: self._config = config or Config.default() self._config._validate() self._session = CacheControl(requests.Session()) self._queue = queue.Queue(self._config.events_max_pending) self._event_consumer = None self._lock = Lock() self._store = self._config.feature_store """ :type: FeatureStore """ if self._config.offline: log.info("Started LaunchDarkly Client in offline mode") return if self._config.events_enabled: self._event_consumer = self._config.event_consumer_class( self._queue, self._config) self._event_consumer.start() if self._config.use_ldd: log.info("Started LaunchDarkly Client in LDD mode") return if self._config.feature_requester_class: self._feature_requester = self._config.feature_requester_class( self._config) else: self._feature_requester = FeatureRequesterImpl(self._config) """ :type: FeatureRequester """ update_processor_ready = threading.Event() if self._config.update_processor_class: log.info("Using user-specified update processor: " + str(self._config.update_processor_class)) self._update_processor = self._config.update_processor_class( self._config, self._feature_requester, self._store, update_processor_ready) else: if self._config.stream: self._update_processor = StreamingUpdateProcessor( self._config, self._feature_requester, self._store, update_processor_ready) else: self._update_processor = PollingUpdateProcessor( self._config, self._feature_requester, self._store, update_processor_ready) """ :type: UpdateProcessor """ self._update_processor.start() log.info("Waiting up to " + str(start_wait) + " seconds for LaunchDarkly client to initialize...") update_processor_ready.wait(start_wait) if self._update_processor.initialized() is True: log.info("Started LaunchDarkly Client: OK") else: log.warn( "Initialization timeout exceeded for LaunchDarkly Client or an error occurred. " "Feature Flags may not yet be available.")