chrisboulton / php-resque

PHP port of resque (Workers and Queueing)
MIT License
3.43k stars 759 forks source link

Connecting to redis via unix sockets not possible #222

Closed beheh closed 8 years ago

beheh commented 10 years ago

The version 1.2 accepted a unix://<path> style socket path to connect to redis. credis does still support this, but the Resque_Redis-Wrapper does not allow the "unix" protocol in parseDsn.

This should be allowed, although unix sockets do not understand the notion of ports. A workaround is to use Resque::setBackend(array(array('host' => 'unix://<path>'))), but this is not easily possible on the command line to use the supplied bin/resque worker (this works because an array is directly passed to Credis_Cluster, which then initializes Credis_Client(s)).

I also barely found any documentation of this feature. It would be nice if this is mentioned at least somewhere.

beheh commented 10 years ago

I added two basic tests at beheh/php-resque@d24f65bbae097fe33d67b10da3c7e45ae9d5a68a. Note that parseDsn currently always returns the supplied port the default port - this does not apply to unix, and Credis_Client works perfectly fine with a 0 or NULL port (see test here and code here).

beheh commented 10 years ago

Also, note that PHPs parse_url cannot handle unix:/// uris (as Credis proposes), since PHPs doc on this function states:

This function is intended specifically for the purpose of parsing URLs and not URIs. However, to comply with PHP's backwards compatibility requirements it makes an exception for the file:// scheme where triple slashes (file:///...) are allowed. For any other scheme this is invalid.

lenar commented 9 years ago

@beheh: It actually works if you just pass absolute path of unix socket as hostname (without scheme etc). And yes, unix:// prefix isn't supported right now at all. And as you said just adding unix to allowed schemes in Resque_Redis::parseDns() doesn't cut it because of the shortcomings of parse_url() function. Somebody should do something :).

chrisboulton commented 8 years ago

Addressed by #298