-
Notifications
You must be signed in to change notification settings - Fork 4
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
Support for PubSub Messaging #38
Conversation
Added PubSubEvent for passing messages back and forth between the publisher and subscriber.
Predis client. Added a PubSubManager for handling events. Added initial tests which are WIP.
and implemented a WIP custom subscriber function in the RedisDriver.
Fixed an issue with extracting channel name. Bit of refactoring.
Fixed DummyPubSubDriver for unit testing.
@@ -91,6 +92,10 @@ public function __construct( | |||
$this->client = $client; | |||
} | |||
|
|||
// Enable Pub/Sub mechanism | |||
if ($this->isPubSubSupported()) { |
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.
Should this be here?
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.
No, thanks, removed.
|
||
// Send the message to the subscriber | ||
$pubsub_manager->addListener($channel_name, function(PubSubEvent $e) { | ||
list($cmd, $msg) = explode(' ', $e->getMessage()); |
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.
So can't use space in message?
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.
Just an example @y2khjh, in that example you can't.
* @param string $message | ||
* @return int | ||
*/ | ||
public function publishMessage($channel, $message); |
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.
Unittest?
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.
Explain a bit more? Unit tests should be for the driver, which we assume works as it is from Predis.
Pub/Sub
Pub/Sub mechanism implements the message passing between applications using the ORM leveraging the native implementations of Pub/Sub within the database driver in use.
An example use case for Pub/Sub would be sending messages to background tasks that run on a separate process apart from the application itself, processing the workload without holding the application process.