canonical / testflinger

https://testflinger.readthedocs.io/en/latest/
GNU General Public License v3.0
11 stars 17 forks source link

refactor(agent): unify treatment of output and other events #332

Open boukeas opened 1 month ago

boukeas commented 1 month ago

Description

Even though there is currently only a single event (output) that can be subscribed to on CommandRunner, there are two different methods for subscribing:

Likewise, there are two different methods for notifying the handlers that an event has taken place:

This PR unifies the treatment of output events and general events, i.e. output events are treated no differently than any other event. This makes the CommandRunner interface slimmer and more consistent but also allows for extensibility when additional event types might be added. Event handlers are still callables but now expect the event as their argument (carrying all necessary information to handle the event, e.g. the output, within the passed argument).

Resolved issues

This PR is not linked to a specific issue.

Documentation

No changes required to the documentation.

Web service API changes

No changes to the Web service API

Tests

All existing tests are still passing (following a couple of minor modifications to reflect the PR changes). No additional functionality has been added and hence no additional tests have been introduced.