Skip to content
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

Merged
merged 15 commits into from
Feb 16, 2016
Merged

Support for PubSub Messaging #38

merged 15 commits into from
Feb 16, 2016

Conversation

purinda
Copy link
Member

@purinda purinda commented Feb 15, 2016

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.

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()) {
Copy link
Member

Choose a reason for hiding this comment

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

Should this be here?

Copy link
Member Author

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());
Copy link

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?

Copy link
Member Author

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

Choose a reason for hiding this comment

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

Unittest?

Copy link
Member Author

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.

purinda added a commit that referenced this pull request Feb 16, 2016
Support for PubSub Messaging
@purinda purinda merged commit ecb611e into master Feb 16, 2016
@purinda purinda deleted the feature/pubsub branch February 16, 2016 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants