-
-
Notifications
You must be signed in to change notification settings - Fork 422
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
Internal endpoint refactoring, handler optimizations #771
Merged
Conversation
This file contains 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
These flags replace strings as constants used to register and identify Request Types (ie: GET, POST) and API Transport Types. Signed-off-by: Eric Callahan <[email protected]>
Emit a single event where the first argument contains a "JobEvent" enumeration that describes the particular event. This reduces the number of callbacks registered by JobState consumers and allows them react to multiple state changes in the same callback. The individual events remain for compatibility, however they are deprecated. Current modules should be updated to use the "job_state:state_changed" event and new modules must use this event. Signed-off-by: Eric Callahan <[email protected]>
Signed-off-by: Eric Callahan <[email protected]>
Signed-off-by: Eric Callahan <[email protected]>
Refactor endpoint registration to reduce duplicated code. Rename some APIDefinition attributes for clarity. Signed-off-by: Eric Callahan <[email protected]>
This change refactors the APIDefiniton into a dataclass, allowing defs to be shared directly among HTTP and RPC requests. In addition, all transports now share one instance of JSONRPC, removing duplicate registration. API Defintiions are registered with the RPC Dispatcher, and it validates the Transport type. In addition tranports may perform their own validation prior to request execution. Signed-off-by: Eric Callahan <[email protected]>
The default behavior of the subscribe API shares all subscription requests. API Transports require their own subscription. Add a method to facilitate this request. Signed-off-by: Eric Callahan <[email protected]>
Track authentication requirements in the API Definition. This eliminates the need to look up the authentication component to disable auth on an endpoint. Signed-off-by: Eric Callahan <[email protected]>
Signed-off-by: Eric Callahan <[email protected]>
Only log registration when verbose (debug) logging is enabled. In addition, log endpoint removal. Signed-off-by: Eric Callahan <[email protected]>
Add a POST /server/jsonrpc endpoint that processes jsonrpc requests from the body. This allows developers familiar with the JSON-RPC API to use it in places where a websocket is not desiriable. Signed-off-by: Eric Callahan <[email protected]>
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 pull request represents significant refactoring of some of Moonraker's internals. The goal is to prepare Moonraker for future additions such as:
An overview of the items changed:
Use Python enums and flags in place of strings where appropriate. This includes HTTP request methods (ie: GET, POST), tranport types (HTTP, WEBSOCKET, etc), Klippy State, and Job State.
Emit a single internal event for job state changes. The legacy events remain in place for now.
Optimize endpoint registration to use shared API Definitions for all transports. Previously
Use a single instance of the JsonRPC class across all transports.
I have been testing this branch for a few weeks and believe that I have squashed any outstanding issues/regressions. That said, I only test against official Moonraker components. Developers and users who use optional components such as timelapse may wish to test this branch.
As of right now I intent to merge around the end of the week, presuming no regressions are discovered.