-
Notifications
You must be signed in to change notification settings - Fork 109
Add HTTP publishing and image source operations #551
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
Add HTTP publishing and image source operations #551
Conversation
buildSrc/build.gradle
Outdated
| compile gradleApi() | ||
| compile localGroovy() | ||
| compile group: 'com.google.guava', name: 'guava', version: '19.0' | ||
| compile group: 'com.google.guava', name: 'guava', version: '18.0' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why that's there; I had pulled from WPIRoboticsProjects/master so this may have gotten changed.
Edit: Reverted in 438cf2f
Current coverage is 53.72%@@ master #551 diff @@
========================================
Files 158 176 +18
Lines 4699 4993 +294
Methods 0 0
Branches 500 521 +21
========================================
+ Hits 2522 2682 +160
- Misses 2037 2164 +127
- Partials 140 147 +7
|
| private final HttpServerFactory serverFactory; | ||
| private HttpServer server; | ||
| private final Map<String, GetHandler> getHandlers; | ||
| private final Map<String, List<PostHandler>> postHandlers; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could have used a multi-map for this: https://github.com/google/guava/wiki/NewCollectionTypesExplained#multimap
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would replace one stream operation and nothing else. Not much point.
GripServer returns a 423 error if a data request is sent while the pipeline is running
… static image source
This breaks compatibility with previous save files that use HTTP sources
…is running Use library-defined HTTP codes instead of redefining them 404 error when going to a URI such as /GRIP/data/foo or /GRIP/data* (now it has to be on a path that has a handler specifically assigned to it) Update tests to stop codacy bot from complaining so much
Remove GripProperties Tests are broken. Will be fixed in next commit.
It works on my Travis instance, so hopefully it's not borked on the main Travis instance
HTTP sources can only supply images POSTed to URLs under '/GRIP/upload/image', e.g. '/GRIP/upload/image/foo'
Also added logging to PedanticHandler when handling a request
- Remove unused imports and redundant asserts - Undid some Intellij autoformatting - Remove PipelineLoaded / PIpelineUnloaded events
… EventBus, add method to get server state
| this.server.setHandler(handlers); | ||
| handlers.addHandler(new NoContextHandler(contextStore)); | ||
|
|
||
| Runtime.getRuntime().addShutdownHook(new Thread(this::stop)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still needs to be made a daemon thread.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not how the shutdown hook API works. This is the proper way to do it
How to use the publishing operations
Use them in the UI just like a NetworkTable publish operation
Getting the data
All data published will be at
http://localhost:8080/GRIP/data(or whatever port you set in the settings) in json format. To get specific data, put their names as parameters in the URL -- e.g. if you wantmyContoursReportandmyBlobsReport, go tohttp://localhost:8080/GRIP/data?myContoursReport&myBlobsReportHTTP image source
GRIP-side
Just use it like a normal image source. The URL is configurable under
/GRIP/upload/image/-- e.g./GRIP/upload/image/my-image. Note that this path must be under/GRIP/upload/image/Supplier-side
Perform an HTTP
POSToperation to/GRIP/upload/image/your-imagewith the raw image bytes as binary data. It will be reconstructed server-side and trigger the pipeline to run if the image is different form the last one POSTed to that path.