55< meta name ="viewport " content ="width=device-width, initial-scale=1, minimum-scale=1 " />
66< meta name ="generator " content ="pdoc 0.10.0 " />
77< title > state_signals API documentation</ title >
8- < meta name ="description " content ="" />
8+ < meta name ="description " content ="State/Event Signal Module … " />
99< link rel ="preload stylesheet " as ="style " href ="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/sanitize.min.css " integrity ="sha256-PK9q560IAAa6WVRRh76LtCaI8pjTJ2z11v0miyNNjrs= " crossorigin >
1010< link rel ="preload stylesheet " as ="style " href ="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/typography.min.css " integrity ="sha256-7l/o7C8jubJiy74VsKTidCy1yBkRtiUGbVkYBylBqUg= " crossorigin >
1111< link rel ="stylesheet preload " as ="style " href ="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/styles/github.min.css " crossorigin >
2222< h1 class ="title "> Module < code > state_signals</ code > </ h1 >
2323</ header >
2424< section id ="section-intro ">
25+ < p > State/Event Signal Module</ p >
26+ < p > Adds two new, simple-to-use objects:</ p >
27+ < ul >
28+ < li > SignalExporter
29+ (for publishing state signals and handling subscribers + responses)
30+ </ li >
31+ < li > SignalResponder
32+ (for receiving state signals, locking onto publishers, and publishing responses)</ li >
33+ </ ul >
34+ < p > Also provides two dataclass specifications:</ p >
35+ < ul >
36+ < li > Signal
37+ (state signal protocol payload definition)
38+ </ li >
39+ < li > Response
40+ (response protocol payload definition)</ li >
41+ </ ul >
42+ < p > Combining redis pubsub features with state signal + response protocols,
43+ these additions make state signal publishing, subscribing, receiving,
44+ and responding incredibly easy to integrate into any code.</ p >
2545< details class ="source ">
2646< summary >
2747< span > Expand source code</ span >
2848</ summary >
29- < pre > < code class ="python "> from dataclasses import dataclass
30- from enum import Enum
31- from typing import Any, Dict, Iterator, List, Optional, Tuple
32- import redis
33- import platform
34- import json
35- import time
36- import uuid
37- import logging
38-
39-
40- """
49+ < pre > < code class ="python "> """
4150State/Event Signal Module
4251
4352Adds two new, simple-to-use objects:
44- - SignalExporter (for publishing state signals and handling subscribers + responses)
45- - SignalResponder (for receiving state signals, locking onto publishers, and publishing responses)
53+
54+ - SignalExporter (for publishing state signals and handling subscribers + responses)
55+ - SignalResponder (for receiving state signals, locking onto publishers, and publishing responses)
4656
4757Also provides two dataclass specifications:
48- - Signal (state signal protocol payload definition)
49- - Response (response protocol payload definition)
58+
59+ - Signal (state signal protocol payload definition)
60+ - Response (response protocol payload definition)
5061
5162Combining redis pubsub features with state signal + response protocols,
5263these additions make state signal publishing, subscribing, receiving,
5364and responding incredibly easy to integrate into any code.
5465"""
5566
5667
68+ from dataclasses import dataclass
69+ from enum import Enum
70+ from typing import Any, Dict, Iterator, List, Optional, Tuple
71+ import redis
72+ import platform
73+ import json
74+ import time
75+ import uuid
76+ import logging
77+
78+
5779def _create_logger(
5880 class_name: str, process_name: str, log_level: str
5981) -> logging.Logger:
@@ -77,6 +99,10 @@ <h1 class="title">Module <code>state_signals</code></h1>
7799
78100
79101class ResultCodes(Enum):
102+ """
103+ All potential result codes when publishing a signal. See the publish_signal
104+ method under SignalExporter for more details.
105+ """
80106 ALL_SUBS_SUCCESS = 0
81107 SUB_FAILED = 1
82108 MISSING_RESPONSE = 2
@@ -198,7 +224,7 @@ <h1 class="title">Module <code>state_signals</code></h1>
198224 log_level: str = "INFO",
199225 ) -> None:
200226 """
201- Sets exporter object fields and generates unique publisher_id.
227+ init: Sets exporter object fields and generates unique publisher_id.
202228 Allows for specification of redis host/port. Also allows runner
203229 hostname to be inputted manually (otherwise will default to
204230 platform.node() value)
@@ -334,10 +360,11 @@ <h1 class="title">Module <code>state_signals</code></h1>
334360 is reached (default = 20s). Returns one of the below result codes based on
335361 signal publish/response success.
336362
337- RESULT CODES:
338- ALL_SUBS_SUCCESS = 0 = ALL SUBS RESPONDED WELL
339- SUB_FAILED = 1 = ONE OR MORE SUB RESPONDED BADLY
340- MISSING_RESPONE = 2 = NOT ALL SUBS RESPONDED
363+ Result Codes:
364+
365+ - ALL_SUBS_SUCCESS = 0 = all subs responded well
366+ - SUB_FAILED = 1 = one or more sub responded badly
367+ - MISSING_RESPONE = 2 = not all subs responded
341368 """
342369 if not isinstance(timeout, int):
343370 raise TypeError("'timeout' arg must be an int value")
@@ -437,7 +464,7 @@ <h1 class="title">Module <code>state_signals</code></h1>
437464 log_level="INFO",
438465 ) -> None:
439466 """
440- Sets exporter object fields and generates unique responder_id.
467+ init: Sets responder object fields and generates unique responder_id.
441468 Allows for specification of redis host/port.
442469 """
443470 self.logger = _create_logger("SignalResponder", responder_name, log_level)
@@ -667,12 +694,17 @@ <h3>Methods</h3>
667694< span > (</ span > < span > value, names=None, *, module=None, qualname=None, type=None, start=1)</ span >
668695</ code > </ dt >
669696< dd >
670- < div class ="desc "> < p > An enumeration.</ p > </ div >
697+ < div class ="desc "> < p > All potential result codes when publishing a signal. See the publish_signal
698+ method under SignalExporter for more details.</ p > </ div >
671699< details class ="source ">
672700< summary >
673701< span > Expand source code</ span >
674702</ summary >
675703< pre > < code class ="python "> class ResultCodes(Enum):
704+ """
705+ All potential result codes when publishing a signal. See the publish_signal
706+ method under SignalExporter for more details.
707+ """
676708 ALL_SUBS_SUCCESS = 0
677709 SUB_FAILED = 1
678710 MISSING_RESPONSE = 2</ code > </ pre >
@@ -840,7 +872,7 @@ <h3>Methods</h3>
840872Also handles subscriber recording and response reading/awaiting. Uses the standard
841873signal protocol for all published messages. Easy-to-use interface for publishing
842874legal signals and handling responders.</ p >
843- < p > Sets exporter object fields and generates unique publisher_id.
875+ < p > init: Sets exporter object fields and generates unique publisher_id.
844876Allows for specification of redis host/port. Also allows runner
845877hostname to be inputted manually (otherwise will default to
846878platform.node() value)</ p > </ div >
@@ -865,7 +897,7 @@ <h3>Methods</h3>
865897 log_level: str = "INFO",
866898 ) -> None:
867899 """
868- Sets exporter object fields and generates unique publisher_id.
900+ init: Sets exporter object fields and generates unique publisher_id.
869901 Allows for specification of redis host/port. Also allows runner
870902 hostname to be inputted manually (otherwise will default to
871903 platform.node() value)
@@ -1001,10 +1033,11 @@ <h3>Methods</h3>
10011033 is reached (default = 20s). Returns one of the below result codes based on
10021034 signal publish/response success.
10031035
1004- RESULT CODES:
1005- ALL_SUBS_SUCCESS = 0 = ALL SUBS RESPONDED WELL
1006- SUB_FAILED = 1 = ONE OR MORE SUB RESPONDED BADLY
1007- MISSING_RESPONE = 2 = NOT ALL SUBS RESPONDED
1036+ Result Codes:
1037+
1038+ - ALL_SUBS_SUCCESS = 0 = all subs responded well
1039+ - SUB_FAILED = 1 = one or more sub responded badly
1040+ - MISSING_RESPONE = 2 = not all subs responded
10081041 """
10091042 if not isinstance(timeout, int):
10101043 raise TypeError("'timeout' arg must be an int value")
@@ -1137,10 +1170,13 @@ <h3>Methods</h3>
11371170subscribed responders (if any). The method will give up once the timeout period
11381171is reached (default = 20s). Returns one of the below result codes based on
11391172signal publish/response success.</ p >
1140- < p > RESULT CODES:
1141- ALL_SUBS_SUCCESS = 0 = ALL SUBS RESPONDED WELL
1142- SUB_FAILED = 1 = ONE OR MORE SUB RESPONDED BADLY
1143- MISSING_RESPONE = 2 = NOT ALL SUBS RESPONDED</ p > </ div >
1173+ < p > Result Codes:</ p >
1174+ < ul >
1175+ < li > ALL_SUBS_SUCCESS = 0 = all subs responded well </ li >
1176+ < li > SUB_FAILED = 1 = one or more sub responded badly
1177+ </ li >
1178+ < li > MISSING_RESPONE = 2 = not all subs responded</ li >
1179+ </ ul > </ div >
11441180< details class ="source ">
11451181< summary >
11461182< span > Expand source code</ span >
@@ -1160,10 +1196,11 @@ <h3>Methods</h3>
11601196 is reached (default = 20s). Returns one of the below result codes based on
11611197 signal publish/response success.
11621198
1163- RESULT CODES:
1164- ALL_SUBS_SUCCESS = 0 = ALL SUBS RESPONDED WELL
1165- SUB_FAILED = 1 = ONE OR MORE SUB RESPONDED BADLY
1166- MISSING_RESPONE = 2 = NOT ALL SUBS RESPONDED
1199+ Result Codes:
1200+
1201+ - ALL_SUBS_SUCCESS = 0 = all subs responded well
1202+ - SUB_FAILED = 1 = one or more sub responded badly
1203+ - MISSING_RESPONE = 2 = not all subs responded
11671204 """
11681205 if not isinstance(timeout, int):
11691206 raise TypeError("'timeout' arg must be an int value")
@@ -1243,7 +1280,7 @@ <h3>Methods</h3>
12431280Can be used both for listening for signals as well as responding to them. Also
12441281allows for locking onto specific tags/publisher_ids. Uses the standard signal
12451282response protocol for all published messages.</ p >
1246- < p > Sets exporter object fields and generates unique responder_id.
1283+ < p > init: Sets responder object fields and generates unique responder_id.
12471284Allows for specification of redis host/port.</ p > </ div >
12481285< details class ="source ">
12491286< summary >
@@ -1265,7 +1302,7 @@ <h3>Methods</h3>
12651302 log_level="INFO",
12661303 ) -> None:
12671304 """
1268- Sets exporter object fields and generates unique responder_id.
1305+ init: Sets responder object fields and generates unique responder_id.
12691306 Allows for specification of redis host/port.
12701307 """
12711308 self.logger = _create_logger("SignalResponder", responder_name, log_level)
0 commit comments