Create ControllerAPI class to decouple transport from Controller#87
Merged
Create ControllerAPI class to decouple transport from Controller#87
Conversation
This was referenced Nov 20, 2024
Closed
Contributor
Author
|
2 tasks
b34a45a to
fedfb44
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #87 +/- ##
==========================================
+ Coverage 89.66% 90.52% +0.85%
==========================================
Files 40 41 +1
Lines 1858 1920 +62
==========================================
+ Hits 1666 1738 +72
+ Misses 192 182 -10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
07d6568 to
31e8269
Compare
908f281 to
3af55df
Compare
Merged
3af55df to
973d2bf
Compare
evvaaaa
suggested changes
Mar 5, 2025
Contributor
evvaaaa
left a comment
There was a problem hiding this comment.
I really like abstracting this stuff out of controller, nice job!
383fb8f to
a7aeff5
Compare
a7aeff5 to
98807bc
Compare
evvaaaa
approved these changes
Mar 10, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This changes a few key parts of the internal logic to make the static typing more robust and to improve the driver API.
It is now possible to dynamically create
Methods as well asAttributes. This is shown in the new test here where aCommandis added to aControllerduringinitialise.The new
Command,PutandScanmethods enable decoupling theControllerfrom the transport layer via a newControllerAPIclass, which replaces and extends the oldSingleMappingclass. The differences being:ControllerAPIdoesn't need a reference to theController- it is entirely self contained because the methods are dynamically bound to the controller instance and can be called outside the context of the class.ControllerAPImaintains the tree structure from theControllerswhereSingleMappingflattened itSummary of changes:
Controller.get_controller_mappings->ControllerAPI.walk_apiSingleMapping.{attributes,command_methods,put_methods,scan_methods}->ControllerAPI.{attributes,command_methods,put_methods,scan_methods}SingleMapping.Controller.path->ControllerAPI.path{Command,Put,Scan}.fnis now callable directly. Don't doMethodType(method, controller)orgetattr(controller, method.__name__)().for Controller in SingleMapping.Controller.get_sub_controllers()->for ControllerAPI in ControllerAPI.sub_apis()Fixes #74
Fixes #60
Fixes #93
Fixes #62