-
Notifications
You must be signed in to change notification settings - Fork 51
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
Generic subject observer (RFC 7641) support #68
Comments
I'm glad to hear that the repository can help you. The first change is wonderful. The observer feature will be easier to use. But the other changes will break the origin definition from RFC 7641. I think they are not fit for the coap library. please correct me if i misunderstood. |
I'm interested to learn more about your concerns on the other changes. I informed my original recommendation by reading RFC 7641 and other CoAP server implementations and as I understand it the intention of RFC 7641 is that observe notifications should be identical with the exception of the Observe/Token options to simply re-issuing a GET request. More formally, an observed GET request should yield a stream of updates that are eventually consistent with any future regular GET request. Thus logically saying that a resource changed is most consistent with simply presuming that to be the same as making a GET request and sending the response with the Observe/Token options synthesized onto the response. Also note regarding #3, I meant to say that a failed GET request would logically deny observation and that it would not be tied to the PUT request at all (currently coap-rs simply yields a 4.04 if you issue a GET Observe:0 request to something that you have not previously PUT into). I wrongly implied that the coap-rs implementation would require all GET requests to be observable. That said, a handler should be able to deny observability in the current implementation by simply yielding a 4.xx code if the Observe flag is set which should cover our bases. Do you have an example of something you'd prefer to see that better matches how RFC 7641 is defined? |
You are right. Some functions are not implement. But I think the former actions should be reserved, e.g. the PUT request automatically affect resources. |
PUT, POST, and DELETE can automatically trigger a resource change event, however we have to be careful there because only certain response codes would indicate that a change indeed occurred. For example, a PUT request that is rejected with 4.xx should not trigger notifications. I think I can come up with a best effort set of cases that should cover common uses but still be flexible for developers to control how it works. |
Unfortunately after trying pretty hard to make Observe support integration work I've decided I need to go a different direction and start a new project with a higher level API goal for cleaner integration: https://github.com/jasta/coap-server-rs. While coap-rs has been extremely useful in getting me started there are some pretty significant architectural challenges that would need to be overcome for good generic support for more advanced features and that would end up taking the project in a very different direction with potentially a lot of disruption to current users. For now I'm choosing to incubate a more experimental but convenient approach in the linked repo above (which does have transparent Observe and Block-wise support) For an example of how this new API I'm using supports observe, see: https://github.com/jasta/coap-server-rs/blob/main/examples/app_observable.rs |
The observer support today is a very useful start however it's missing a few key APIs to customize it to work similar to other CoAP implementations and, more importantly, generalized to the use cases described in RFC 7641. For example, the support requires that PUT request be issued in order for the system to work, even though we wouldn't normally expect read-only endpoints to have such a feature. Further, the implementation is just a limited replaying of the last PUT payload without any of the handling consideration that you'd get with a GET request (like if the GET response included ContentFormat options, the resulting notification for this resource path would not include that information).
I believe this can be addressed relatively easily but the easy way will break a few implementation assumptions and change the public API. For those reasons I wanted to open a dialog to make sure my assumptions are correct and my goals are consistent with the projects before proceeding to a pull request. Specifically, the following changes should make this possible:
server.resource_changed(path)
.server.resource_changed(path)
. This response would be cached instead and copied to all observing clients.What do you think of these changes? Are you interested in me proceeding with a possible PR?
Thanks for the great project, this is really helping me get a cool project of mine off the ground using an ultra low powered old Lego EV3 brick as the hub!
The text was updated successfully, but these errors were encountered: