Uninett / zino

Zino 2.0 - Network state monitor for research networks
Apache License 2.0
3 stars 5 forks source link

Rework trap observers to full classes with provisions auto-subscribing #227

Closed lunkwill42 closed 4 months ago

lunkwill42 commented 4 months ago

Now that we're on the brink of implementing more actual trap handlers, it's time to slightly rethink the original alpha implementation of the trap observer protocol.

This reworks the protocol from being simple functions to being slightly more involved classes (which can inherit directly from the protocol to remain somewhat simple). I realized that many of the observers will need access to the running ZinoState as well as the running event loop (which handlers already had an argument for). It makes no sense to keep adding arguments to trap handler functions for everything not all of them need. Instead, these more permanent values can be fed to the trap observers inherited constructor, and the handler function itself needs only concern itself with the incoming trap message argument.

This makes for even stronger separation of concerns.

This PR moves the list of ignored traps to a separate TrapObserver subclass, leaving it cleanly out of the TrapReceiver implementation itself, and serving as a sort of template of how the remaining observers can be implemented.

github-actions[bot] commented 4 months ago

Test results

    3 files      3 suites   51s :stopwatch: 318 tests 318 :heavy_check_mark: 0 :zzz: 0 :x: 954 runs  952 :heavy_check_mark: 2 :zzz: 0 :x:

Results for commit ed66ca32.

:recycle: This comment has been updated with latest results.

lunkwill42 commented 4 months ago

This apparently needs some more work, as the new Protocol implementation works just fine on Python 3.11 (which I use), but fails on Python 3.9 and 3.10. Something to do with the init method of TrapObserver and its subclasses.

codecov[bot] commented 4 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 98.98%. Comparing base (5805c67) to head (ed66ca3). Report is 2 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #227 +/- ## ======================================= Coverage 98.97% 98.98% ======================================= Files 47 48 +1 Lines 6532 6549 +17 ======================================= + Hits 6465 6482 +17 Misses 67 67 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

sonarcloud[bot] commented 4 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud