Skip to content
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

Adding websocket event publisher #65

Merged
merged 3 commits into from
Jun 19, 2018
Merged

Adding websocket event publisher #65

merged 3 commits into from
Jun 19, 2018

Conversation

hazmat345
Copy link
Contributor

No description provided.

@codecov
Copy link

codecov bot commented Jun 15, 2018

Codecov Report

Merging #65 into develop will decrease coverage by 0.35%.
The diff coverage is 65%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop      #65      +/-   ##
===========================================
- Coverage    71.84%   71.48%   -0.36%     
===========================================
  Files           20       20              
  Lines          959      996      +37     
===========================================
+ Hits           689      712      +23     
- Misses         270      284      +14
Impacted Files Coverage Δ
brew_view/__main__.py 0% <0%> (ø) ⬆️
brew_view/publishers.py 52.55% <100%> (+2.17%) ⬆️
brew_view/controllers/__init__.py 100% <100%> (ø) ⬆️
brew_view/controllers/event_api.py 56.09% <57.69%> (+2.76%) ⬆️
brew_view/__init__.py 90.83% <66.66%> (-1.41%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 96758fc...21d1bab. Read the comment docs.

Copy link
Member

@loganasherjones loganasherjones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the long term goal here is to support actual websockets on the JS front-end? If that is the case, I can't wait to refactor the front-end :)

@@ -23,6 +23,9 @@ def shutdown():
brew_view.logger.info("Stopping server.")
brew_view.server.stop()

# Close any open websocket connections
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather see this as a docstring on the shutdown method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -120,6 +126,7 @@ def _setup_tornado_app():
(r'{0}config/swagger/?'.format(prefix), SwaggerConfigHandler),
(r'{0}version/?'.format(prefix), VersionHandler),
(r'{0}api/v1/spec/?'.format(prefix), SpecHandler),
(r'{0}events/?'.format(prefix), EventSocket),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would think we would want to version this endpoint also? If we aren't sure, I'd still expose it on api/vbeta/websocket or something to that affect.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call - my initial thought is to put it with the versioned ones. Let me know if you'd rather have it in beta.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, I remember why I punted on this decision 😄

We already have a POST api/vbeta/events/ route that allows for publishing your own events. I think we eventually want to support retrieving events by an ID (assuming you've been saving them to mongo)?

Now I'm thinking it would be better to have this be something besides events so we don't muddy the RESTfulness.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And now I remember more ... the apispec package we're using to construct the swagger spec doesn't like that we're putting a websocket handler in our 'published' path list. Which makes sense - it's not really designed for non-REST things. See:

swagger-api/swagger-socket#47
OAI/OpenAPI-Specification#55

So far all of the API we've wanted to publish has fit nicely into REST, so it's fit nicely into swagger (and apispec). We'll have to decide how to move forward with documenting the websocket support.

@hazmat345
Copy link
Contributor Author

Yeah, this actually came about because I was annoyed at the admin page. I had a branch from a while ago where I did this and started reworking the admin page. Figured it was good to break them up and just get this merged.

@hazmat345 hazmat345 merged commit e8e7771 into develop Jun 19, 2018
@hazmat345 hazmat345 deleted the websocket_publisher branch June 19, 2018 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants