Subscriber abstracted class - #64
Conversation
| """Allow connections from all origins.""" | ||
| return True | ||
|
|
||
| def update(self): |
There was a problem hiding this comment.
It doesn't look like update() is used anywhere.
There was a problem hiding this comment.
It can indeed be removed. I originally started using one update method, but then realized a Thing has separate notifications for an Action, Event and Property.
|
|
||
| def update_property(self, property_): | ||
| """ | ||
| Receive update from a Thing about an Property. |
There was a problem hiding this comment.
Just a nitpick about the comments on these three methods... They should probably say Send an update about X, rather than Receive, given that this is at the server layer.
There was a problem hiding this comment.
I used "Receive" since the Subscriber receives an update while a Thing (the subject) sends the notification according to the Observer pattern. Then again a Thing uses the method to send an update to the Subscriber, so I'll change that.
|
I assume you've rebuilt the whole server layer to use a different framework. Do you mind if I ask which framework, and why? |
I have created a gateway which brings together sensors from different sources (Kafka, external APIs..). This gateway has been implemented using Flask, because of the large, active community and the high amount of extensions. Of course I then wanted to use this package to make the gateway Web Thing Model compliant. |
|
Neat! |
|
Is there a chance you might launch a new release for these changes? It would be nice to be able to use the package. |
|
Done! 0.12.1 is out now. |
When I wanted to use the
webthing-pythonpackage without Tornado I ran into several issues, because the subscribers on a Thing are Tornado WebSockets resulting in a dependency between a Thing andtornado.websockets.To resolve this I created an abstract method named
Subscriber. It utilizes the Observer Pattern and describesupdatemethods which are called by a Thing when notifying the subscribers. These update methods can be implemented usingtornado.websocketsor any alternative. I extended theThingHandlerand implemented theSubscriberclass.Result
The
webthing-pythonpackage can now be used regardless the choice of Python web server.