-
Notifications
You must be signed in to change notification settings - Fork 45
Add polling + indirect support for streaming #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
280d1c4
[wip] Added polling support + indirect messages in streaming. Both po…
02b7f2d
[wip] Added polling support + indirect messages in streaming. Both po…
c4501cd
cleanup
ce05217
polling client no longer drifts.
2b74410
cleanup
22382ed
Remove commented code. Fix some documentation
9e9fe54
Move offline to config so it is set once during initialization and on…
222f981
Add log statements when returning default
ea76873
Rename
f29e2a0
Rename and move some things.
c34a29f
Rename some config params. Add Redis feature store + tests
d8ae8aa
update some redis-related things
b6b4151
Add wait loop at start
40f5443
clean up uris, etc
110499f
Rename more things. Remove some outdated twisted impls.
52073d8
Change client init logic to handle LDD mode. Make other things more c…
328a9eb
Add debug logging
b694fe6
Add debug logging
e0e9fae
Update deps
249162f
bump version. Add more debug logging.
567baed
temporary- make inmem feature store look like master
5fb3f59
fix bad import
79a6b1c
Revert
40c1e26
Change feature store so it lives in config
8510837
Remove startup wait.
a429301
add log statements
778ec2e
move feature store init
50b1e73
more logging
d85ccba
maybe
23547c1
Revert some things that didn't work.
7110730
Attempt to make event consumer behavior more consistent. temporarily …
4c819c5
Bump version. Rename some things.
ab4929c
Add start_wait.
4e32f00
add future
62ceb43
cahnge log statement.
739ccb1
Make python 3 happy.
0596d50
Make python 3 happy.
1350833
Start polling processor for real this time
f2cb7a3
Update readme
9c23fc4
Change redis feature store to take url
467ad4e
always set a feature store
605fb13
Address PR comments. Fix weird formatting in test file.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,25 @@ | ||
| from __future__ import print_function | ||
| from ldclient import LDClient | ||
|
|
||
| import logging | ||
| import sys | ||
|
|
||
| import ldclient | ||
|
|
||
| root = logging.getLogger() | ||
| root.setLevel(logging.DEBUG) | ||
|
|
||
| ch = logging.StreamHandler(sys.stdout) | ||
| ch.setLevel(logging.DEBUG) | ||
| formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') | ||
| ch.setFormatter(formatter) | ||
| root.addHandler(ch) | ||
|
|
||
| if __name__ == '__main__': | ||
| apiKey = 'feefifofum' | ||
| client = LDClient(apiKey) | ||
| print(client.api_key) | ||
| ldclient._api_key = 'api_key' | ||
| ldclient.start_wait = 10 | ||
| client = ldclient.get() | ||
|
|
||
| user = {u'key': 'userKey'} | ||
| print(client.toggle("update-app", user, False)) | ||
|
|
||
| client.close() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,9 @@ | ||
| from .client import * | ||
| import logging | ||
|
|
||
| from ldclient.rwlock import ReadWriteLock | ||
| from ldclient.version import VERSION | ||
| from .client import * | ||
| from .util import log | ||
| import logging | ||
|
|
||
| __version__ = VERSION | ||
|
|
||
|
|
@@ -11,6 +13,34 @@ | |
| "firstName", "lastName", "avatar", "name", "anonymous"] | ||
|
|
||
|
|
||
| """Settings.""" | ||
| client = None | ||
| api_key = None | ||
| start_wait = 5 | ||
| config = Config() | ||
|
|
||
| _lock = ReadWriteLock() | ||
|
|
||
|
|
||
| def get(): | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added double-check locking. Please run through how this can break.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks reasonable to me. |
||
| try: | ||
| _lock.rlock() | ||
| if client: | ||
| return client | ||
| finally: | ||
| _lock.runlock() | ||
|
|
||
| try: | ||
| global client | ||
| _lock.lock() | ||
| if not client: | ||
| log.debug("Initializing LaunchDarkly Client") | ||
| client = LDClient(api_key, config, start_wait) | ||
| return client | ||
| finally: | ||
| _lock.unlock() | ||
|
|
||
|
|
||
| # Add a NullHandler for Python < 2.7 compatibility | ||
| class NullHandler(logging.Handler): | ||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This follows the model used by segment to enforce the singleton pattern. See updated readme + restwrapper PR: https://github.com/launchdarkly/python-restwrapper/pull/1/files