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

Event payload filtering #176

Open
farshidtz opened this issue May 17, 2021 · 3 comments
Open

Event payload filtering #176

farshidtz opened this issue May 17, 2021 · 3 comments

Comments

@farshidtz
Copy link
Member

farshidtz commented May 17, 2021

The Notification API draft describes filtering of events based on their types.

The filtering based on payload was suggested by in #28 (comment). But there are different filtering requirements:

  1. Observe an attribute and trigger events whenever it changes. E.g. $.properties will trigger event when properties change.
  2. Filter the event payload and give the selected attributes to the client. E.g. $.properties will only give events with properties values.
  3. Combination of 1 and 2. E.g. $.properties will give only the changed properties.

Notes:

  • The update event produces only a diff. The order of applying selection and diff affects the final results.
  • JSONPath (and maybe also XPath) cannot be used to filter events based on assertions, e.g. to get TD events that have a specific type. Unlike in the search API, here, the expression is executed on a single TD.
  • This kind of event filtering is usually NOT possible in publish-subscribe exchanges (e.g. MQTT).
@farshidtz
Copy link
Member Author

farshidtz commented May 17, 2021

The current draft describes the first way. But this is confusing when considering what JSONPath and XPath are really meant for. Going to make a PR to remove that for now: #177.

mmccool added a commit that referenced this issue May 17, 2021
Remove payload-based event filtering.  Note this only comments out the section, we can revert this easily if desired.   Related issue (#176) is to figure out how to do this properly so will remain open.
@relu91
Copy link
Member

relu91 commented May 19, 2021

Thank you for creating the issue 👍🏻 and I agree that selecting while also filtering events is tricky. I just want to clarify a point. The use case in point 1 I slightly narrowed with respect to what we had in mind. It would be nice to have the ability to subscribe to facts about the whole collection of TDs, not just a specific one. Like with $[?(@.name === "Lillo")]. Translated in human-readable text: Please let me know when a TD named Lillo is popping up or is leaving the TDD.

Do you think is still confusing?

@farshidtz
Copy link
Member Author

farshidtz commented May 19, 2021

I fully understand your point and have also thought about applying the expression to a hypothetical list, but this is really a hack to make JSONPath work.

I particularly didn't pursue that approach for the following reasons:

  • JSONPath (based on common specs) is for filtering and selection, not assertion.
  • The server has to place each changed TD in an empty list and then apply JSONPath.
  • The API has to take one argument applied to individual events (event filtering by type) and another one (jsonpath expression) applied to a list of events data.

I personally think the best use of JSONPath in events is to filter and select parts of data from individual events (bullet number 2 above). Assertions on TD attributes can still be done on the client side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants