-
Notifications
You must be signed in to change notification settings - Fork 87
Rebalance the modules to reduce complexity #298
Conversation
In order to keep the word "handler" for the user-facing handler functions only (created with decorators). The word "processor" is taken to match with the event-driver or event-stream system design terminology.
`kopf.reactor.handling` is already overloaded with logic and entities, it is time to split it. The dividing line is the processing of the incoming watch-events vs. executing the handlers. Also, vs. invocation of arbitrary callbacks, not only the handlers, in `kopf.reactor.invocation`.
They contain a lot of copy-pasting, so it is better to keep them away from the meaningful code (handlers & registries). As they are more protocols are going to be added, separating them seems a good refactoring move to rebalance the modules. Also, they are similar to `kopf.reactor.lifecycles`, as they declare the invokable function signatures the same way.
🤖 zincr found 0 problems , 1 warning
Details on how to resolve are provided below Large CommitsChecks all commits for large additions to a single file. Large commits should be reviewed more carefully for potential copyright and licensing issues This file contains a substantial change, please review to determine if the change comes from an external source and if there are any copyright or licensing issues to be aware of
|
🤖 zincr found 1 problem , 1 warning
Details on how to resolve are provided below ApprovalsAll proposed changes must be reviewed by project maintainers before they can be merged Not enough people have approved this pull request - please ensure that 1 additional user, who have not contributed to this pull request approve the changes.
Large CommitsChecks all commits for large additions to a single file. Large commits should be reviewed more carefully for potential copyright and licensing issues This file contains a substantial change, please review to determine if the change comes from an external source and if there are any copyright or licensing issues to be aware of
|
This pull request fixes 4 alerts when merging 147f5de into f82c90b - view on LGTM.com fixed alerts:
|
This pull request fixes 17 alerts when merging ac3b646 into f82c90b - view on LGTM.com fixed alerts:
|
This pull request fixes 17 alerts when merging 322a562 into f82c90b - view on LGTM.com fixed alerts:
|
What do these changes do?
Move classes and functions across the modules, extract new modules — in order to reduce the complexity and prepare the codebase for adding even more code.
The behaviour is not changed, only the imports.
Description
Before this PR, some modules were too large, up to 1k of lines, containing too many aspects and topics — as it has historically happened when new features were added. For example, activity execution was part of
handling.py
, as it was nearly a clone of handler execution. Similarly, event processing and handler invocation were there too (inhandling.py
) — since the times they were short and simple.With this PR, some huge modules are split into smaller ones, and classes/functions are moved all around. For example, watch-event handling is now renamed to processing and moved to
processing.py
— as per event processing of the event-driven design, which it is by its nature — this releases the term handling to the callback functions, which are currently called handlers.This is needed to make more space for adding more code (e.g. for daemons and timers) without exploding the modules beyond understanding.
See the list of commits for individual changes (they are all atomic). Briefly:
handling.py
->handling.py
+processing.py
+activities.py
registries.py
->registries.py
+handlers.py
+callbacks.py
+errors.py
The latter split also removes the cyclic imports as detected by LGTM (all 16 alarms at once) — this cycle is broken by moving
BaseHandler
away fromregistries
:registries
invocation
(forget_kwargs()
, needed for matching callbacks)lifecycles
(forLifeCycleFn
, needed forInvokable
definition)registries
(forBaseHandler
, needed forhandlers
kwarg)Replaced with a regular dependency tree:
registries
invocation
(forget_kwargs()
, needed for matching callbacks)lifecycles
(forLifeCycleFn
, needed forInvokable
definition)handlers
(forBaseHandler
, needed forhandlers
kwarg)handlers
(for all handlers dataclasses, previously located inregistries
)The users should not be affected, as these are the internal changes only — unless they monkey-patch some of the Kopf's internals.
Issues/PRs
Type of changes
Checklist
CONTRIBUTORS.txt