Skip to content

新增auth支持#328

Open
ghost wants to merge 2 commits intochrisboulton:masterfrom
beck917:master
Open

新增auth支持#328
ghost wants to merge 2 commits intochrisboulton:masterfrom
beck917:master

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Feb 17, 2017

No description provided.

@danhunsaker
Copy link
Copy Markdown
Contributor

One of the changes here seems helpful, namely the use of PID tracking to ensure better "thread safety" across forks.

That said, all the rest are breaking changes. Some bugfixes are reverted, and many features are removed. I suspect the changes in this PR were made to a much older version of the code than the most recent version in master.

Additionally, your second commit changes the namespace of the package, which cannot be accepted.

To address this, please close this PR, create a new branch even with the master branch of chrisboulton/php-resque (this repo), and make your changes on that branch before opening a new PR for just those changes. Remember, when you make a commit to a PR's branch, GitHub adds that commit to that PR.

Copy link
Copy Markdown
Contributor

@danhunsaker danhunsaker left a comment

Choose a reason for hiding this comment

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

Changing the namespace is not something that can be merged.

Copy link
Copy Markdown
Contributor

@danhunsaker danhunsaker left a comment

Choose a reason for hiding this comment

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

One other note that isn't specific to any given line - please make sure you use consistent spacing and indentation in PRs. I see at least one case where you fixed the indentation, but several more where you've added something with poor spacing.

Comment thread lib/Resque.php
<?php
require_once dirname(__FILE__) . '/Resque/Event.php';
require_once dirname(__FILE__) . '/Resque/Exception.php';

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 lines are from before Composer was introduced...

Comment thread lib/Resque.php
* and implement "thread" safety to avoid race conditions.
*/
protected static $pid = null;

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 seems useful, though.

Comment thread lib/Resque.php
* a callable that receives the configured database ID
* and returns a Resque_Redis instance, or
* @param mixed $server Host/port combination separated by a colon, or
* a nested array of servers with host/port pairs.
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.

Dropping a lot of valid server definitions, here...

Comment thread lib/Resque.php
return $pid;
self::$redis->select(self::$redisDatabase);
return self::$redis;
}
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.

The Resque::fork() method is pretty essential to the way the library operates now. It shouldn't be removed.

Comment thread lib/Resque.php
}
return true;
self::redis()->rpush('queue:' . $queue, json_encode($item));
}
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 removes a lot of error handling...

Comment thread lib/Resque.php
{
$counter = self::size($queue);
$result = self::redis()->del('queue:' . $queue);
return ($result == 1) ? $counter : 0;
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.

Again, we still need to be able to remove jobs from the queue.

Comment thread lib/Resque.php
*/
public static function generateJobId()
{
return md5(uniqid('', true));
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.

Not strictly vital, but consistency is nice, so putting this in a method rather than duplicating it everywhere is helpful.

Comment thread lib/Resque.php

return $pid;
self::$redis->select(self::$redisDatabase);
return self::$redis;
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.

All of this logic is unnecessary with Credis, and is in fact redundant. Assuming it dates from before the switch to Composer, as well.

Comment thread lib/Resque.php
$pid = getmypid();
if (self::$pid !== $pid) {
self::$redis = null;
self::$pid = $pid;
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 bit still looks helpful, though.

Comment thread lib/Resque.php
{
self::$redisServer = $server;
self::$redisDatabase = $database;
self::$auth = $auth;
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 can see why this might be tempting to have. Feels a bit superfluous, though.

@PreciselyAlyss
Copy link
Copy Markdown

I'm sure this is obvious in the code, but the PR title translates to Added auth support

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.

2 participants