Skip to content

Conversation

@drichelson
Copy link
Contributor

@drichelson drichelson commented Jun 30, 2016

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
self._session = CacheControl(requests.Session())
self._queue = queue.Queue(self._config.capacity)
self._consumer = None
self._offline = False
Copy link
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.



class TwistedRedisLDDStreamProcessor(StreamProcessor):
class TwistedRedisLDDStreamProcessor(UpdateProcessor):
Copy link
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..

Copy link
Contributor

@jkodumal jkodumal Jun 30, 2016

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


class LDClient(object):

def __init__(self, api_key, config=None):
Copy link
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
Copy link
Contributor

jkodumal commented Jun 30, 2016

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

self._config = config
self._requester = requester
self._store = store
self._running = False
Copy link
Contributor

@jkodumal jkodumal Jun 30, 2016

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

_lock = threading.Lock()


def get():
Copy link
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
Contributor Author

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

@drichelson
Copy link
Contributor Author

drichelson commented Jul 6, 2016

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)
Copy link
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
Copy link
Contributor

pkaeding commented Jul 7, 2016

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
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
Copy link
Contributor

pkaeding commented Jul 7, 2016

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

@jkodumal
Copy link
Contributor

jkodumal commented Jul 7, 2016

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

_lock = ReadWriteLock()


def get():
Copy link
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
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
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.

4 participants