Skip to content

Commit 02e6cf7

Browse files
samuel-gauthierrjarry
authored andcommitted
subscription: add support for filter_origin
Add support for the new SR_SUBSCR_FILTER_ORIG flag. Signed-off-by: Samuel Gauthier <[email protected]>
1 parent 2e67e25 commit 02e6cf7

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

cffi/cdefs.h

+3
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@ typedef enum sr_subscr_flag_e {
208208
SR_SUBSCR_ENABLED,
209209
SR_SUBSCR_UPDATE,
210210
SR_SUBSCR_OPER_MERGE,
211+
SR_SUBSCR_THREAD_SUSPEND,
212+
SR_SUBSCR_OPER_POLL_DIFF,
213+
SR_SUBSCR_FILTER_ORIG,
211214
...
212215
} sr_subscr_flag_t;
213216

sysrepo/session.py

+26-3
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ def subscribe_module_change(
326326
passive: bool = False,
327327
done_only: bool = False,
328328
enabled: bool = False,
329+
filter_origin: bool = False,
329330
private_data: Any = None,
330331
asyncio_register: bool = False,
331332
include_implicit_defaults: bool = True,
@@ -359,6 +360,9 @@ def subscribe_module_change(
359360
:arg enabled:
360361
The subscriber wants to be notified about the current configuration
361362
at the moment of subscribing.
363+
:arg filter_origin:
364+
Filter events on the originator side to unburden the subscriber, but
365+
results in 0 value for filtered-out changes in the subscriber infos.
362366
:arg private_data:
363367
Private context passed to the callback function, opaque to sysrepo.
364368
:arg asyncio_register:
@@ -390,7 +394,11 @@ def subscribe_module_change(
390394
if asyncio_register:
391395
no_thread = True # we manage our own event loop
392396
flags = _subscribe_flags(
393-
no_thread=no_thread, passive=passive, done_only=done_only, enabled=enabled
397+
no_thread=no_thread,
398+
passive=passive,
399+
done_only=done_only,
400+
enabled=enabled,
401+
filter_origin=filter_origin,
394402
)
395403

396404
check_call(
@@ -444,6 +452,7 @@ def subscribe_module_change_unsafe(
444452
passive: bool = False,
445453
done_only: bool = False,
446454
enabled: bool = False,
455+
filter_origin: bool = False,
447456
private_data: Any = None,
448457
asyncio_register: bool = False,
449458
) -> None:
@@ -478,6 +487,9 @@ def subscribe_module_change_unsafe(
478487
:arg enabled:
479488
The subscriber wants to be notified about the current configuration
480489
at the moment of subscribing.
490+
:arg filter_origin:
491+
Filter events on the originator side to unburden the subscriber, but
492+
results in 0 value for filtered-out changes in the subscriber infos.
481493
:arg private_data:
482494
Private context passed to the callback function, opaque to sysrepo.
483495
:arg asyncio_register:
@@ -503,7 +515,11 @@ def subscribe_module_change_unsafe(
503515
if asyncio_register:
504516
no_thread = True # we manage our own event loop
505517
flags = _subscribe_flags(
506-
no_thread=no_thread, passive=passive, done_only=done_only, enabled=enabled
518+
no_thread=no_thread,
519+
passive=passive,
520+
done_only=done_only,
521+
enabled=enabled,
522+
filter_origin=filter_origin,
507523
)
508524
check_call(
509525
lib.sr_module_change_subscribe,
@@ -1615,7 +1631,12 @@ def _get_oper_flags(no_state=False, no_config=False, no_subs=False, no_stored=Fa
16151631

16161632
# -------------------------------------------------------------------------------------
16171633
def _subscribe_flags(
1618-
no_thread=False, passive=False, done_only=False, enabled=False, oper_merge=False
1634+
no_thread=False,
1635+
passive=False,
1636+
done_only=False,
1637+
enabled=False,
1638+
oper_merge=False,
1639+
filter_origin=False,
16191640
):
16201641
flags = 0
16211642
if no_thread:
@@ -1628,6 +1649,8 @@ def _subscribe_flags(
16281649
flags |= lib.SR_SUBSCR_ENABLED
16291650
if oper_merge:
16301651
flags |= lib.SR_SUBSCR_OPER_MERGE
1652+
if filter_origin:
1653+
flags |= lib.SR_SUBSCR_FILTER_ORIG
16311654
return flags
16321655

16331656

0 commit comments

Comments
 (0)