-
Notifications
You must be signed in to change notification settings - Fork 51
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
provide predis native configuration option #88
Conversation
upon rereading the issues: |
Thank you very much for this nice PR, @scones! I'll have a more detailed look in a few days. In general, the concept to leverage the full potential of the underlying predis library sounds great. Although you also still support the legacy configuration, I'd think this should land in the 3.0 release. What is your opinion on that? Unfortunately, I didn't get any response from @mjphaynes yet concerning issue #78. However, we could postpone that decision to 4.0 and continue now with this PR, PR #82 and PR #85 for php-resque 3.0. |
By the way, could you please also add a short description in the docs? Thank you very much 😄 |
changing the major version would indicate a major change in interfaces or a complete rewrite. You can merge it as soon as you find it good. ;) also: what to add to the docs? i edited the config.yml with the dummy configs. How to configure the predis client is not in the scope of the docs from php-resque, but the job of predis. best regards |
Thanks. I like the general approach and will review and (probably) merge soon 👍 . Two small things I saw for now: The Dockerfile you add is for development and testing with PHP 5.3, right? Maybe we should add a general docker readme (docker.md?) in the docs folder on how to run php-resque in Docker with best practices (see #66). Could you please use camelCase for variable and property names instead of snake_case? We try to comply with PSR-2 for new code (although there are still a few legacy code parts). Thank you very much! |
The Dockerfile is for php 5.3, yes. But it is intended as testing environment. I will rename the variables. |
done |
Great, thank you @scones 👍 Best regards |
I'll leave a few notes via the review system here 😄 Thank you very much! |
config.yml
Outdated
@@ -11,7 +11,7 @@ | |||
|
|||
include: examples/autoload.php # A file to include on each command | |||
|
|||
|
|||
# # The manual legacy way |
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'm not sure whether manual is the right expression here. Maybe just "The legacy way, which only supports a subset of Redis options"?
|
||
RUN apt-get install -yqq git-core | ||
|
||
RUN pecl install -o -f redis && rm -rf /tmp/pear && docker-php-ext-enable redis |
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.
If i remember correctly, we use phpiredis instead of the quite problematic and unmaintained PHP redis extension. See #42
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.
maybe, but this configuration let me run the tests.
which is all this container is for: run the tests in any environment.
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.
Ok, let's maybe add a comment at the beginning of the Dockerfile that it is for development and testing with the minimum deps, but not suitable as a template for production. What do you think?
We plan to add/link a fully-fledged Docker example with a minimal but complete worker for a real-world application later on anyway.
RUN docker-php-ext-install pcntl | ||
|
||
|
||
CMD composer install -v && tail -f /dev/null |
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.
What is fail -f /dev/null supposed to do in this context?
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.
tail -f
attaches itself to a stream and listens. with /dev/null
as a stream there will be no output, but the stream stays open.
in combination it keeps the CMD running without producing spam.
Thus the docker container won't shut down after it booted up, but stays active.
src/Resque/Redis.php
Outdated
); | ||
|
||
// setup password | ||
if (isset($config['password']) && !empty($config['password'])) { |
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.
empty includes a check for isset() so it is not necessary to do both.
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.
sorry, force of habbit.
i tend to implement such stuff explicit and more readable
} | ||
|
||
// create Predis client | ||
$this->redis = new Predis\Client($params, $options); | ||
$this->redis = $this->initializePredisClient($predisParams, $predisOptions); |
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.
Good idea to extract the intitalization!
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 was necessary to make the initialization testable, as it it cumbersome to mock foreign objects.
@@ -9,7 +9,7 @@ | |||
* file that was distributed with this source code. | |||
*/ | |||
|
|||
namespace Resque\Tests\Heplers\Utils; | |||
namespace Resque\Tests\Helpers; |
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.
Thanks for fixing that 👍
ffe59f3
to
bb65341
Compare
… stuff on productive builds
…redis configuration
everything updated. |
Thank you very much 👍 Best regards |
|
unless there is more text to that, i will assume these checkboxes mean: tests in progress :) |
Exactly 😀 I'll update here and post an additional comment when all tests are done. What would you think about my three notes? |
what notes? |
# # "options" is the second parameter to Predis\Client | ||
# predis: | ||
# config: | ||
# - "tcp://10.0.0.1:12345" |
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.
Maybe the config template should use the standard Redis port (6379) as well. Otherwise, this might confuse users.
# - "tcp://10.0.0.3:12345" | ||
# options: | ||
# service: "some_redis_cluster_name" | ||
# replication: "sentinel" |
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.
Here I would add a comment inside the template that advanced Predis features like password, database index, replication etc are supported, but optional. Otherwise, newbies might struggle as they can't find out why it doesn't work if they try to copy and adapt the example 😉
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 and the note above would suggest the existence of a valid documentation of settings.
such a thing should not be done in a config file.
thus you are asking for a feature, which is unrelated to this pull request.
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.
That's true, so I'd just link to the Predis documentation instead of duplicating it on our own.
If someone wants to use advanced features they can do so, but the defaults in the config template should IMHO match the ones in the legacy configuration to avoid confusion.
|
||
RUN apt-get install -yqq git-core | ||
|
||
RUN pecl install -o -f redis && rm -rf /tmp/pear && docker-php-ext-enable redis |
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.
Ok, let's maybe add a comment at the beginning of the Dockerfile that it is for development and testing with the minimum deps, but not suitable as a template for production. What do you think?
We plan to add/link a fully-fledged Docker example with a minimal but complete worker for a real-world application later on anyway.
Ah sorry, just saw that GitHub doesn't show my review comments to others until I explicitely publish them 😀 |
thus it just exists there, without users knowing why. I can only assume, that users who seek an (undocumented) Dockerfile, will know enough about docker to understand what it's doing. |
the current wrapper class does not allow for a deviation from "one redis server" configuration variant of predis.
As Resque in itself is a technology one usually uses in more complex setups, the need for a more complex redis-setup arises.
The provided predis version does have all these options, but the wrapper is too limited.
This patch allows for direct configuration of predis via the predis section in the
config.yml
it effectively overrides anything configured in the redis section, so one has to chose.
I provided a sentinel example for that.
In addition i added the following things for a brighter future:
Dockerfile
file for testingdocker-compose.yml
file for testing.gitattributes
fileif this gets merged i also have the tools to work on the handler thing again (#85 )
best regards,
scones