I have now refactored and reimplemented the Event machinery for monit.
If you are a committer, please read this mail since things have
changed :-)
I have added a new class called event.c/event.h which implements the
event handling machinery I outlined in a previous mail. You should
examine this class and try to understand how event handling is done.
Here is a brief description of the changes:
1) All the alert_xxx methods are removed.
2) do_start/do_restart/do_stop is removed from validate.c, simplified
and moved into event.c as event handlers for start/restart/stop
events.
3) There is now a single unified api for posting events. The method
you should use is Event_post(..) see event.c for details.
4) Event handling is conducted in the local method handle_event in
event.c. Here, all action events i.e. start/restart/stop events are
handled. Alert events are also handled in this method and later
when implemented, exec events will be handled there as well. As you
can see from the handle_event method the logic is as follows: When
an event is recieved the event is dropped down through the various
event handlers which will handle the event (or not).
5) A new start event is added to truly distinguish between start and
restart events. If a Service start/stop/restart should fail for
some reason the event is changed to a failed event and the user is
notified that the action failed. This was not the case before and
monit should now be much more consistent in reporting.
6) The event handling architecture in monit is now a true event
handling system and the design should make it easy to include new
event handlers in a consistent and in a logic way. If necessary it
is also possible to do the call to handle_event in a new thread to
make the event handling non-sequential and more responsive.
TODO
Christan and Martin, I hope that you can refactor the code in
validate.c as I mentioned in the previous mail on this topic, so that
all the code in the switch/case statement is moved into it's own
function.
case TASK_PROCESS <- Christian
case TASK_DEVICE <- Martin
case TASK_FILE <- Marin
case TASK_DIRECTORY <- Martin
Agree?