Event System

Here you can find an analysis of the existing code base related to the Tango Event System (9.3.x). Existing code base is presented in block scheme diagrams. These block scheme diagrams are close to actual code, i.e. only a very few very low level details are omitted.


Event System classes


Event subscription

AttrProxy::subscribe_event

EventConsumer::subscribe_event

EventConsumer::connect_event

ZmqEventConsumer::zmq_specific

ZmqEventConsumer::connect_event_channel

ZmqEventConsumer::connect_event_system


Event reconnect

Reconnection happens in KeepAliveThread after having missed a heartbeat event.

Event unsubscribe

Entry point: EventConsumer::unsubscribe_event

ZMQ specific:


Conclusions

Currently event subscription algorithm on the client side is strictly procedural. Basically, all the code is located in EventConsumer::connect_event method.

There are several severe problems with the existing code base:

1) It does not follow OOP principles. Moreover, existing class structure makes it up side down - Channel and Callback structures inherit from more specific Zmq and Base (Notifd???) structures.

2) Logic is hard to read and maintain due to a lot of similar but quite differently written code; a lot of nested if/else statements; a lot of if-without-else statements, etc.

3) Code duplicates - full event name is built several times.

4) There is no clear API for event subscription algorithm. Frankly speaking, there is only one method EventConsumer::connect_event which is impossible to unit test.

5) There is no clear boundaries between low level and high level logic, e.g. raw response from the admin server passed through all over the code base.

A PR has been created to address these issues and to propose refactoring: link to GitHub.