-
-
Notifications
You must be signed in to change notification settings - Fork 421
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
spoolman: connection and proxy improvements #792
Conversation
I should also note that this PR does not do validation when a |
(cc'ing @matmen as he's been maintaining Spoolman integration in Fluidd) |
Out of curiosity, I saw you already made some changes to moonraker which actually resolved the error. |
Thanks for the ping Arksine. I have prepared a PR for this improvement. Supporting the old and new versions in parallel in the GUI is also easily possible. This should allow the user to update without any problems. |
When testing my changes I noticed some behavior (not introduced by the changes themselves) that could be improved on. For example, the Spoolman component will report when new extrusion is detected, presuming that the configured "sync time" has elapsed. This can lead to a condition where some extrusion goes unreported until the spool ID is changed. If spoolman isn't connected during that change the extrusion is lost. I have refactored how reporting is done so its filament data is queued and reported on a timer. This eliminates the Locks, making the code cleaner. It also keeps spool data persistent if Spoolman is not available. In addition I noticed that the spoolman module wasn't accounting for tool changes, so I added that (although I can't test it as I don't have any printers with multiple tools). It should work fine though. Finally, I added a new endpoint and a new notification so frontends can be notified of Spoolman's connection status. The The |
Connect to the spoolman sevice via websocket to receive spool events. In addition, this gives Moonraker a persistent connection to know when the service is available. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
The loop time is monotonic and can't be affected by changes to the system clock. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
The exisiting implementation of spoolman's proxy endpoint returns responses and errors exactly as they are received by spoolman. This creates a problem of ambiguity, as the frontend cannot easily diffentiate between an error returned by Moonraker and an error returned by Spoolman. This implements a "v2" alternate response to proxy requests. All requests to spoolman will return success, with responses wrapped in a top level object. Successful requests will be returned in a "spoolman_response" object, errors in a "spoolman_error" object. Initially v2 responses will be opt-in to prevent breaking existing spoolman implementations. However, as of this commit the v1 response is deprecated and will be removed in a future version of Moonraker. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Use a python dict to act as a queue for reporting used filament per spool. This eliminates the need for locks and resolves potential issues with spool changes when the Spoolman service is not available. In addition, add support for tracking multiple tools Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Avoid running multiple callbacks if a timer is stopped and restarted in quick succession. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This performs a significant refactor to the ZipDeploy class, making it near identiical to WebClientDeploy. Zipped applications have the same "release_info" requirement as web clients. Unlike web clients, they may also configure the dependency and service options available to git repos. The ZipDeploy class can also support we clients, eliminating duplicate code and the need to keep web_deploy.py. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Reduce verbosity in release mode and add connection status to the log rollover. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
a9b6deb
to
d10ce87
Compare
This Pull Request aims to resolve issues around Spoolman proxy errors. It appears that deleted spools or spool IDs that don't exist can lead to 404 responses that confuse frontends. To help resolve this two changes have been added:
Moonraker opens a websocket connection to Spoolman to listen for deleted spools. If a deleted spool ID matches Moonraker's current spool ID then it will be set to
None
and the spool ID changed event will be broadcast to clients. In addition the perisistent connection to Spoolman avoids attempts to make HTTP API requests when it is known that Spoolman is not available.Moonraker's
/server/spoolman/proxy
API now provides an alternate response. It is currently opt-in via theuse_v2_response
argument. When set totrue
, successful responses to the proxy will be returned in the following format:If Spoolman returns an error then
response
will benull
anderror
will contain error details:This eliminates the ambiguity between Spoolman errors and Moonraker errors that can confuse frontends. If Moonraker returns an error response the frontend will know that Moonraker is the source of the error and can handle it appropriately.
@meteyou @pedrolamas @Clon1998
I believe this pull request is likely of interest to all of you.