Skip to content

Add polling + indirect support for streaming#47

Closed
drichelson wants to merge 42 commits into
masterfrom
dr/v1Polling
Closed

Add polling + indirect support for streaming#47
drichelson wants to merge 42 commits into
masterfrom
dr/v1Polling

Conversation

@drichelson

@drichelson drichelson commented Jun 30, 2016

Copy link
Copy Markdown
Contributor

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

Dan Richelson added 5 commits June 28, 2016 13:55
…lling and streaming restwrappers pass, but local tests do not pass.
…lling and streaming restwrappers pass, All but some integration tests pass
Comment thread ldclient/client.py Outdated
@@ -156,18 +108,19 @@ def __init__(self, api_key, config=None):
self._offline = False

Copy link
Copy Markdown
Contributor

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.

Comment thread ldclient/twisted_redis.py Outdated


class TwistedRedisLDDStreamProcessor(StreamProcessor):
class TwistedRedisLDDStreamProcessor(UpdateProcessor):

Copy link
Copy Markdown
Contributor Author

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..

@jkodumal jkodumal Jun 30, 2016

Copy link
Copy Markdown
Contributor

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.

@drichelson drichelson changed the title Add polling + indirect support for streaming [HOLD] Add polling + indirect support for streaming Jun 30, 2016
@drichelson drichelson changed the title [HOLD] Add polling + indirect support for streaming Add polling + indirect support for streaming Jun 30, 2016
@drichelson

Copy link
Copy Markdown
Contributor Author

This is passing against restwrappers running locally, but is failing on Circle. I'm investigating, but I believe all this code to be correct.

Comment thread ldclient/client.py Outdated

class LDClient(object):

def __init__(self, api_key, config=None):

Copy link
Copy Markdown
Contributor

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.

@jkodumal

jkodumal commented Jun 30, 2016

Copy link
Copy Markdown
Contributor

I would recommend updating the major version in version.py now as part of this refactoring.

Comment thread ldclient/polling.py
self._config = config
self._requester = requester
self._store = store
self._running = False

@jkodumal jkodumal Jun 30, 2016

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct.

@drichelson drichelson changed the title Add polling + indirect support for streaming [HOLD] Add polling + indirect support for streaming Jul 5, 2016
@drichelson drichelson changed the title [HOLD] Add polling + indirect support for streaming Add polling + indirect support for streaming Jul 6, 2016
@drichelson

Copy link
Copy Markdown
Contributor Author

3 existing restwrappers: python with streaming, python polling, and twisted streaming:
https://circleci.com/gh/launchdarkly/integration-harness/1173 (python)
https://circleci.com/gh/launchdarkly/integration-harness/1174 (twisted)

Comment thread ldclient/__init__.py
_lock = threading.Lock()


def get():

Copy link
Copy Markdown
Contributor Author

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

@drichelson

Copy link
Copy Markdown
Contributor Author

Added python-redis restwrapper, it should run with this build: https://circleci.com/gh/launchdarkly/integration-harness/1176

@drichelson

drichelson commented Jul 6, 2016

Copy link
Copy Markdown
Contributor Author

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..

Comment thread demo/demo.py Outdated
apiKey = 'feefifofum'
client = LDClient(apiKey)
api_key = 'api_key'
client = LDClient(api_key, start_wait=10)

Copy link
Copy Markdown
Contributor

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?

@pkaeding

pkaeding commented Jul 7, 2016

Copy link
Copy Markdown
Contributor

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,

Copy link
Copy Markdown
Contributor

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

@pkaeding

pkaeding commented Jul 7, 2016

Copy link
Copy Markdown
Contributor

lgtm
👍
looks good to me
merge away
I approve
canned replies are great.

@jkodumal

jkodumal commented Jul 7, 2016

Copy link
Copy Markdown
Contributor

Let's have this PR target a v2 branch, instead of master.

Comment thread ldclient/__init__.py
_lock = ReadWriteLock()


def get():

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Contributor

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.

@drichelson

Copy link
Copy Markdown
Contributor Author

ok- I'm closing this PR and merging this branch into v2.

@drichelson drichelson closed this Jul 7, 2016
eli-darkly added a commit that referenced this pull request May 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants