I just wanted to know if there is a way to create a pub/sub mechanism using ceramic-one, in order to listen to events in different nodes and whenever there is new event, all the nodes listening will be forwarded this event without the need of querying for it.
I saw that it is possible to create a script to run the same query after certain period of time to verify if there was a new event, but this is not considered a pub/sub system (acts like it, but not the same since we need to query all the time). I was able to do this approach by using Flight SQL Library, but not the best solution from what I saw.
Ceramic One comes with its own synchronization mechanism called Recon that C1 nodes use to stay up-to-date with new events.
In order to use this mechanism, nodes must declare which Models they’re “interested” in. Once you’ve registered a Model with multiple nodes, any events on any of those nodes for that Model will be synchronized over to each interested node.
You can verify this by registering your interest in a Model on two nodes, then creating a new stream on Node 1. If you’re using FlightSQL to wait on the feed on the Node 2, you should quickly see the event from Node 1 show up on Node 2.
This can be extended across more nodes.
Did I understand your question correctly? Or did you mean some way for applications to know when a new event is available on their C1 node?
Yes, I think I am getting you and I am partially doing that.
So first, I would need some listeners (lets say these ones don’t have a ceramic node) to be informed whenever a new event is listened by the C1 node.
So I created a model and also set the interest for all instances related to this model in that node. So now, whenever I update the information of any instance, I will see a log in the C1 node related to the update, which is fine, and even I could track these logs to execute certain actions whenever I see any new event in these logs (which would work for me, because I could create a pub/sub mechanism to inform the listeners whenever I find a event log that I am looking for).
But in terms of the FlightSQL, I think there is no possible to receive event updates in a live way, at least I used this method for example:
const feed = await client.preparedFeedQuery(
"SELECT * FROM conclusion_events WHERE stream_cid = $1",
[["$1", modelCid]]
);
But this method only returns the events before the query, if I update the instance stream information from different modelInstanceClient after executing this query, the result in the terminal is not updated, and I would need to run the code again to get the update.
Am I doing something wrong? Let me know if I was not clear so I could clarify.
Another way I thought was tracking the logs of the C1 and whenever there was a log informing about aggregation of information of certain instance stream, then share with the listeners creating a pub/sub system with redis, so they would be informed whenever the information is updated through the node.
Because there is no way to get the logs of the events in the C1 node, same way it prints the aggregation of information, right?
And through the flight sql server, you need to execute a query to retrieve the evens/information if I am not wrong.