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

Add property filter to broker signal subscription #351

Open
fvacek opened this issue Sep 28, 2023 · 2 comments
Open

Add property filter to broker signal subscription #351

fvacek opened this issue Sep 28, 2023 · 2 comments
Assignees

Comments

@fvacek
Copy link
Contributor

fvacek commented Sep 28, 2023

.app/broker/currentClient:subscribe() can have two params currently

  • path
  • method

I suggest to provide third optional parameter property, which will behave like additional subscription filter. Notificaton is currently delivered to client if:

  1. signal method equals method subscribed
  2. signal path starts with path subscribed

Proposed change is to add third option:

  1. signal path ends with property subscribed

This change enables client to subscribe not only method but also method of some property.

Use-case:

We wand to subscribe chng signal of all alarms in shv tree but not other properties changes. Only way how to achieve this currently is to call subscribe for every alarm node. With this change implemented, one can call subscribe only once.

Before:

  • .app/broker/currentClient:subscribe({"path": "foo/bar1/alarm", "method": "chng"})
  • .app/broker/currentClient:subscribe({"path": "foo/bar2/alarm", "method": "chng"})
  • .app/broker/currentClient:subscribe({"path": "foo/bar/baz/alarm", "method": "chng"})

After:

  • .app/broker/currentClient:subscribe({"path": "foo", "method": "chng", "property": "alarm"})
@fvacek fvacek self-assigned this Sep 28, 2023
@fvacek
Copy link
Contributor Author

fvacek commented Sep 28, 2023

@Cynerd

@fvacek
Copy link
Contributor Author

fvacek commented Oct 1, 2023

Version 2

We keep path parameter unchanged.

A new pattern parameter will be added, when pattern is specified, then the path parameter is ignored. pattern parameter can hold glob pattern plus globstar (**). Signals with paths matching pattern will be subscribed.

Sub-broker note

When subscription with pattern is requested, then broker must split pattern to local and sub-broker path. One possible implementation is:

  1. foreach subrokers mountpoint
    1. remove last part of the pattern after slash, until it matches moutpoint
    2. matching part of pattern is local pattern, rest of pattern must be subscribed in subbroker
    3. if local part ends with **, then ** must be prepended also to subbroker pattern

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

No branches or pull requests

1 participant