You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
stateBuilder is a function object that takes some input data (current state and target state, and kong version) and produces some output data.
The distinction between inputs and outputs is not very clear in the implementation of stateBuilder. I would like to put on the table (for consideration) the possibility of refactoring stateBuilder into pure mathematical functions with no preserved state - similar to what happened to parser in KIC. I believe that this would help with testability and readability. Of course, let's be mindful of priorities in our projects - I only want these considerations to contribute to the vision of where we want to take the codebase to in small steps.
When we think of stateBuilder as a mathematical function, like described above: A mathematical function changing its outputs based on version of some software dependency (here: gateway version) suffers from two problems:
2.1. keeps stateBuilder (a mathematical function processing X into Y) concerned with a version of "some external" component - which feels at odds with SRP
2.2. in tests, couples logic with software versions. I believe that the role of a unit test here would be to check that "state builder properly adds tags when asked to, and does not when not asked to". "Asking" the state builder to add tags or not depending on Gateway version is a separate concern imo, and should happen on a higher level (and would be tested on a higher level too, in an integration test).
To make the above considerations actionable, I believe that the following would help improve the code health:
kick kongVersion out of stateBuilder to a higher level, and replace it with knobs that control whether selectTags get applied to all creds, or all creds but mtls-auth, or to none.
refactor stateBuilder into pure stateless functions
stateBuilder
is a function object that takes some input data (current state and target state, and kong version) and produces some output data.stateBuilder
. I would like to put on the table (for consideration) the possibility of refactoring stateBuilder into pure mathematical functions with no preserved state - similar to what happened toparser
in KIC. I believe that this would help with testability and readability. Of course, let's be mindful of priorities in our projects - I only want these considerations to contribute to the vision of where we want to take the codebase to in small steps.2.1. keeps stateBuilder (a mathematical function processing X into Y) concerned with a version of "some external" component - which feels at odds with SRP
2.2. in tests, couples logic with software versions. I believe that the role of a unit test here would be to check that "state builder properly adds tags when asked to, and does not when not asked to". "Asking" the state builder to add tags or not depending on Gateway version is a separate concern imo, and should happen on a higher level (and would be tested on a higher level too, in an integration test).
To make the above considerations actionable, I believe that the following would help improve the code health:
kongVersion
out ofstateBuilder
to a higher level, and replace it with knobs that control whether selectTags get applied to all creds, or all creds but mtls-auth, or to none.Originally posted by @mflendrich in #455 (comment)
The text was updated successfully, but these errors were encountered: