Skip to content

Improve Test Loop Status Data Gathering #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
AntsInMyEy3sJohnson opened this issue Jul 15, 2022 · 0 comments · Fixed by #21
Closed

Improve Test Loop Status Data Gathering #8

AntsInMyEy3sJohnson opened this issue Jul 15, 2022 · 0 comments · Fixed by #21
Assignees
Labels
refactoring Changes to the code base that will lead to better "-ilities" (maintainability, readability etc.).

Comments

@AntsInMyEy3sJohnson
Copy link
Owner

AntsInMyEy3sJohnson commented Jul 15, 2022

Context

  • Package api exposes an endpoint, /status, external actors can use to query the status of the various test loops that are currently being run (total number of runs, number of runs already completed etc.)
  • Test loop status currently represented as a struct type in the api package itself

Problem

  • According to the Tell, Don't Ask software engineering guideline, the behavior described above is fine -- the test loops inform or "tell" the api package about their status rather than the latter querying, or "asking", for it
  • But: The fact that the test loop status is represented as a struct type in the api package means the latter embodies a lot of knowledge about how the status of a test loop has to look like -- something that only the test loops themselves should have to worry about
  • This creates unnecessary coupling between the api package and the test loops (map test loop and queue test loop)

Solution

Two options:

  1. In api package, represent test loop status simply as map[string]interface{}. Offer function the test loops can invoke to update the state this map holds. Upside: Tell, Don't Ask guideline adhered to. Downside: Test loops have to know how to update the map, thus they have to have knowledge about what it contains and what its structure is -- knowledge they should not need to have.
  2. Keep test loop status internal to the test loops. Offer function the api/endpoints.go code can call that represents the status as map[string]interface{}. Upside: Function would act as a "coupling breaker" between test loops and api -- the former could use their internal status representation, and the latter could query a map view thereof, so each component encapsulates only the knowledge it needs to operate on its own data structures. Downside: Violation of Tell, Don't Ask.

So this is really about playing around with these two options and see which one turns out to be more satisfying.

@AntsInMyEy3sJohnson AntsInMyEy3sJohnson added the refactoring Changes to the code base that will lead to better "-ilities" (maintainability, readability etc.). label Jul 15, 2022
@AntsInMyEy3sJohnson AntsInMyEy3sJohnson self-assigned this Nov 7, 2022
@AntsInMyEy3sJohnson AntsInMyEy3sJohnson linked a pull request Nov 23, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Changes to the code base that will lead to better "-ilities" (maintainability, readability etc.).
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant