Pub/Sub messaging over ubus with Lua

In my GSoC project (more about this here) I need to do a lot of ubus use.

In this case, I want to connect a series of services in a publish-subscribe model.

I want to thank Commodo for his ubus examples… I will be showing a similar example that you can test to have a publish-subscribe pattern implemented in ubus and lua.

In a publish-subscribe you have two type of agents: publishers and subsribers.

Publishers send messages tagged with a specific topic.

Subscribers wait for messages about a specific topic.

Tue Bus is in charge of routing messages based on the topic from publishers to subscribers.

In our case, ubus will act as the Bus.

Here is the code:

First, the publisher:

And this is the subscriber:

I still have to figure out how it works… will expand this post once I finish understanding everything.
In particular, I still don’t understand how the notify send an event with a “test.alarm” topic, but the subscribe just listens to “test”… maybe is listening to everything that starts with test.

One thought on “Pub/Sub messaging over ubus with Lua

Leave a Reply

Your email address will not be published. Required fields are marked *