Ë
    ÿ\jg7  ã                   óà   — d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZmZmZmZmZ  G d„ d«      Z G d„ d«      Z G d„ d«      Z G d„ d«      Zy)zv
This submodule contains factory/configuration methods for integrating the SDK with services
other than LaunchDarkly.
é    )ÚCacheConfig)ÚCachingStoreWrapper)Ú_ConsulFeatureStoreCore©Ú_DynamoDBBigSegmentStore)Ú_DynamoDBFeatureStoreCore©Ú_FileDataSource©Ú_RedisBigSegmentStore)Ú_RedisFeatureStoreCore)ÚBigSegmentStore)ÚAnyÚDictÚListÚMappingÚOptionalc                   ój   — e Zd ZdZ	 dZedddd ej                  «       fdede	dede
ded	efd
„«       Zy)ÚConsulzWProvides factory methods for integrations between the LaunchDarkly SDK and Consul.
    ÚlaunchdarklyNÚhostÚportÚprefixÚconsul_optsÚcachingÚreturnc                 ó6   — t        | |||«      }t        ||«      S )aE  Creates a Consul-backed implementation of :class:`ldclient.interfaces.FeatureStore`.
        For more details about how and why you can use a persistent feature store, see the
        `SDK reference guide <https://docs.launchdarkly.com/sdk/concepts/data-stores>`_.

        To use this method, you must first install the ``python-consul`` package. Then, put the object
        returned by this method into the ``feature_store`` property of your client configuration
        (:class:`ldclient.config.Config`).
        ::

            from ldclient.integrations import Consul
            store = Consul.new_feature_store()
            config = Config(feature_store=store)

        :param host: hostname of the Consul server (uses ``localhost`` if omitted)
        :param port: port of the Consul server (uses 8500 if omitted)
        :param prefix: a namespace prefix to be prepended to all Consul keys
        :param consul_opts: optional parameters for configuring the Consul client, if you need
          to set any of them besides host and port, as defined in the
          `python-consul API <https://python-consul.readthedocs.io/en/latest/#consul>`_
        :param caching: specifies whether local caching should be enabled and if so,
          sets the cache properties; defaults to :func:`ldclient.feature_store.CacheConfig.default()`
        )r   r   )r   r   r   r   r   Úcores         úH/root/env/lib/python3.12/site-packages/ldclient/integrations/__init__.pyÚnew_feature_storezConsul.new_feature_store   s!   € ô8 ' t¨T°6¸;ÓGˆÜ" 4¨Ó1Ð1ó    )Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚDEFAULT_PREFIXÚstaticmethodr   ÚdefaultÚstrÚintÚdictr   r    © r!   r   r   r      su   „ ñð AØ#€NàØ$(Ø$(Ø&*Ø,0Ø/B¨{×/BÑ/BÓ/Dñ	2 ð 2Ø #ð2à"%ð2ð (,ð2ð $/ð	2ð J]ò	2ó ñ2r!   r   c                   ó    — e Zd ZdZedi  ej                  «       fdedee   de	ee
f   dedef
d„«       Zedi fdedee   de	ee
f   fd	„«       Zy)
ÚDynamoDBzYProvides factory methods for integrations between the LaunchDarkly SDK and DynamoDB.
    NÚ
table_namer   Údynamodb_optsr   r   c                 ó4   — t        | ||«      }t        ||«      S )a›  Creates a DynamoDB-backed implementation of :class:`ldclient.interfaces.FeatureStore`.
        For more details about how and why you can use a persistent feature store, see the
        `SDK reference guide <https://docs.launchdarkly.com/sdk/concepts/data-stores>`_.

        To use this method, you must first install the ``boto3`` package for the AWS SDK.
        Then, put the object returned by this method into the ``feature_store`` property of your
        client configuration (:class:`ldclient.config.Config`).
        ::

            from ldclient.integrations import DynamoDB
            store = DynamoDB.new_feature_store("my-table-name")
            config = Config(feature_store=store)

        Note that the DynamoDB table must already exist; the LaunchDarkly SDK does not create the table
        automatically, because it has no way of knowing what additional properties (such as permissions
        and throughput) you would want it to have. The table must have a partition key called
        "namespace" and a sort key called "key", both with a string type.

        By default, the DynamoDB client will try to get your AWS credentials and region name from
        environment variables and/or local configuration files, as described in the AWS SDK documentation.
        You may also pass configuration settings in ``dynamodb_opts``.

        :param table_name: the name of an existing DynamoDB table
        :param prefix: an optional namespace prefix to be prepended to all DynamoDB keys
        :param dynamodb_opts: optional parameters for configuring the DynamoDB client, as defined in
          the `boto3 API <https://boto3.amazonaws.com/v1/documentation/api/latest/reference/core/session.html#boto3.session.Session.client>`_
        :param caching: specifies whether local caching should be enabled and if so,
          sets the cache properties; defaults to :func:`ldclient.feature_store.CacheConfig.default()`
        )r   r   )r/   r   r0   r   r   s        r   r    zDynamoDB.new_feature_store=   s    € ôD )¨°V¸]ÓKˆÜ" 4¨Ó1Ð1r!   c                 ó   — t        | ||«      S )a  
        Creates a DynamoDB-backed Big Segment store.

        Big Segments are a specific type of user segments. For more information, read the LaunchDarkly
        documentation: https://docs.launchdarkly.com/home/users/big-segments

        To use this method, you must first install the ``boto3`` package for the AWS SDK. Then,
        put the object returned by this method into the ``store`` property of your Big Segments
        configuration (see :class:`ldclient.config.Config`).
        ::

          from ldclient.config import Config, BigSegmentsConfig
          from ldclient.integrations import DynamoDB
          store = DynamoDB.new_big_segment_store("my-table-name")
          config = Config(big_segments=BigSegmentsConfig(store=store))

        Note that the DynamoDB table must already exist; the LaunchDarkly SDK does not create the table
        automatically, because it has no way of knowing what additional properties (such as permissions
        and throughput) you would want it to have. The table must have a partition key called
        "namespace" and a sort key called "key", both with a string type.

        By default, the DynamoDB client will try to get your AWS credentials and region name from
        environment variables and/or local configuration files, as described in the AWS SDK documentation.
        You may also pass configuration settings in ``dynamodb_opts``.

        :param table_name: the name of an existing DynamoDB table
        :param prefix: an optional namespace prefix to be prepended to all DynamoDB keys
        :param dynamodb_opts: optional parameters for configuring the DynamoDB client, as defined in
          the `boto3 API <https://boto3.amazonaws.com/v1/documentation/api/latest/reference/core/session.html#boto3.session.Session.client>`_
        r   )r/   r   r0   s      r   Únew_big_segment_storezDynamoDB.new_big_segment_storeb   s   € ô@ (¨
°F¸MÓJÐJr!   )r"   r#   r$   r%   r'   r   r(   r)   r   r   r   r   r    r3   r,   r!   r   r.   r.   9   s¯   „ ñð à04Ø;=Ø/B¨{×/BÑ/BÓ/Dñ"2 cð "2Ø"*¨3¡-ð"2à)0°°c°Ñ):ð"2ð $/ð"2ð J]ò"2ó ð"2ðH ØEIÐlnñ K¨#ð K°xÀ±}ð KÐZaÐbeÐgjÐbjÑZkò Kó ñKr!   r.   c                   ó´   — e Zd ZdZdZdZdZeddd ej                  «       i fde
de
deded	ee
ef   d
efd„«       Zedddi fde
de
ded	ee
ef   d
ef
d„«       Zy)ÚRediszVProvides factory methods for integrations between the LaunchDarkly SDK and Redis.
    zredis://localhost:6379/0r   é   Úurlr   Úmax_connectionsr   Ú
redis_optsr   c                 óF   — t        | ||«      }t        ||«      }||_        |S )aõ  
        Creates a Redis-backed implementation of :class:`~ldclient.interfaces.FeatureStore`.
        For more details about how and why you can use a persistent feature store, see the
        `SDK reference guide <https://docs.launchdarkly.com/sdk/concepts/data-stores>`_.

        To use this method, you must first install the ``redis`` package. Then, put the object
        returned by this method into the ``feature_store`` property of your client configuration
        (:class:`ldclient.config.Config`).
        ::

            from ldclient.config import Config
            from ldclient.integrations import Redis
            store = Redis.new_feature_store()
            config = Config(feature_store=store)

        :param url: the URL of the Redis host; defaults to ``DEFAULT_URL``
        :param prefix: a namespace prefix to be prepended to all Redis keys; defaults to
          ``DEFAULT_PREFIX``
        :param caching: specifies whether local caching should be enabled and if so,
          sets the cache properties; defaults to :func:`ldclient.feature_store.CacheConfig.default()`
        :param redis_opts: extra options for initializing Redis connection from the url,
          see `redis.connection.ConnectionPool.from_url` for more details.
        )r   r   Ú_core)r7   r   r8   r   r9   r   Úwrappers          r   r    zRedis.new_feature_storeŒ   s*   € ô< & c¨6°:Ó>ˆÜ% d¨GÓ4ˆØˆŒØˆr!   c                 ó   — t        | ||«      S )a9  
        Creates a Redis-backed Big Segment store.

        Big Segments are a specific type of user segments. For more information, read the LaunchDarkly
        documentation: https://docs.launchdarkly.com/home/users/big-segments

        To use this method, you must first install the ``redis`` package. Then, put the object
        returned by this method into the ``store`` property of your Big Segments configuration
        (see :class:`ldclient.config.Config`).
        ::

          from ldclient.config import Config, BigSegmentsConfig
          from ldclient.integrations import Redis
          store = Redis.new_big_segment_store()
          config = Config(big_segments=BigSegmentsConfig(store=store))

        :param url: the URL of the Redis host; defaults to ``DEFAULT_URL``
        :param prefix: a namespace prefix to be prepended to all Redis keys; defaults to
          ``DEFAULT_PREFIX``
        :param redis_opts: extra options for initializing Redis connection from the url,
          see `redis.connection.ConnectionPool.from_url` for more details.
        r   )r7   r   r8   r9   s       r   r3   zRedis.new_big_segment_store¯   s   € ô8 % S¨&°*Ó=Ð=r!   N)r"   r#   r$   r%   ÚDEFAULT_URLr&   ÚDEFAULT_MAX_CONNECTIONSr'   r   r(   r)   r*   r   r   r   r    r   r3   r,   r!   r   r5   r5   …   s×   „ ñà,€KØ#€NØ ÐàØ#=Ø&4Ø/1Ø/B¨{×/BÑ/BÓ/DØ79ñ	 ˜sð  Ø"%ð à+.ð ð $/ð ð '+¨3°¨8¡nð	 ð ?Rò	 ó ð ðD Ø'AØ*8Ø35Ø;=ñ> 3ð >Ø&)ð>à/2ð>ð +/¨s°C¨x©.ð>ð CRò>ó ñ>r!   r5   c                   óD   — e Zd ZdZe	 	 	 d	dee   dededede	f
d„«       Z
y)
ÚFileszDProvides factory methods for integrations with filesystem data.
    ÚpathsÚauto_updateÚpoll_intervalÚforce_pollingr   c                 ó   ‡ ‡‡‡— ˆˆˆ ˆfd„S )a&  Provides a way to use local files as a source of feature flag state. This would typically be
        used in a test environment, to operate using a predetermined feature flag state without an
        actual LaunchDarkly connection.

        To use this component, call ``new_data_source``, specifying the file path(s) of your data file(s)
        in the ``paths`` parameter; then put the value returned by this method into the ``update_processor_class``
        property of your LaunchDarkly client configuration (:class:`ldclient.config.Config`).
        ::

            from ldclient.integrations import Files
            data_source = Files.new_data_source(paths=[ myFilePath ])
            config = Config(update_processor_class=data_source)

        This will cause the client not to connect to LaunchDarkly to get feature flags. The
        client may still make network connections to send analytics events, unless you have disabled
        this in your configuration with ``send_events`` or ``offline``.

        The format of the data files is described in the SDK Reference Guide on
        `Reading flags from a file <https://docs.launchdarkly.com/sdk/features/flags-from-files#python>`_.
        Note that in order to use YAML, you will need to install the ``pyyaml`` package.

        If the data source encounters any error in any file-- malformed content, a missing file, or a
        duplicate key-- it will not load flags from any of the files.

        :param paths: the paths of the source files for loading flag data. These may be absolute paths
          or relative to the current working directory. Files will be parsed as JSON unless the ``pyyaml``
          package is installed, in which case YAML is also allowed.
        :param auto_update: (default: false) True if the data source should watch for changes to the source file(s)
          and reload flags whenever there is a change. The default implementation of this feature is based on
          polling the filesystem, which may not perform well; if you install the ``watchdog`` package, its
          native file watching mechanism will be used instead. Note that auto-updating will only work if all
          of the files you specified have valid directory paths at startup time.
        :param poll_interval: (default: 1) the minimum interval, in seconds, between checks for file
          modifications-- used only if ``auto_update`` is true, and if the native file-watching mechanism from
          ``watchdog`` is not being used.
        :param force_polling: (default: false) True if the data source should implement auto-update via
          polling the filesystem even if a native mechanism is available. This is mainly for SDK testing.

        :return: an object (actually a lambda) to be stored in the ``update_processor_class`` configuration property
        c                 ó$   •— t        ||‰‰‰‰«      S )Nr	   )ÚconfigÚstoreÚreadyrC   rE   rB   rD   s      €€€€r   ú<lambda>z'Files.new_data_source.<locals>.<lambda>þ   s   ø€ ¬_¸UÀEÈ5ÐR]Ð_lÐn{Ó-|€ r!   r,   )rB   rC   rD   rE   s   ````r   Únew_data_sourcezFiles.new_data_sourceÑ   s   û€ öZ }Ð|r!   N)Fé   F)r"   r#   r$   r%   r'   r   r)   ÚboolÚfloatÚobjectrL   r,   r!   r   rA   rA   Í   sZ   „ ñð à*/Ø-.Ø,1ñ,}˜t C™yð ,}Ø%)ð,}à',ð,}ð (,ð,}ð 7=ò,}ó ñ,}r!   rA   N)r%   Úldclient.feature_storer   Úldclient.feature_store_helpersr   Ú6ldclient.impl.integrations.consul.consul_feature_storer   Ú>ldclient.impl.integrations.dynamodb.dynamodb_big_segment_storer   Ú:ldclient.impl.integrations.dynamodb.dynamodb_feature_storer   Ú1ldclient.impl.integrations.files.file_data_sourcer
   Ú8ldclient.impl.integrations.redis.redis_big_segment_storer   Ú4ldclient.impl.integrations.redis.redis_feature_storer   Úldclient.interfacesr   Útypingr   r   r   r   r   r   r.   r5   rA   r,   r!   r   ú<module>r[      s`   ðñõ
 /Ý >Ý ZÝ cÝ `Ý MÝ ZÝ WÝ /ç 5Õ 5÷$2ñ $2÷NIKñ IK÷XF>ñ F>÷P1}ò 1}r!   