Skip to content

Commit 683d4db

Browse files
msohailhussainaliabbasrizvi
authored andcommitted
readme: Optimizely DFM (#188)
1 parent 08f314e commit 683d4db

File tree

1 file changed

+88
-1
lines changed

1 file changed

+88
-1
lines changed

README.rst

+88-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,92 @@ dashboard, please contact your Optimizely account executive.
3030
Using the SDK
3131
~~~~~~~~~~~~~
3232

33-
See the Optimizely `Full Stack documentation`_ to learn how to
33+
You can initialize the Optimizely instance in three ways: with a datafile, by providing an `sdk_key`, or by providing a `ConfigManager`_. Each method is described below.
34+
35+
1. Initialize Optimizely with a datafile. This datafile will be used as
36+
ProjectConfig throughout the life of Optimizely instance.
37+
::
38+
39+
optimizely.Optimizely(
40+
datafile
41+
)
42+
43+
2. Initialize Optimizely by providing an 'sdk_key'. This will initialize
44+
a PollingConfigManager that makes an HTTP GET request to the URL (formed
45+
using your provided `sdk key` and the default datafile CDN URL
46+
template) to asynchronously download the project datafile at regular
47+
intervals and update ProjectConfig when a new datafile is recieved. A
48+
hard-coded datafile can also be provided along with the `sdk_key` that
49+
will be used initially before any update.
50+
::
51+
52+
optimizely.Optimizely(
53+
sdk_key='put_your_sdk_key_here'
54+
)
55+
56+
3. Initialize Optimizely by providing a ConfigManager that implements `BaseConfigManager`_. You may use our `PollingConfigManager` as needed.
57+
::
58+
59+
optimizely.Optimizely(
60+
config_manager=custom_config_manager
61+
)
62+
63+
PollingConfigManager
64+
''''''''''''''''''''
65+
66+
The `PollingConfigManager` asynchronously polls for datafiles from a
67+
specified URL at regular intervals by making HTTP requests.
68+
69+
polling_config_manager = PollingConfigManager( sdk_key=None,
70+
datafile=None, update_interval=None, url=None, url_template=None,
71+
logger=None, error_handler=None, notification_center=None,
72+
skip_json_validation=False )
73+
74+
**Note**: You must provide either the `sdk_key` or URL. If you provide both, the URL takes precedence.
75+
76+
**sdk_key** The `sdk_key` is used to compose the outbound HTTP request to
77+
the default datafile location on the Optimizely CDN.
78+
79+
**datafile** You can provide an initial datafile to bootstrap the
80+
``ProjectConfigManager`` so that it can be used immediately. The initial
81+
datafile also serves as a fallback datafile if HTTP connection cannot be
82+
established. The initial datafile will be discarded after the first
83+
successful datafile poll.
84+
85+
**update_interval** The update_interval is used to specify a fixed delay
86+
in seconds between consecutive HTTP requests for the datafile.
87+
88+
**url_template** A string with placeholder ``{sdk_key}`` can be provided
89+
so that this template along with the provided `sdk key` is used to form
90+
the target URL.
91+
92+
You may also provide your own logger, error_handler, or
93+
notification_center.
94+
95+
Advanced configuration
96+
''''''''''''''''''''''
97+
98+
The following properties can be set to override the default
99+
configurations for `PollingConfigManager`.
100+
101+
================ ======================================================== =====================================================================================
102+
**PropertyName** **Default Value** **Description**
103+
================ ======================================================== =====================================================================================
104+
update_interval 5 minutes Fixed delay between fetches for the datafile
105+
sdk_key None Optimizely project SDK key
106+
url None URL override location used to specify custom HTTP source for the Optimizely datafile
107+
url_template https://cdn.optimizely.com/datafiles/{sdk_key}.json Parameterized datafile URL by SDK key
108+
datafile None Initial datafile, typically sourced from a local cached source
109+
================ ======================================================== =====================================================================================
110+
111+
A notification signal will be triggered whenever a *new* datafile is
112+
fetched and Project Config is updated. To subscribe to these
113+
notifications, use:
114+
115+
``notification_center.add_notification_listener(NotificationTypes.OPTIMIZELY_CONFIG_UPDATE, update_callback)``
116+
117+
118+
For Further details see the Optimizely `Full Stack documentation`_ to learn how to
34119
set up your first Python project and use the SDK.
35120

36121
Development
@@ -123,6 +208,8 @@ Please see `CONTRIBUTING`_.
123208
.. _Full Stack documentation: https://docs.developers.optimizely.com/full-stack/docs
124209
.. _Rollouts documentation: https://docs.developers.optimizely.com/rollouts/docs
125210
.. _CONTRIBUTING: CONTRIBUTING.rst
211+
.. _ConfigManager: https://github.com/optimizely/python-sdk/tree/master/optimizely/config_manager.py
212+
.. _BaseConfigManager: https://github.com/optimizely/python-sdk/tree/master/optimizely/config_manager.py#L32
126213

127214
.. |PyPI version| image:: https://badge.fury.io/py/optimizely-sdk.svg
128215
:target: https://pypi.org/project/optimizely-sdk

0 commit comments

Comments
 (0)