caas-team / sparrow

A monitoring tool to gather infrastructure network information
Apache License 2.0
6 stars 4 forks source link

refactor: implement common check methods by check base #135

Open lvlcn-t opened 1 month ago

lvlcn-t commented 1 month ago

~⚠ Review after #134 has been merged, since this PR is based on that one.~

Motivation

Currently, we have a lot of duplicated code for each check. This PR aims to refactor the code to have a common base struct which implements the methods that are common for all checks.

Partly addresses #99 but could be extended to generate the wrapping methods and method shells/types for each check.

Changes

I've removed the duplicated code and adjusted our common base struct to implement the methods that are common for all checks. This way we can reduce the amount of code and make it easier to maintain.

To do so I've made it a generic struct that takes in the config type of an individual check. This way we can embed the common check base struct in each check and pass the config to the common check base struct.

For additional information look at the commits.

Tests done

I've moved the tests for the common methods to test the common check base struct. All tests succeeded.

TODO