@@ -22,18 +22,30 @@ class SystemState:
22
22
A mapping from topics to the names of subscribers to that topic.
23
23
services: Mapping[str, Collection[str]]
24
24
A mapping from services to the names of providers of that service.
25
+ nodes: AbstractSet[str]
26
+ The names of all known nodes running on the system.
27
+ topics: AbstractSet[str]
28
+ The names of all known topics on the system with at least one
29
+ publisher or one subscriber.
25
30
"""
26
31
publishers : Mapping [str , Collection [str ]]
27
32
subscribers : Mapping [str , Collection [str ]]
28
33
services : Mapping [str , Collection [str ]]
29
34
nodes : AbstractSet [str ] = attr .ib (init = False , repr = False )
35
+ topics : AbstractSet [str ] = attr .ib (init = False , repr = False )
30
36
31
37
def __attrs_post_init__ (self ) -> None :
32
38
nodes : Set [str ] = set ()
33
39
nodes = nodes .union (* self .publishers .values ())
34
40
nodes = nodes .union (* self .subscribers .values ())
35
41
nodes = nodes .union (* self .services .values ())
42
+
43
+ topics : Set [str ] = set ()
44
+ topics = topics .union (self .publishers )
45
+ topics = topics .union (self .subscribers )
46
+
36
47
object .__setattr__ (self , 'nodes' , frozenset (nodes ))
48
+ object .__setattr__ (self , 'topics' , frozenset (topics ))
37
49
38
50
39
51
@attr .s (frozen = True , auto_attribs = True )
0 commit comments