-
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
Conversation
…lling and streaming restwrappers pass, but local tests do not pass.
…lling and streaming restwrappers pass, All but some integration tests pass
ldclient/client.py
Outdated
| self._session = CacheControl(requests.Session()) | ||
| self._queue = queue.Queue(self._config.capacity) | ||
| self._consumer = None | ||
| self._offline = False |
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.
One thing we did in the other refactorings like this is change offline mode to a configuration parameter rather than a modifiable state. This makes it a lot easier to reason about things, and it makes it the case that we don't have to lazily initialize the streaming connection.
ldclient/twisted_redis.py
Outdated
|
|
||
|
|
||
| class TwistedRedisLDDStreamProcessor(StreamProcessor): | ||
| class TwistedRedisLDDStreamProcessor(UpdateProcessor): |
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.
Do we need this? It seems like this should be a RedisFeatureStore, not a Redis stream processor..
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.
Indeed, I think this should be refactored into a RedisFeatureStore.
This would also involve substantial refactoring to RedisLDDRequester, but I think we should bring everything in line with the structure of the other implementations anyway.
…ly read after that.
|
This is passing against restwrappers running locally, but is failing on Circle. I'm investigating, but I believe all this code to be correct. |
ldclient/client.py
Outdated
|
|
||
| class LDClient(object): | ||
|
|
||
| def __init__(self, api_key, config=None): |
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.
Can we add an option (as we have in go) to wait for initialization? That would get rid of the ugly sleep in thet demo code.
|
I would recommend updating the major version in |
| self._config = config | ||
| self._requester = requester | ||
| self._store = store | ||
| self._running = False |
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.
I don't think there are any implications to this, and I notice we use the same pattern in the StreamProcessor, but this doesn't look thread safe to me.
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.
Do you mean that the modification of self._running is not done under a lock?
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.
Correct.
|
3 existing restwrappers: python with streaming, python polling, and twisted streaming: |
| _lock = threading.Lock() | ||
|
|
||
|
|
||
| def get(): |
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
|
Added python-redis restwrapper, it should run with this build: https://circleci.com/gh/launchdarkly/integration-harness/1176 |
|
The megabuild: https://circleci.com/gh/launchdarkly/integration-harness/1176 failed the polling restwrapper, but I ran it again: https://circleci.com/gh/launchdarkly/integration-harness/1177 and it passed. Then I ran both python wrappers: https://circleci.com/gh/launchdarkly/integration-harness/1178 and they both passed.. |
demo/demo.py
Outdated
| apiKey = 'feefifofum' | ||
| client = LDClient(apiKey) | ||
| api_key = 'api_key' | ||
| client = LDClient(api_key, start_wait=10) |
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.
Should this be calling ldclient.get() like the README says?
|
As there are a number of breaking changes here (I noticed the major version bump, so that is good), we should be sure to call out those changes in the release notes. (remember that files are modules in Python, so moving a class to its own file is moving it to a new module, which is a breaking change) |
| url='redis://localhost:6379/0', | ||
| prefix='launchdarkly', | ||
| max_connections=16, | ||
| expiration=15, |
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.
these parameters should probably be documented
|
lgtm |
|
Let's have this PR target a |
| _lock = ReadWriteLock() | ||
|
|
||
|
|
||
| def get(): |
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.
Added double-check locking. Please run through how this can break.
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 looks reasonable to me.
|
ok- I'm closing this PR and merging this branch into v2. |
I tried to change as little as possible, but that didn't work. See comments in diff.
This is deployed to restwrappers and harness is running: https://circleci.com/gh/launchdarkly/integration-harness/1126