From f1300e4985a79728765c7a806fdd76f3e01f9adb Mon Sep 17 00:00:00 2001 From: komuW Date: Thu, 5 Sep 2019 18:08:28 +0300 Subject: [PATCH 01/18] validate args --- naz/log.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/naz/log.py b/naz/log.py index 7bda8cb1..c7719fe6 100644 --- a/naz/log.py +++ b/naz/log.py @@ -215,6 +215,9 @@ def __init__( target: the ultimate `log handler `_ that will be used. flushOnClose: whether to flush the buffer when the handler is closed even if the flush level hasn't been exceeded """ + self._validate_args( + flushLevel=flushLevel, capacity=capacity, target=target, flushOnClose=flushOnClose + ) # call `logging.handlers.MemoryHandler` init super(BreachHandler, self).__init__( # type: ignore capacity=capacity, @@ -234,3 +237,28 @@ def shouldFlush(self, record: logging.LogRecord) -> bool: Implementation is mostly taken from `logging.handlers.MemoryHandler` """ return record.levelno >= self.flushLevel # type: ignore # pytype: disable=attribute-error + + def _validate_args( + self, flushLevel: int, capacity: int, target: logging.Handler, flushOnClose: bool + ): + if not isinstance(flushLevel, int): + raise ValueError( + "`flushLevel` should be of type:: `int` You entered: {0}".format(type(flushLevel)) + ) + if not isinstance(capacity, int): + raise ValueError( + "`capacity` should be of type:: `int` You entered: {0}".format(type(capacity)) + ) + + if not isinstance(target, logging.Handler): + raise ValueError( + "`target` should be of type:: `logging.Handler` You entered: {0}".format( + type(target) + ) + ) + if not isinstance(flushOnClose, bool): + raise ValueError( + "`flushOnClose` should be of type:: `bool` You entered: {0}".format( + type(flushOnClose) + ) + ) From 4f3b2088895a809c5378caa3872f703f91c90d53 Mon Sep 17 00:00:00 2001 From: komuW Date: Thu, 5 Sep 2019 18:26:24 +0300 Subject: [PATCH 02/18] validate args --- examples/example_config.py | 37 +++++++++++++++++++++++++++++++++++++ naz/log.py | 16 ++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/examples/example_config.py b/examples/example_config.py index 38162174..411c0102 100644 --- a/examples/example_config.py +++ b/examples/example_config.py @@ -4,6 +4,41 @@ # run as: # naz-cli --client examples.example_config.client + +import logging + + +class Hook(naz.hooks.BaseHook): + def __init__(self): + self.logger = naz.log.SimpleLogger("MyHook") + + async def request(self, smpp_command, log_id, hook_metadata): + self.logger.log( + logging.INFO, + { + "event": "naz.SimpleHook.request", + "stage": "start", + "smpp_command": smpp_command, + "log_id": log_id, + "hook_metadata": hook_metadata, + }, + ) + + async def response(self, smpp_command, log_id, hook_metadata, smsc_response, raw_pdu): + self.logger.log( + logging.INFO, + { + "event": "naz.SimpleHook.response", + "stage": "start", + "smpp_command": smpp_command, + "log_id": log_id, + "hook_metadata": hook_metadata, + "smsc_response": smsc_response, + "raw_pdu": raw_pdu, + }, + ) + + client = naz.Client( smsc_host="127.0.0.1", smsc_port=2775, @@ -18,4 +53,6 @@ enquire_link_interval=70.00, rateLimiter=MyRateLimiter(), address_range="^254", # any msisdns beginning with 254. See Appendix A of SMPP spec doc + logger=naz.log.SimpleLogger("custom_logger", handler=naz.log.BreachHandler()), + hook=Hook(), ) diff --git a/naz/log.py b/naz/log.py index c7719fe6..9a357a73 100644 --- a/naz/log.py +++ b/naz/log.py @@ -207,6 +207,7 @@ def __init__( capacity: int = 10_000, target: logging.Handler = logging.StreamHandler(), flushOnClose: bool = False, + heartbeatInterval: typing.Union[None, int] = None, ) -> None: """ Parameters: @@ -214,6 +215,7 @@ def __init__( capacity: the maximum number of log records to store in the ring buffer target: the ultimate `log handler `_ that will be used. flushOnClose: whether to flush the buffer when the handler is closed even if the flush level hasn't been exceeded + TODO: add doc for heartbeatInterval """ self._validate_args( flushLevel=flushLevel, capacity=capacity, target=target, flushOnClose=flushOnClose @@ -230,12 +232,26 @@ def __init__( ) # pytype: disable=attribute-error # assuming each log record is 250 bytes, then the maximum # memory used by `buffer` will always be == 250*10_000/(1000*1000) == 2.5MB + self.heartbeatInterval = heartbeatInterval def shouldFlush(self, record: logging.LogRecord) -> bool: """ Check for record at the flushLevel or higher. Implementation is mostly taken from `logging.handlers.MemoryHandler` """ + import pdb + + pdb.set_trace() + if self.heartbeatInterval: + # name, level, pathname, lineno, msg, args, exc_info, func=None, sinfo=None, **kwargs + record = logging.makeLogRecord( + { + "level": logging.INFO, + "name": "BreachHandler", + "msg": "heartbeat sent every {0} minutes".format(self.heartbeatInterval), + } + ) + self.target.emit(record=record) return record.levelno >= self.flushLevel # type: ignore # pytype: disable=attribute-error def _validate_args( From 284e149e9cba09c7a4a1410f74d2f6b71a20cc8c Mon Sep 17 00:00:00 2001 From: komuW Date: Thu, 5 Sep 2019 18:29:29 +0300 Subject: [PATCH 03/18] validate args --- naz/log.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/naz/log.py b/naz/log.py index 9a357a73..e5282f30 100644 --- a/naz/log.py +++ b/naz/log.py @@ -239,20 +239,26 @@ def shouldFlush(self, record: logging.LogRecord) -> bool: Check for record at the flushLevel or higher. Implementation is mostly taken from `logging.handlers.MemoryHandler` """ + self._heartbeat() + return record.levelno >= self.flushLevel # type: ignore # pytype: disable=attribute-error + + def _heartbeat(self): import pdb pdb.set_trace() if self.heartbeatInterval: # name, level, pathname, lineno, msg, args, exc_info, func=None, sinfo=None, **kwargs + # see: https://docs.python.org/3/library/logging.html#logging.LogRecord record = logging.makeLogRecord( { "level": logging.INFO, "name": "BreachHandler", - "msg": "heartbeat sent every {0} minutes".format(self.heartbeatInterval), + "msg": "BreachHandler heartbeat sent every {0} minutes".format( + self.heartbeatInterval + ), } ) self.target.emit(record=record) - return record.levelno >= self.flushLevel # type: ignore # pytype: disable=attribute-error def _validate_args( self, flushLevel: int, capacity: int, target: logging.Handler, flushOnClose: bool From f28635c99c98df7cb8de3febbe5dca0b7f826143 Mon Sep 17 00:00:00 2001 From: komuW Date: Fri, 6 Sep 2019 10:36:26 +0300 Subject: [PATCH 04/18] m --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a78f5beb..d4c4982b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ most recent version is listed first. - rename the `naz.hooks.BaseHook` methods: https://github.com/komuw/naz/pull/159 The new names are more correct and indicate what is actually taking place. - use github actions for CI: https://github.com/komuw/naz/pull/162 +- Add heartbeat to BreachHandler: https://github.com/komuw/naz/pull/161 ## **version:** v0.6.6 From 3ba45845e99e9de68b7186ec2deec810b53b49e4 Mon Sep 17 00:00:00 2001 From: komuW Date: Fri, 6 Sep 2019 10:45:26 +0300 Subject: [PATCH 05/18] g --- naz/log.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/naz/log.py b/naz/log.py index e5282f30..f8643df0 100644 --- a/naz/log.py +++ b/naz/log.py @@ -232,7 +232,8 @@ def __init__( ) # pytype: disable=attribute-error # assuming each log record is 250 bytes, then the maximum # memory used by `buffer` will always be == 250*10_000/(1000*1000) == 2.5MB - self.heartbeatInterval = heartbeatInterval + self.heartbeatInterval = heartbeatInterval * 60 # seconds + self._s_time = time.monotonic() def shouldFlush(self, record: logging.LogRecord) -> bool: """ @@ -243,10 +244,13 @@ def shouldFlush(self, record: logging.LogRecord) -> bool: return record.levelno >= self.flushLevel # type: ignore # pytype: disable=attribute-error def _heartbeat(self): - import pdb + # check if `heartbeatInterval` seconds have passed. + # if they have, emit a heartbeat log record to the target handler - pdb.set_trace() - if self.heartbeatInterval: + _now = time.monotonic() + _diff = _now - self._s_time + if _diff >= self.heartbeatInterval: + self._s_time = _now # name, level, pathname, lineno, msg, args, exc_info, func=None, sinfo=None, **kwargs # see: https://docs.python.org/3/library/logging.html#logging.LogRecord record = logging.makeLogRecord( @@ -261,7 +265,12 @@ def _heartbeat(self): self.target.emit(record=record) def _validate_args( - self, flushLevel: int, capacity: int, target: logging.Handler, flushOnClose: bool + self, + flushLevel: int, + capacity: int, + target: logging.Handler, + flushOnClose: bool, + heartbeatInterval: typing.Union[None, int] = None, ): if not isinstance(flushLevel, int): raise ValueError( @@ -284,3 +293,9 @@ def _validate_args( type(flushOnClose) ) ) + if not isinstance(heartbeatInterval, (type(None), int)): + raise ValueError( + "`heartbeatInterval` should be of type:: `None` or `int` You entered: {0}".format( + type(heartbeatInterval) + ) + ) From 445fd866ab3c2b283e48025475a1d5ebb6b80909 Mon Sep 17 00:00:00 2001 From: komuW Date: Fri, 6 Sep 2019 11:14:03 +0300 Subject: [PATCH 06/18] g --- naz/log.py | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/naz/log.py b/naz/log.py index f8643df0..a7d79cae 100644 --- a/naz/log.py +++ b/naz/log.py @@ -215,10 +215,16 @@ def __init__( capacity: the maximum number of log records to store in the ring buffer target: the ultimate `log handler `_ that will be used. flushOnClose: whether to flush the buffer when the handler is closed even if the flush level hasn't been exceeded - TODO: add doc for heartbeatInterval + heartbeatInterval: can be an integer or None. If it is an integer, then a heartbeat log record will be emitted every :py:attr:`~heartbeatInterval` seconds. + If it is None(the default), then no heartbeat log record is emitted. + If you do decide to set it, a good value is 1800(ie 30 minutes) """ self._validate_args( - flushLevel=flushLevel, capacity=capacity, target=target, flushOnClose=flushOnClose + flushLevel=flushLevel, + capacity=capacity, + target=target, + flushOnClose=flushOnClose, + heartbeatInterval=heartbeatInterval, ) # call `logging.handlers.MemoryHandler` init super(BreachHandler, self).__init__( # type: ignore @@ -232,8 +238,11 @@ def __init__( ) # pytype: disable=attribute-error # assuming each log record is 250 bytes, then the maximum # memory used by `buffer` will always be == 250*10_000/(1000*1000) == 2.5MB - self.heartbeatInterval = heartbeatInterval * 60 # seconds - self._s_time = time.monotonic() + + self.heartbeatInterval = heartbeatInterval + if self.heartbeatInterval: + self.heartbeatInterval = heartbeatInterval # seconds + self._s_time = time.monotonic() def shouldFlush(self, record: logging.LogRecord) -> bool: """ @@ -244,9 +253,13 @@ def shouldFlush(self, record: logging.LogRecord) -> bool: return record.levelno >= self.flushLevel # type: ignore # pytype: disable=attribute-error def _heartbeat(self): + if not self.heartbeatInterval: + return + import pdb + + pdb.set_trace() # check if `heartbeatInterval` seconds have passed. # if they have, emit a heartbeat log record to the target handler - _now = time.monotonic() _diff = _now - self._s_time if _diff >= self.heartbeatInterval: @@ -257,9 +270,11 @@ def _heartbeat(self): { "level": logging.INFO, "name": "BreachHandler", - "msg": "BreachHandler heartbeat sent every {0} minutes".format( - self.heartbeatInterval - ), + "pathname": "naz.log.BreachHandler", + "msg": { + "event": "naz.BreachHandler.heartbeat", + "heartbeatInterval": self.heartbeatInterval, + }, } ) self.target.emit(record=record) @@ -270,7 +285,7 @@ def _validate_args( capacity: int, target: logging.Handler, flushOnClose: bool, - heartbeatInterval: typing.Union[None, int] = None, + heartbeatInterval: typing.Union[None, int], ): if not isinstance(flushLevel, int): raise ValueError( From d3d48281fd51e8cb1f341cbdc56c83207371ac2a Mon Sep 17 00:00:00 2001 From: komuW Date: Fri, 6 Sep 2019 11:16:58 +0300 Subject: [PATCH 07/18] g --- naz/log.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/naz/log.py b/naz/log.py index a7d79cae..f6f55711 100644 --- a/naz/log.py +++ b/naz/log.py @@ -207,7 +207,7 @@ def __init__( capacity: int = 10_000, target: logging.Handler = logging.StreamHandler(), flushOnClose: bool = False, - heartbeatInterval: typing.Union[None, int] = None, + heartbeatInterval: typing.Union[None, float] = None, ) -> None: """ Parameters: @@ -215,9 +215,9 @@ def __init__( capacity: the maximum number of log records to store in the ring buffer target: the ultimate `log handler `_ that will be used. flushOnClose: whether to flush the buffer when the handler is closed even if the flush level hasn't been exceeded - heartbeatInterval: can be an integer or None. If it is an integer, then a heartbeat log record will be emitted every :py:attr:`~heartbeatInterval` seconds. + heartbeatInterval: can be an float or None. If it is an float, then a heartbeat log record will be emitted every :py:attr:`~heartbeatInterval` seconds. If it is None(the default), then no heartbeat log record is emitted. - If you do decide to set it, a good value is 1800(ie 30 minutes) + If you do decide to set it, a good value is 1800(ie 30 minutes) or more. """ self._validate_args( flushLevel=flushLevel, @@ -255,9 +255,7 @@ def shouldFlush(self, record: logging.LogRecord) -> bool: def _heartbeat(self): if not self.heartbeatInterval: return - import pdb - pdb.set_trace() # check if `heartbeatInterval` seconds have passed. # if they have, emit a heartbeat log record to the target handler _now = time.monotonic() @@ -285,7 +283,7 @@ def _validate_args( capacity: int, target: logging.Handler, flushOnClose: bool, - heartbeatInterval: typing.Union[None, int], + heartbeatInterval: typing.Union[None, float], ): if not isinstance(flushLevel, int): raise ValueError( @@ -308,9 +306,9 @@ def _validate_args( type(flushOnClose) ) ) - if not isinstance(heartbeatInterval, (type(None), int)): + if not isinstance(heartbeatInterval, (type(None), float)): raise ValueError( - "`heartbeatInterval` should be of type:: `None` or `int` You entered: {0}".format( + "`heartbeatInterval` should be of type:: `None` or `float` You entered: {0}".format( type(heartbeatInterval) ) ) From d1b8dee1fb0ccf9e619e1d96f0929c48a0b8280f Mon Sep 17 00:00:00 2001 From: komuW Date: Fri, 6 Sep 2019 11:27:19 +0300 Subject: [PATCH 08/18] g --- tests/test_logger.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/tests/test_logger.py b/tests/test_logger.py index 425f5f8c..0751ecc2 100644 --- a/tests/test_logger.py +++ b/tests/test_logger.py @@ -129,7 +129,7 @@ def test_use_with_naz_logger(self): _handler = naz.log.BreachHandler( capacity=4, target=logging.StreamHandler(stream=_temp_stream) ) - logger = naz.log.SimpleLogger("aha", handler=_handler) + logger = naz.log.SimpleLogger("test_use_with_naz_logger", handler=_handler) logger.bind(level="INFO", log_metadata={"name": "JayZ"}) # log at level less than `_handler.trigger_level` @@ -179,3 +179,28 @@ def test_use_with_stdlib_logger(self): self.assertNotIn("one", _temp_stream.getvalue()) self.assertIn("Dr. Missy Elliot", _temp_stream.getvalue()) self.assertIn("damn!", _temp_stream.getvalue()) + + # def test_heartbeat(self): + # # with io.StringIO() as _temp_stream: + # # heartbeatInterval = 1.0 + # # _handler = naz.log.BreachHandler( + # # capacity=4, + # # target=logging.StreamHandler(stream=_temp_stream), + # # # heartbeatInterval=heartbeatInterval, + # # ) + # # logger = naz.log.SimpleLogger("test_heartbeat", handler=_handler) + # # logger.bind(level="INFO", log_metadata={"name": "JayZ"}) + + # with io.StringIO() as _temp_stream: + # _handler = naz.log.BreachHandler( + # capacity=4, target=logging.StreamHandler(stream=_temp_stream) + # ) + # logger = naz.log.SimpleLogger("test_use_with_naz_logger", handler=_handler) + # logger.bind(level="INFO", log_metadata={"name": "JayZ"}) + + # # log at level less than `_handler.trigger_level` + # logger.log(level=logging.INFO, log_data={"trace_id": 781125213295, "one": 1}) + + # # log at level less than `_handler.trigger_level` + # logger.log(level=logging.INFO, log_data={"trace_id": 781125213295, "one": 1}) + # self.assertIn("", _temp_stream.getvalue()) # nothing is logged From b5a81a36ba15a4e8e8530b1f6fa7626ad135b3fb Mon Sep 17 00:00:00 2001 From: komuW Date: Fri, 6 Sep 2019 11:46:50 +0300 Subject: [PATCH 09/18] g --- tests/test_logger.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/tests/test_logger.py b/tests/test_logger.py index 0751ecc2..6f4d33c5 100644 --- a/tests/test_logger.py +++ b/tests/test_logger.py @@ -139,7 +139,7 @@ def test_use_with_naz_logger(self): logger.log(level=logging.INFO, log_data={"trace_id": 781125213295, "four": 4}) logger.log(level=logging.INFO, log_data={"trace_id": 781125213295, "five": 5}) logger.log(level=logging.INFO, log_data={"trace_id": 781125213295, "six": 6}) - self.assertIn("", _temp_stream.getvalue()) # nothing is logged + self.assertEqual("", _temp_stream.getvalue()) # nothing is logged # log at level greater than or equal to `_handler.trigger_level` logger.log(level=logging.WARN, log_data={"trace_id": 781125213295, "seven": 7}) @@ -182,14 +182,22 @@ def test_use_with_stdlib_logger(self): # def test_heartbeat(self): # # with io.StringIO() as _temp_stream: - # # heartbeatInterval = 1.0 - # # _handler = naz.log.BreachHandler( - # # capacity=4, - # # target=logging.StreamHandler(stream=_temp_stream), - # # # heartbeatInterval=heartbeatInterval, - # # ) - # # logger = naz.log.SimpleLogger("test_heartbeat", handler=_handler) - # # logger.bind(level="INFO", log_metadata={"name": "JayZ"}) + # _temp_stream = io.StringIO() + # heartbeatInterval = 0.0001 + + # _handler = naz.log.BreachHandler( + # capacity=4, + # target=logging.StreamHandler(stream=_temp_stream), + # heartbeatInterval=heartbeatInterval, + # ) + # logger = naz.log.SimpleLogger("test_heartbeat", handler=_handler) + # logger.bind(level="INFO", log_metadata={"artist": "Missy"}) + # self.assertEqual("", _temp_stream.getvalue()) + # logger.log(level=logging.INFO, log_data={"song_id": 1234, "name": "The Rain"}) + # import pdb + + # pdb.set_trace() + # self.assertIn("", _temp_stream.getvalue()) # with io.StringIO() as _temp_stream: # _handler = naz.log.BreachHandler( From 71739b25bd48c9792ffae2b5a8837850cec8f2d8 Mon Sep 17 00:00:00 2001 From: komuW Date: Fri, 6 Sep 2019 12:07:33 +0300 Subject: [PATCH 10/18] g --- naz/log.py | 6 +- tests/test_logger.py | 173 ++++++++++++++++++++++--------------------- 2 files changed, 94 insertions(+), 85 deletions(-) diff --git a/naz/log.py b/naz/log.py index f6f55711..ce583cef 100644 --- a/naz/log.py +++ b/naz/log.py @@ -244,6 +244,8 @@ def __init__( self.heartbeatInterval = heartbeatInterval # seconds self._s_time = time.monotonic() + self.target.setLevel(logging.DEBUG) + def shouldFlush(self, record: logging.LogRecord) -> bool: """ Check for record at the flushLevel or higher. @@ -268,13 +270,15 @@ def _heartbeat(self): { "level": logging.INFO, "name": "BreachHandler", - "pathname": "naz.log.BreachHandler", + "pathname": ".../naz/naz/log.py", + "func": "BreachHandler._heartbeat", "msg": { "event": "naz.BreachHandler.heartbeat", "heartbeatInterval": self.heartbeatInterval, }, } ) + self.target.emit(record=record) def _validate_args( diff --git a/tests/test_logger.py b/tests/test_logger.py index 6f4d33c5..37db4f95 100644 --- a/tests/test_logger.py +++ b/tests/test_logger.py @@ -124,91 +124,96 @@ class TestBreachHandler(TestCase): python -m unittest -v tests.test_logger.TestBreachHandler.test_something """ + def setUp(self): + self._temp_stream = io.StringIO() + + def tearDown(self): + # self._temp_stream.close() + self._temp_stream = None + def test_use_with_naz_logger(self): - with io.StringIO() as _temp_stream: - _handler = naz.log.BreachHandler( - capacity=4, target=logging.StreamHandler(stream=_temp_stream) - ) - logger = naz.log.SimpleLogger("test_use_with_naz_logger", handler=_handler) - logger.bind(level="INFO", log_metadata={"name": "JayZ"}) + _handler = naz.log.BreachHandler( + capacity=4, target=logging.StreamHandler(stream=self._temp_stream) + ) + logger = naz.log.SimpleLogger("test_use_with_naz_logger", handler=_handler) + logger.bind(level="INFO", log_metadata={"name": "JayZ"}) - # log at level less than `_handler.trigger_level` - logger.log(level=logging.INFO, log_data={"trace_id": 781125213295, "one": 1}) - logger.log(level=logging.INFO, log_data={"trace_id": 781125213295, "two": 2}) - logger.log(level=logging.INFO, log_data={"trace_id": 781125213295, "three": 3}) - logger.log(level=logging.INFO, log_data={"trace_id": 781125213295, "four": 4}) - logger.log(level=logging.INFO, log_data={"trace_id": 781125213295, "five": 5}) - logger.log(level=logging.INFO, log_data={"trace_id": 781125213295, "six": 6}) - self.assertEqual("", _temp_stream.getvalue()) # nothing is logged - - # log at level greater than or equal to `_handler.trigger_level` - logger.log(level=logging.WARN, log_data={"trace_id": 781125213295, "seven": 7}) - - # assert that the handler used a circular buffer - self.assertNotIn("one", _temp_stream.getvalue()) - self.assertNotIn("two", _temp_stream.getvalue()) - self.assertNotIn("three", _temp_stream.getvalue()) - - # assert everything in the buffer after trigger level is reached - # is flushed to `_handler.stream` - self.assertIn("five", _temp_stream.getvalue()) - self.assertIn("six", _temp_stream.getvalue()) - self.assertIn("seven", _temp_stream.getvalue()) - self.assertIn(str(781125213295), _temp_stream.getvalue()) + # log at level less than `_handler.trigger_level` + logger.log(level=logging.INFO, log_data={"trace_id": 781125213295, "one": 1}) + logger.log(level=logging.INFO, log_data={"trace_id": 781125213295, "two": 2}) + logger.log(level=logging.INFO, log_data={"trace_id": 781125213295, "three": 3}) + logger.log(level=logging.INFO, log_data={"trace_id": 781125213295, "four": 4}) + logger.log(level=logging.INFO, log_data={"trace_id": 781125213295, "five": 5}) + logger.log(level=logging.INFO, log_data={"trace_id": 781125213295, "six": 6}) + self.assertEqual("", self._temp_stream.getvalue()) # nothing is logged + + # log at level greater than or equal to `_handler.trigger_level` + logger.log(level=logging.WARN, log_data={"trace_id": 781125213295, "seven": 7}) + + # assert that the handler used a circular buffer + self.assertNotIn("one", self._temp_stream.getvalue()) + self.assertNotIn("two", self._temp_stream.getvalue()) + self.assertNotIn("three", self._temp_stream.getvalue()) + + # assert everything in the buffer after trigger level is reached + # is flushed to `_handler.stream` + self.assertIn("five", self._temp_stream.getvalue()) + self.assertIn("six", self._temp_stream.getvalue()) + self.assertIn("seven", self._temp_stream.getvalue()) + self.assertIn(str(781125213295), self._temp_stream.getvalue()) def test_use_with_stdlib_logger(self): - with io.StringIO() as _temp_stream: - handler = naz.log.BreachHandler( - capacity=3, target=logging.StreamHandler(stream=_temp_stream) - ) - - logger = logging.getLogger("my-logger") - formatter = logging.Formatter("%(message)s") - handler.setFormatter(formatter) - handler.setLevel("DEBUG") - if not logger.handlers: - logger.addHandler(handler) - logger.setLevel("DEBUG") - - logger.info("one") - logger.info("two") - logger.info("three") - logger.info("I did records for Tweet before y'all could even tweet - Dr. Missy Elliot") - logger.error("damn!") - - self.assertNotIn("one", _temp_stream.getvalue()) - self.assertIn("Dr. Missy Elliot", _temp_stream.getvalue()) - self.assertIn("damn!", _temp_stream.getvalue()) - - # def test_heartbeat(self): - # # with io.StringIO() as _temp_stream: - # _temp_stream = io.StringIO() - # heartbeatInterval = 0.0001 - - # _handler = naz.log.BreachHandler( - # capacity=4, - # target=logging.StreamHandler(stream=_temp_stream), - # heartbeatInterval=heartbeatInterval, - # ) - # logger = naz.log.SimpleLogger("test_heartbeat", handler=_handler) - # logger.bind(level="INFO", log_metadata={"artist": "Missy"}) - # self.assertEqual("", _temp_stream.getvalue()) - # logger.log(level=logging.INFO, log_data={"song_id": 1234, "name": "The Rain"}) - # import pdb - - # pdb.set_trace() - # self.assertIn("", _temp_stream.getvalue()) - - # with io.StringIO() as _temp_stream: - # _handler = naz.log.BreachHandler( - # capacity=4, target=logging.StreamHandler(stream=_temp_stream) - # ) - # logger = naz.log.SimpleLogger("test_use_with_naz_logger", handler=_handler) - # logger.bind(level="INFO", log_metadata={"name": "JayZ"}) - - # # log at level less than `_handler.trigger_level` - # logger.log(level=logging.INFO, log_data={"trace_id": 781125213295, "one": 1}) - - # # log at level less than `_handler.trigger_level` - # logger.log(level=logging.INFO, log_data={"trace_id": 781125213295, "one": 1}) - # self.assertIn("", _temp_stream.getvalue()) # nothing is logged + handler = naz.log.BreachHandler( + capacity=3, target=logging.StreamHandler(stream=self._temp_stream) + ) + + logger = logging.getLogger("my-logger") + formatter = logging.Formatter("%(message)s") + handler.setFormatter(formatter) + handler.setLevel("DEBUG") + if not logger.handlers: + logger.addHandler(handler) + logger.setLevel("DEBUG") + + logger.info("one") + logger.info("two") + logger.info("three") + logger.info("I did records for Tweet before y'all could even tweet - Dr. Missy Elliot") + logger.error("damn!") + + self.assertNotIn("one", self._temp_stream.getvalue()) + self.assertIn("Dr. Missy Elliot", self._temp_stream.getvalue()) + self.assertIn("damn!", self._temp_stream.getvalue()) + + def test_heartbeat_NOT_exceeded(self): + # if heartbeatInterval has NOT been exceeded, we do not log a heartbeat record + heartbeatInterval = 20.0 * 60 # 20minutes + _handler = naz.log.BreachHandler( + capacity=4, + target=logging.StreamHandler(stream=self._temp_stream), + heartbeatInterval=heartbeatInterval, + ) + logger = naz.log.SimpleLogger("test_heartbeat_NOT_exceeded", handler=_handler) + logger.bind(level="INFO", log_metadata={"artist": "Missy"}) + self.assertEqual("", self._temp_stream.getvalue()) + + logger.log(level=logging.INFO, log_data={"song_id": 1234, "name": "The Rain"}) + self.assertNotIn("naz.BreachHandler.heartbeat", self._temp_stream.getvalue()) + self.assertNotIn(str(heartbeatInterval), self._temp_stream.getvalue()) + self.assertEqual("", self._temp_stream.getvalue()) + + def test_heartbeat_exceeded(self): + # if heartbeatInterval IS exceeded, we log a heartbeat record + heartbeatInterval = 0.000000000001 # seconds + _handler = naz.log.BreachHandler( + capacity=4, + target=logging.StreamHandler(stream=self._temp_stream), + heartbeatInterval=heartbeatInterval, + ) + logger = naz.log.SimpleLogger("test_heartbeat_exceeded", handler=_handler) + logger.bind(level="INFO", log_metadata={"artist": "Lauryn"}) + self.assertEqual("", self._temp_stream.getvalue()) + + logger.log(level=logging.INFO, log_data={"song_id": 543, "name": "Zion"}) + self.assertIn("naz.BreachHandler.heartbeat", self._temp_stream.getvalue()) + self.assertIn(str(heartbeatInterval), self._temp_stream.getvalue()) From a4e544f00f193a9601b4fbf0971457a73f9a061d Mon Sep 17 00:00:00 2001 From: komuW Date: Fri, 6 Sep 2019 12:12:46 +0300 Subject: [PATCH 11/18] g --- examples/example_config.py | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/examples/example_config.py b/examples/example_config.py index 411c0102..38162174 100644 --- a/examples/example_config.py +++ b/examples/example_config.py @@ -4,41 +4,6 @@ # run as: # naz-cli --client examples.example_config.client - -import logging - - -class Hook(naz.hooks.BaseHook): - def __init__(self): - self.logger = naz.log.SimpleLogger("MyHook") - - async def request(self, smpp_command, log_id, hook_metadata): - self.logger.log( - logging.INFO, - { - "event": "naz.SimpleHook.request", - "stage": "start", - "smpp_command": smpp_command, - "log_id": log_id, - "hook_metadata": hook_metadata, - }, - ) - - async def response(self, smpp_command, log_id, hook_metadata, smsc_response, raw_pdu): - self.logger.log( - logging.INFO, - { - "event": "naz.SimpleHook.response", - "stage": "start", - "smpp_command": smpp_command, - "log_id": log_id, - "hook_metadata": hook_metadata, - "smsc_response": smsc_response, - "raw_pdu": raw_pdu, - }, - ) - - client = naz.Client( smsc_host="127.0.0.1", smsc_port=2775, @@ -53,6 +18,4 @@ async def response(self, smpp_command, log_id, hook_metadata, smsc_response, raw enquire_link_interval=70.00, rateLimiter=MyRateLimiter(), address_range="^254", # any msisdns beginning with 254. See Appendix A of SMPP spec doc - logger=naz.log.SimpleLogger("custom_logger", handler=naz.log.BreachHandler()), - hook=Hook(), ) From af313fee53f237f4e936083bea0a120ce613bad1 Mon Sep 17 00:00:00 2001 From: komuW Date: Fri, 6 Sep 2019 12:13:48 +0300 Subject: [PATCH 12/18] g --- docs/_modules/naz/log.html | 86 +++++++++++++++++++++++++++++++++++++- docs/log.html | 7 +++- docs/searchindex.js | 2 +- 3 files changed, 90 insertions(+), 5 deletions(-) diff --git a/docs/_modules/naz/log.html b/docs/_modules/naz/log.html index a0135c81..7557c994 100644 --- a/docs/_modules/naz/log.html +++ b/docs/_modules/naz/log.html @@ -371,6 +371,7 @@

Source code for naz.log

         capacity: int = 10_000,
         target: logging.Handler = logging.StreamHandler(),
         flushOnClose: bool = False,
+        heartbeatInterval: typing.Union[None, float] = None,
     ) -> None:
         """
         Parameters:
@@ -378,7 +379,17 @@ 

Source code for naz.log

             capacity: the maximum number of log records to store in the ring buffer
             target: the ultimate `log handler <https://docs.python.org/3.6/library/logging.html#logging.Handler>`_ that will be used.
             flushOnClose: whether to flush the buffer when the handler is closed even if the flush level hasn't been exceeded
+            heartbeatInterval: can be an float or None. If it is an float, then a heartbeat log record will be emitted every :py:attr:`~heartbeatInterval` seconds.
+                               If it is None(the default), then no heartbeat log record is emitted.
+                               If you do decide to set it, a good value is 1800(ie 30 minutes) or more.
         """
+        self._validate_args(
+            flushLevel=flushLevel,
+            capacity=capacity,
+            target=target,
+            flushOnClose=flushOnClose,
+            heartbeatInterval=heartbeatInterval,
+        )
         # call `logging.handlers.MemoryHandler` init
         super(BreachHandler, self).__init__(  # type: ignore
             capacity=capacity,
@@ -388,16 +399,87 @@ 

Source code for naz.log

         )
         self.buffer: collections.deque = collections.deque(
             maxlen=self.capacity  # type: ignore
-        )  # pytype: disable=attribute-error
+ ) # pytype: disable=attribute-error # assuming each log record is 250 bytes, then the maximum # memory used by `buffer` will always be == 250*10_000/(1000*1000) == 2.5MB + self.heartbeatInterval = heartbeatInterval + if self.heartbeatInterval: + self.heartbeatInterval = heartbeatInterval # seconds + self._s_time = time.monotonic() + + self.target.setLevel(logging.DEBUG)
+
[docs] def shouldFlush(self, record: logging.LogRecord) -> bool: """ Check for record at the flushLevel or higher. Implementation is mostly taken from `logging.handlers.MemoryHandler` """ - return record.levelno >= self.flushLevel # type: ignore # pytype: disable=attribute-error
+ self._heartbeat() + return record.levelno >= self.flushLevel # type: ignore # pytype: disable=attribute-error + + def _heartbeat(self): + if not self.heartbeatInterval: + return + + # check if `heartbeatInterval` seconds have passed. + # if they have, emit a heartbeat log record to the target handler + _now = time.monotonic() + _diff = _now - self._s_time + if _diff >= self.heartbeatInterval: + self._s_time = _now + # name, level, pathname, lineno, msg, args, exc_info, func=None, sinfo=None, **kwargs + # see: https://docs.python.org/3/library/logging.html#logging.LogRecord + record = logging.makeLogRecord( + { + "level": logging.INFO, + "name": "BreachHandler", + "pathname": ".../naz/naz/log.py", + "func": "BreachHandler._heartbeat", + "msg": { + "event": "naz.BreachHandler.heartbeat", + "heartbeatInterval": self.heartbeatInterval, + }, + } + ) + + self.target.emit(record=record) + + def _validate_args( + self, + flushLevel: int, + capacity: int, + target: logging.Handler, + flushOnClose: bool, + heartbeatInterval: typing.Union[None, float], + ): + if not isinstance(flushLevel, int): + raise ValueError( + "`flushLevel` should be of type:: `int` You entered: {0}".format(type(flushLevel)) + ) + if not isinstance(capacity, int): + raise ValueError( + "`capacity` should be of type:: `int` You entered: {0}".format(type(capacity)) + ) + + if not isinstance(target, logging.Handler): + raise ValueError( + "`target` should be of type:: `logging.Handler` You entered: {0}".format( + type(target) + ) + ) + if not isinstance(flushOnClose, bool): + raise ValueError( + "`flushOnClose` should be of type:: `bool` You entered: {0}".format( + type(flushOnClose) + ) + ) + if not isinstance(heartbeatInterval, (type(None), float)): + raise ValueError( + "`heartbeatInterval` should be of type:: `None` or `float` You entered: {0}".format( + type(heartbeatInterval) + ) + ) diff --git a/docs/log.html b/docs/log.html index dcc1959f..64af835e 100644 --- a/docs/log.html +++ b/docs/log.html @@ -280,7 +280,7 @@
-class naz.log.BreachHandler(flushLevel=30, capacity=10000, target=<StreamHandler <stderr> (NOTSET)>, flushOnClose=False)[source]
+class naz.log.BreachHandler(flushLevel=30, capacity=10000, target=<StreamHandler <stderr> (NOTSET)>, flushOnClose=False, heartbeatInterval=None)[source]

Bases: logging.handlers.MemoryHandler

This is an implementation of logging.Handler that puts logs in an in-memory ring buffer. When a trigger condition(eg a certain log level) is met; @@ -316,7 +316,7 @@

-__init__(flushLevel=30, capacity=10000, target=<StreamHandler <stderr> (NOTSET)>, flushOnClose=False)[source]
+__init__(flushLevel=30, capacity=10000, target=<StreamHandler <stderr> (NOTSET)>, flushOnClose=False, heartbeatInterval=None)[source]
Parameters
    @@ -324,6 +324,9 @@
  • capacity (int) – the maximum number of log records to store in the ring buffer

  • target (Handler) – the ultimate log handler that will be used.

  • flushOnClose (bool) – whether to flush the buffer when the handler is closed even if the flush level hasn’t been exceeded

  • +
  • heartbeatInterval (Union[None, float]) – can be an float or None. If it is an float, then a heartbeat log record will be emitted every heartbeatInterval seconds. +If it is None(the default), then no heartbeat log record is emitted. +If you do decide to set it, a good value is 1800(ie 30 minutes) or more.

Return type
diff --git a/docs/searchindex.js b/docs/searchindex.js index 17f2a209..f39d3d76 100644 --- a/docs/searchindex.js +++ b/docs/searchindex.js @@ -1 +1 @@ -Search.setIndex({docnames:["client","correlater","example_demo","hooks","index","introduction","log","nazcodec","queue","ratelimiter","sequence","state","throttle"],envversion:{"sphinx.domains.c":1,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":1,"sphinx.domains.javascript":1,"sphinx.domains.math":2,"sphinx.domains.python":1,"sphinx.domains.rst":1,"sphinx.domains.std":1,"sphinx.ext.todo":2,"sphinx.ext.viewcode":1,sphinx:56},filenames:["client.rst","correlater.rst","example_demo.rst","hooks.rst","index.rst","introduction.rst","log.rst","nazcodec.rst","queue.rst","ratelimiter.rst","sequence.rst","state.rst","throttle.rst"],objects:{"naz.client":{Client:[0,1,1,""],NazClientError:[0,3,1,""]},"naz.client.Client":{__init__:[0,2,1,""],command_handlers:[0,2,1,""],connect:[0,2,1,""],deliver_sm_resp:[0,2,1,""],dequeue_messages:[0,2,1,""],enquire_link:[0,2,1,""],enquire_link_resp:[0,2,1,""],re_establish_conn_bind:[0,2,1,""],receive_data:[0,2,1,""],send_data:[0,2,1,""],shutdown:[0,2,1,""],submit_sm:[0,2,1,""],tranceiver_bind:[0,2,1,""],unbind:[0,2,1,""],unbind_resp:[0,2,1,""]},"naz.correlater":{BaseCorrelater:[1,1,1,""],SimpleCorrelater:[1,1,1,""]},"naz.correlater.BaseCorrelater":{get:[1,2,1,""],put:[1,2,1,""]},"naz.correlater.SimpleCorrelater":{__init__:[1,2,1,""],delete_after_ttl:[1,2,1,""],get:[1,2,1,""],put:[1,2,1,""]},"naz.hooks":{BaseHook:[3,1,1,""],SimpleHook:[3,1,1,""]},"naz.hooks.BaseHook":{from_smsc:[3,2,1,""],to_smsc:[3,2,1,""]},"naz.hooks.SimpleHook":{__init__:[3,2,1,""],from_smsc:[3,2,1,""],to_smsc:[3,2,1,""]},"naz.log":{BaseLogger:[6,1,1,""],BreachHandler:[6,1,1,""],SimpleLogger:[6,1,1,""]},"naz.log.BaseLogger":{bind:[6,2,1,""],log:[6,2,1,""]},"naz.log.BreachHandler":{__init__:[6,2,1,""],shouldFlush:[6,2,1,""]},"naz.log.SimpleLogger":{__init__:[6,2,1,""],bind:[6,2,1,""],log:[6,2,1,""]},"naz.nazcodec":{BaseNazCodec:[7,1,1,""],SimpleNazCodec:[7,1,1,""]},"naz.nazcodec.BaseNazCodec":{decode:[7,2,1,""],encode:[7,2,1,""]},"naz.nazcodec.SimpleNazCodec":{decode:[7,2,1,""],encode:[7,2,1,""]},"naz.q":{BaseOutboundQueue:[8,1,1,""],SimpleOutboundQueue:[8,1,1,""]},"naz.q.BaseOutboundQueue":{dequeue:[8,2,1,""],enqueue:[8,2,1,""]},"naz.q.SimpleOutboundQueue":{__init__:[8,2,1,""],dequeue:[8,2,1,""],enqueue:[8,2,1,""]},"naz.ratelimiter":{BaseRateLimiter:[9,1,1,""],SimpleRateLimiter:[9,1,1,""]},"naz.ratelimiter.BaseRateLimiter":{limit:[9,2,1,""]},"naz.ratelimiter.SimpleRateLimiter":{__init__:[9,2,1,""],limit:[9,2,1,""]},"naz.sequence":{BaseSequenceGenerator:[10,1,1,""],SimpleSequenceGenerator:[10,1,1,""]},"naz.sequence.BaseSequenceGenerator":{next_sequence:[10,2,1,""]},"naz.sequence.SimpleSequenceGenerator":{__init__:[10,2,1,""],next_sequence:[10,2,1,""]},"naz.state":{CommandStatus:[11,1,1,""],DataCoding:[11,1,1,""],SmppCommand:[11,1,1,""],SmppCommandStatus:[11,1,1,""],SmppDataCoding:[11,1,1,""],SmppOptionalTag:[11,1,1,""],SmppSessionState:[11,1,1,""]},"naz.state.CommandStatus":{code:[11,2,1,""],description:[11,2,1,""],value:[11,2,1,""]},"naz.state.DataCoding":{code:[11,2,1,""],description:[11,2,1,""],value:[11,2,1,""]},"naz.throttle":{BaseThrottleHandler:[12,1,1,""],SimpleThrottleHandler:[12,1,1,""]},"naz.throttle.BaseThrottleHandler":{allow_request:[12,2,1,""],not_throttled:[12,2,1,""],throttle_delay:[12,2,1,""],throttled:[12,2,1,""]},"naz.throttle.SimpleThrottleHandler":{__init__:[12,2,1,""],allow_request:[12,2,1,""],not_throttled:[12,2,1,""],throttle_delay:[12,2,1,""],throttled:[12,2,1,""]},naz:{client:[0,0,0,"-"],correlater:[1,0,0,"-"],hooks:[3,0,0,"-"],log:[6,0,0,"-"],nazcodec:[7,0,0,"-"],q:[8,0,0,"-"],ratelimiter:[9,0,0,"-"],sequence:[10,0,0,"-"],state:[11,0,0,"-"],throttle:[12,0,0,"-"]}},objnames:{"0":["py","module","Python module"],"1":["py","class","Python class"],"2":["py","method","Python method"],"3":["py","exception","Python exception"]},objtypes:{"0":"py:module","1":"py:class","2":"py:method","3":"py:exception"},terms:{"0r5nd6bsd3g4atwux":2,"16be":7,"20min":5,"2billion":1,"7wjf935mqgsjplq7e":2,"\u03c3cmt":2,"\u30c4":5,"abstract":[1,3,6,7,8,9,10,12],"byte":[0,3,7],"class":[0,1,2,3,5,6,7,8,9,10,11,12],"default":5,"final":5,"float":[0,1,9,12],"function":0,"h\u00fclk":7,"import":[0,2,5,6,9,12],"int":[0,1,6,8,10],"long":[2,5,12],"return":[0,1,2,3,5,6,7,8,9,10,12],"short":[0,5],"true":2,"try":5,"while":[0,2],"zo\u00e3":7,"zo\u00eb":7,AND:12,AWS:2,And:[2,5],But:2,For:[2,5],One:1,REs:5,SMS:0,SQS:2,That:[0,5],The:[0,1,2,5,6,8,10,12],With:2,__init__:[0,1,2,3,5,6,8,9,10,12],_get_redi:2,_handler:6,_redi:2,abc:[1,3,6,7,8,9,10,12],abil:5,abl:2,about:5,abov:[5,12],accept:2,acct:0,accur:[3,10],acknowledg:0,activ:[0,5],addhandl:[5,6],addit:0,addr_npi:0,addr_ton:0,address:[0,2],address_rang:0,after:[0,1,3,5,12],again:12,agnost:2,aha:6,aioredi:2,algorithm:[5,9],alia:11,all:[0,1,2,5,6],allow:[5,9,10],allow_request:12,alpin:2,also:[0,1,2,5,7,12],altern:6,among:1,ani:[0,1,2,3,5,6,8,12],annot:5,anoth:[1,2,5],anymor:12,anyth:5,api:5,app:[2,4],applic:[0,1,2,3,5],argument:[0,2],around:[1,10],arrang:0,articl:6,artist:5,associ:0,async:[0,1,2,3,8,9,12],asynchron:0,asyncio:[0,2,5],authent:0,auto:1,avail:2,await:[2,5,9],awesom:2,awesomestor:2,b526gdnxfbf8sqlzz:2,backward:5,band:5,base:[0,1,3,6,7,8,9,10,11,12],basecorrelat:[0,1],basehook:[0,3,5],baselogg:[0,5,6],basenazcodec:[0,7],baseoutboundqueu:[0,2,5,8],baseratelimit:[0,5,9],basesequencegener:[0,10],basethrottlehandl:[0,5,12],basi:1,been:[0,2,6],befor:[0,2,3,5,6,12],benchmark:4,best:1,between:[0,1,5],bind:[0,5,6],bind_receiv:0,bind_transceiv:0,bit:[6,7],block:0,bodi:0,body_data:0,bool:[0,6,12],both:2,breachhandl:6,bring:5,broker:2,brpop:2,bucket:[5,9],buffer:[0,6],buffer_s:[],bug:4,busi:2,byte_str:7,calcul:12,call:[0,1,2,3,5,6,7,8,12],can:[0,2,5,6,7,8,9,11],canari:5,capac:6,center:5,certain:6,chang:[2,5],charact:7,check:[0,5,6],choic:[2,5],choos:6,cleanli:0,cli:[2,4],client:[2,5,6,9,12],client_id:[0,2,5],close:[5,6],cmt:0,code:[0,2,11],codec:7,codec_class:0,codec_errors_level:0,com:6,come:1,command:[1,2,3,11],command_handl:[0,2],command_statu:2,command_status_valu:0,commandlin:5,commandstatu:[3,11],commit:5,commun:2,compos:5,condit:[6,12],config:5,confirm:2,conn:5,connect:[0,2,5],connection_lost:2,consult:[2,5],consum:5,contain:[2,5],content:5,continu:[0,5],control:[0,5,9],correl:[1,3,10],correlat:4,correlatinid:5,correlation_handl:0,could:6,counter:5,creat:[2,5],create_redis_pool:2,cthank:2,current:[2,5],cursor:5,custom:[2,5,9],customer_id:6,damn:6,data:[0,3,5,11],databas:5,datacod:11,debug:[5,6],decid:[5,12],decis:12,declar:0,decod:[0,2,7],def:[2,5],defin:[0,7],delet:1,delete_after_ttl:1,deliv:5,deliver_sm:[1,5],deliver_sm_resp:0,deliveri:[0,1,5],demo:[4,5,8],demo_naz:2,deni:[5,12],deny_request_at:[5,12],depend:5,dequed_item:2,dequeu:[0,2,5,8],dequeue_messag:[0,2,5],deriv:5,descript:[5,11],design:[0,5],dest_addr_npi:0,dest_addr_ton:0,destin:0,destination_addr:[0,2,5],determin:12,develop:[2,5,6],diagnost:6,dict:[0,6,8],dictionari:[1,5],did:6,differ:[0,1,3],directori:[2,5],doc:5,docker:[2,5],document:[2,5],doe:[0,5,6,9,12],domain:0,done:[1,2],dot:2,down:0,drain_dur:0,dry:2,dump:2,durat:[0,12],each:5,effort:1,elliot:6,els:2,emit:[],emoji:5,empti:2,enabl:[6,12],encod:[0,7,11],encoding1:0,end:2,enqueu:[0,2,5,8],enquire_link:[0,5],enquire_link_interv:0,enquire_link_resp:0,entiti:5,environ:5,error:[0,5,6,7],esm:[0,5],esm_class:0,esme_rmsgq:12,esme_rthrottl:5,etc:[2,6,7],even:[5,6],event:[2,5,6],everytim:[6,12],everywher:4,exampl:[0,4,5,6,7,9],example_config:5,examplequeu:5,exce:12,exceed:6,except:[0,5,6],execut:[2,5],exist:0,exit:2,expect:2,expir:1,extern:5,fals:[0,2,6,12],featur:[1,4],field:[0,11],file:[2,5,6],flag:0,flow:0,flush:6,flushlevel:6,flushonclos:6,follow:5,forc:2,format:[2,5],formatt:[5,6],found:5,from:[0,1,2,3,5,6,7,12],from_smsc:[3,5],full:[0,3,12],gatewai:[0,5],gather:[0,5],gener:[0,5,10],get:[0,1,2,5,12],get_event_loop:[0,2,5],getenv:0,getlogg:[5,6],give:[2,5],given:[1,6,7],goe:12,going:[1,2],good:5,googl:6,got:[6,12],greater:[5,12],gsm0338:[0,7],gsm:7,guarante:1,had:[1,2,3],hand:0,handl:[2,4,12],handler:[0,5,6,12],happen:5,happili:2,has:5,hasn:6,have:[2,5,12],hello:5,help:[2,3,10],here:[0,5],higher:6,hip:5,hold:5,hook:[0,2,4],hook_metadata1:1,hook_metadata2:1,hook_metadata:[0,1,3,5],hop:5,host:[0,2,5],houston:6,how:[2,5,12],howev:[1,2],http:[5,6],ident:0,identifi:[0,1],ignor:7,implement:[0,1,2,3,5,6,7,8,9,10,12],implemet:0,implemnet:2,impos:12,inc:5,includ:[0,2,6],incompat:5,increas:10,increment:5,indic:0,info:[0,6],inform:5,inherit:[1,3,6,7,8,9,10,12],init:5,initi:[3,10],inject:5,input:7,inspir:6,instal:[2,4],instanc:[0,2],instantait:2,instanti:[0,2,6],integ:10,integr:4,interact:0,interfac:[1,2,3,5,6,7,8,9,10,12],interface_vers:0,introduct:4,issu:5,item:[0,1,2,5,8],iter:1,its:[0,2],itself:[6,12],jayz:6,join:5,json:[2,5],just:[0,3,5,12],kafka:2,keep:5,kei:[1,5],kenyan:5,klqk248jsk8:2,komuw:2,kvlog:5,kvlogger:5,last:12,later:[0,5],learn:2,let:[2,5,9],level:[0,5,6],leverag:5,librari:4,like:[0,1,5,6],limit:[0,2,4,9,12],line:2,list:0,listen:[0,2],load:[2,5,12],localhost:2,log:[0,2,3,4],log_data:[5,6],log_id1:1,log_id2:1,log_id:[0,1,2,3,5],log_metadata:[0,5,6],logger:[0,3,5,6,9,12],logger_nam:6,logic:2,loglevel:[0,5,6],look:[1,2,5],loop:[0,2,5],lost:0,lot:2,lpush:2,mai:[1,3,5,9,12],main:2,make:[0,2,5,12],mandat:1,mandatori:5,manner:5,max_ttl:1,maximum:[6,8,9,10],maxsiz:[0,2,5,8],mean:0,mechan:[0,5],memori:[1,6,8],memoryhandl:6,messag:[0,1,2,3,5,6,7,9,12],met:6,metadata:[0,6],method:[0,1,3,5,6,7,8,9,10,12],metric:5,minimum:12,minsiz:2,missi:6,mkdir:2,mode:0,monitor:4,monoton:10,more:[2,5,12],mostli:6,msg:[0,2,6],msisdn:0,much:2,must:[1,3,6,7,8,9,10,12],my_app:5,my_client:2,my_config:5,my_naz_cli:[2,5],my_queu:[2,5],my_request:5,my_respons:5,myfil:5,myhook:5,myid12345:5,mykvlogg:5,mylimit:5,mylogg:6,myprometheushook:5,myredisqueu:2,mysmsdb:5,name:[0,5,6],naz:[0,1,3,6,7,8,9,10,11,12],naz_benchmarks_queu:2,nazclienterror:0,nazcodec:4,nazizi:5,ncodec:7,need:[2,5],network:0,next:2,next_sequ:10,none:[0,1,2,3,6,8,9,10,12],not_throttl:12,note:[1,8],notif:[1,5],notifi:6,notset:6,now:2,npi:0,number:[0,1,5,6,8,11,12],object:[0,5,7,11],observ:4,occur:5,ofcours:5,off:2,okai:2,older:1,omit:1,onc:2,one:[1,2,3],onli:[2,5,6,8],option:[1,2,11],order:2,origin:0,other:[1,2,5],ought:10,our:2,out:[0,2,5],outbound:8,outboundqueu:[0,2,5],outgo:5,over:[0,1,5,12],own:[2,5],paramet:[0,1,3,5,6,7,8,9,11,12],parti:5,particular:[1,2,12],pass:[0,2,5],password:[0,2,5],path:2,pdu:[0,3,5],per:[5,6],percent:12,percentag:[5,12],period:[0,5],pid:2,pip:[2,5],place:[2,5],plan:0,port:[0,2],possibl:2,predefin:0,previous:[1,3],print:5,prioriti:0,priority_flag:0,problem:6,prod:2,product:5,prometheu:5,prometheus_cli:5,properti:11,protocol:[0,5],protocol_id:0,purchas:2,purpos:[5,8],put:[1,6,8],put_nowait:5,python3:5,python:[0,1,2,5,6,7],python_path:2,queu:[0,4],queue:[0,2,4,5,12],queue_nam:2,rabbitmq:[2,5],rais:0,rang:[0,5,10],rate:[0,2,4,9,12],ratelimit:[0,4,5],re_establish_conn_bind:0,reach:10,read:[0,5],reader:5,readi:2,real:2,reason:[1,5,12],rebind:0,receipt:0,receipted_message_id:1,receiv:[0,3],receive_data:[0,2,5],recipi:0,reconnect:0,record:[5,6],redi:[2,5],registered_deliveri:0,regul:12,relat:[0,1,2],releas:5,reliabl:1,render:[5,6],replac:[0,2],replace_if_present_flag:0,repli:[5,12],repo:5,represenst:11,request:[0,3,5,9,10,12],requir:[0,5],respect:0,respond:12,respons:[0,2,3,5,10,12],ring:6,round:5,rout:[0,5],run:[0,2,5],run_forev:5,run_until_complet:[0,2,5],sai:5,said:0,same:[0,7],sample_s:[5,12],sampling_period:[5,12],san:5,satisfi:[1,2,3,5,6,7,8,9,10,12],save:8,schedul:0,schedule_delivery_tim:0,scheme:7,sdk:5,second:[0,1,5,9,12],see:[2,3,10],self:[1,2,3,5,10,12],send:[0,2,3,5,9,12],send_data:[0,2],send_messag:2,send_messsag:9,send_rat:[5,9],send_request:2,sender:0,sens:5,sent:[0,2,3],sentri:5,sentry_sdk:5,sequenc:[0,1,4],sequence_gener:0,sequence_numb:[0,1,10],sequence_number1:1,serv:0,server:[0,2,5,9],servic:[0,5],service_typ:0,session:[0,11],set:[2,5,7],setformatt:[5,6],setlevel:[5,6],setmessagestatehook:5,setup:5,ship:[2,5],shoe:2,short_messag:[0,2,5],should:[0,1,2,3,5,6,7,8,9,10,12],shouldflush:6,show:[2,5],shown:[1,3,6,7,8,9,10,12],shutdown:0,signal:0,signatur:[1,3,6,7,8,9,10,12],signifi:0,simpl:[1,5],simplecorrelat:1,simplehook:[3,5],simplelogg:6,simplenazcodec:7,simpleoutboundqueu:[0,5,8],simpleratelimit:[5,9],simplesequencegener:10,simplethrottlehandl:[5,12],simul:[2,5],singl:0,size:8,sleep:2,sm_default_msg_id:0,sme:0,smpp:[0,1,2,5,7,10,11,12],smpp_command:[0,1,2,3,5],smpp_server:2,smppclient1:[0,2,5],smppcommand:[5,11],smppcommandstatu:11,smppdatacod:11,smppoptionaltag:11,smppsessionst:11,smsc:[0,1,2,3,5,9,12],smsc_host:[0,2,5],smsc_message_id1:1,smsc_message_id:1,smsc_port:[0,2,5],smsc_respons:[],smstabl:5,socket:0,socket_timeout:0,softwar:2,some:0,someth:6,sometim:5,sourc:[0,1,3,6,7,8,9,10,11,12],source_addr:[0,2,5],source_addr_npi:0,source_addr_ton:0,specif:[0,10],specifi:[1,5,9],sql:5,sqlite3:5,stage:2,standard:7,standardconnectionhandl:2,start:[0,2,5,12],state:[0,2,3,4,5],statehook:5,statement:[0,6],statu:[0,3,5,11,12],status:11,stderr:6,stdlib:6,stdout:6,stop:5,storag:1,store:[0,1,2,6],stored_at:1,str:[0,1,3,5,6,7],stream:6,streamhandl:[5,6],streamread:0,streamwrit:0,strict:0,string:[0,1,3,5,7],string_to_encod:7,structur:6,style:5,submit:[0,2],submit_sm:[0,1,2,3,5],submit_sm_resp:[1,2,3],success:2,suppli:[1,3,5,6],support:[0,5],suppos:5,surpass:5,system:0,system_id:[0,2,5],system_typ:0,tabl:5,tag:[1,11],take:[2,5],taken:6,talk:[2,5],target:6,task:[0,5],termin:[0,5],test:[0,5,8],than:[1,5,12],thank:2,thei:[2,6],them:0,thi:[0,1,2,3,5,6,7,8,9,10,12],thing:2,third:5,those:5,throparserttl:0,throtll:[5,12],throttl:[0,2,4],throttle_delai:12,throttle_handl:[0,5],throttle_wait:12,throttler:5,through:[0,2],thu:[5,12],time:[0,1,12],timeout:2,timestamp:2,tmp:[2,5],to_smsc:[3,5],todo:0,token:[5,9],total:[5,12],track:[1,2,3],tracker:4,tracking_cod:2,tranceiv:[0,5],tranceiver_bind:[0,5],transceiv:0,transfer:5,trigger:6,trigger_level:[],tupl:[0,1,11],tweet:6,two:5,type:[0,1,3,6,7,8,9,10,12],typic:2,ultim:6,unbind:[0,5],unbind_resp:0,under:[5,12],union:[0,1,6],uniqu:[0,1,6],updat:5,upto:5,url:6,usag:[2,4,6,7,9],use:[1,2,5,6],used:[0,2,5,6,7,8],user:[0,1,3,6,7,8,9,10,12],uses:[0,1,5,7],using:[0,1,4,5,9],usual:[5,7],utf8:7,utf:7,valid:0,validity_period:0,valu:[1,5,11],variou:[0,2,11],version:[0,2,5,7],via:[0,5,12],wai:[2,5,6,12],wait:[0,2,12],want:[1,2,3,5,6],watch:5,web_request:6,wether:12,what:[0,2,5],whatev:[5,12],when:[0,2,3,5,6,10,12],whenev:[5,6],where:[2,5],wherea:2,whether:[0,2,6],which:[0,2,5,9,10,11,12],who:2,wikipedia:5,wire:0,work:[5,12],world:5,would:[0,5],wrap:[1,10],write:[0,5],writer:5,www:6,you:[0,2,5,9],your:[2,5],your_sentry_project_id:5,your_sentry_public_kei:5},titles:["Client","correlater","Example demo of using naz","hooks","naz - naz is an async SMPP client.","Introduction to naz","log","nazcodec","queue","ratelimiter","sequence","state","throttle"],titleterms:{api:4,app:5,async:[4,5],benchmark:5,bug:5,cli:5,client:[0,4],content:4,correlat:1,demo:2,everywher:5,exampl:2,featur:5,handl:5,hook:[3,5],instal:5,integr:5,introduct:5,librari:5,limit:5,log:[5,6],logger:[],monitor:5,naz:[2,4,5],nazcodec:7,observ:5,queu:5,queue:8,rate:5,ratelimit:9,refer:4,sequenc:10,smpp:4,state:11,throttl:[5,12],tracker:5,usag:5,using:2}}) \ No newline at end of file +Search.setIndex({docnames:["client","correlater","example_demo","hooks","index","introduction","log","nazcodec","queue","ratelimiter","sequence","state","throttle"],envversion:{"sphinx.domains.c":1,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":1,"sphinx.domains.javascript":1,"sphinx.domains.math":2,"sphinx.domains.python":1,"sphinx.domains.rst":1,"sphinx.domains.std":1,"sphinx.ext.todo":2,"sphinx.ext.viewcode":1,sphinx:56},filenames:["client.rst","correlater.rst","example_demo.rst","hooks.rst","index.rst","introduction.rst","log.rst","nazcodec.rst","queue.rst","ratelimiter.rst","sequence.rst","state.rst","throttle.rst"],objects:{"naz.client":{Client:[0,1,1,""],NazClientError:[0,3,1,""]},"naz.client.Client":{__init__:[0,2,1,""],command_handlers:[0,2,1,""],connect:[0,2,1,""],deliver_sm_resp:[0,2,1,""],dequeue_messages:[0,2,1,""],enquire_link:[0,2,1,""],enquire_link_resp:[0,2,1,""],re_establish_conn_bind:[0,2,1,""],receive_data:[0,2,1,""],send_data:[0,2,1,""],shutdown:[0,2,1,""],submit_sm:[0,2,1,""],tranceiver_bind:[0,2,1,""],unbind:[0,2,1,""],unbind_resp:[0,2,1,""]},"naz.correlater":{BaseCorrelater:[1,1,1,""],SimpleCorrelater:[1,1,1,""]},"naz.correlater.BaseCorrelater":{get:[1,2,1,""],put:[1,2,1,""]},"naz.correlater.SimpleCorrelater":{__init__:[1,2,1,""],delete_after_ttl:[1,2,1,""],get:[1,2,1,""],put:[1,2,1,""]},"naz.hooks":{BaseHook:[3,1,1,""],SimpleHook:[3,1,1,""]},"naz.hooks.BaseHook":{from_smsc:[3,2,1,""],to_smsc:[3,2,1,""]},"naz.hooks.SimpleHook":{__init__:[3,2,1,""],from_smsc:[3,2,1,""],to_smsc:[3,2,1,""]},"naz.log":{BaseLogger:[6,1,1,""],BreachHandler:[6,1,1,""],SimpleLogger:[6,1,1,""]},"naz.log.BaseLogger":{bind:[6,2,1,""],log:[6,2,1,""]},"naz.log.BreachHandler":{__init__:[6,2,1,""],shouldFlush:[6,2,1,""]},"naz.log.SimpleLogger":{__init__:[6,2,1,""],bind:[6,2,1,""],log:[6,2,1,""]},"naz.nazcodec":{BaseNazCodec:[7,1,1,""],SimpleNazCodec:[7,1,1,""]},"naz.nazcodec.BaseNazCodec":{decode:[7,2,1,""],encode:[7,2,1,""]},"naz.nazcodec.SimpleNazCodec":{decode:[7,2,1,""],encode:[7,2,1,""]},"naz.q":{BaseOutboundQueue:[8,1,1,""],SimpleOutboundQueue:[8,1,1,""]},"naz.q.BaseOutboundQueue":{dequeue:[8,2,1,""],enqueue:[8,2,1,""]},"naz.q.SimpleOutboundQueue":{__init__:[8,2,1,""],dequeue:[8,2,1,""],enqueue:[8,2,1,""]},"naz.ratelimiter":{BaseRateLimiter:[9,1,1,""],SimpleRateLimiter:[9,1,1,""]},"naz.ratelimiter.BaseRateLimiter":{limit:[9,2,1,""]},"naz.ratelimiter.SimpleRateLimiter":{__init__:[9,2,1,""],limit:[9,2,1,""]},"naz.sequence":{BaseSequenceGenerator:[10,1,1,""],SimpleSequenceGenerator:[10,1,1,""]},"naz.sequence.BaseSequenceGenerator":{next_sequence:[10,2,1,""]},"naz.sequence.SimpleSequenceGenerator":{__init__:[10,2,1,""],next_sequence:[10,2,1,""]},"naz.state":{CommandStatus:[11,1,1,""],DataCoding:[11,1,1,""],SmppCommand:[11,1,1,""],SmppCommandStatus:[11,1,1,""],SmppDataCoding:[11,1,1,""],SmppOptionalTag:[11,1,1,""],SmppSessionState:[11,1,1,""]},"naz.state.CommandStatus":{code:[11,2,1,""],description:[11,2,1,""],value:[11,2,1,""]},"naz.state.DataCoding":{code:[11,2,1,""],description:[11,2,1,""],value:[11,2,1,""]},"naz.throttle":{BaseThrottleHandler:[12,1,1,""],SimpleThrottleHandler:[12,1,1,""]},"naz.throttle.BaseThrottleHandler":{allow_request:[12,2,1,""],not_throttled:[12,2,1,""],throttle_delay:[12,2,1,""],throttled:[12,2,1,""]},"naz.throttle.SimpleThrottleHandler":{__init__:[12,2,1,""],allow_request:[12,2,1,""],not_throttled:[12,2,1,""],throttle_delay:[12,2,1,""],throttled:[12,2,1,""]},naz:{client:[0,0,0,"-"],correlater:[1,0,0,"-"],hooks:[3,0,0,"-"],log:[6,0,0,"-"],nazcodec:[7,0,0,"-"],q:[8,0,0,"-"],ratelimiter:[9,0,0,"-"],sequence:[10,0,0,"-"],state:[11,0,0,"-"],throttle:[12,0,0,"-"]}},objnames:{"0":["py","module","Python module"],"1":["py","class","Python class"],"2":["py","method","Python method"],"3":["py","exception","Python exception"]},objtypes:{"0":"py:module","1":"py:class","2":"py:method","3":"py:exception"},terms:{"0r5nd6bsd3g4atwux":2,"16be":7,"20min":5,"2billion":1,"7wjf935mqgsjplq7e":2,"\u03c3cmt":2,"\u30c4":5,"abstract":[1,3,6,7,8,9,10,12],"byte":[0,3,7],"class":[0,1,2,3,5,6,7,8,9,10,11,12],"default":[5,6],"final":5,"float":[0,1,6,9,12],"function":0,"h\u00fclk":7,"import":[0,2,5,6,9,12],"int":[0,1,6,8,10],"long":[2,5,12],"return":[0,1,2,3,5,6,7,8,9,10,12],"short":[0,5],"true":2,"try":5,"while":[0,2],"zo\u00e3":7,"zo\u00eb":7,AND:12,AWS:2,And:[2,5],But:2,For:[2,5],One:1,REs:5,SMS:0,SQS:2,That:[0,5],The:[0,1,2,5,6,8,10,12],With:2,__init__:[0,1,2,3,5,6,8,9,10,12],_get_redi:2,_handler:6,_redi:2,abc:[1,3,6,7,8,9,10,12],abil:5,abl:2,about:5,abov:[5,12],accept:2,acct:0,accur:[3,10],acknowledg:0,activ:[0,5],addhandl:[5,6],addit:0,addr_npi:0,addr_ton:0,address:[0,2],address_rang:0,after:[0,1,3,5,12],again:12,agnost:2,aha:6,aioredi:2,algorithm:[5,9],alia:11,all:[0,1,2,5,6],allow:[5,9,10],allow_request:12,alpin:2,also:[0,1,2,5,7,12],altern:6,among:1,ani:[0,1,2,3,5,6,8,12],annot:5,anoth:[1,2,5],anymor:12,anyth:5,api:5,app:[2,4],applic:[0,1,2,3,5],argument:[0,2],around:[1,10],arrang:0,articl:6,artist:5,associ:0,async:[0,1,2,3,8,9,12],asynchron:0,asyncio:[0,2,5],authent:0,auto:1,avail:2,await:[2,5,9],awesom:2,awesomestor:2,b526gdnxfbf8sqlzz:2,backward:5,band:5,base:[0,1,3,6,7,8,9,10,11,12],basecorrelat:[0,1],basehook:[0,3,5],baselogg:[0,5,6],basenazcodec:[0,7],baseoutboundqueu:[0,2,5,8],baseratelimit:[0,5,9],basesequencegener:[0,10],basethrottlehandl:[0,5,12],basi:1,been:[0,2,6],befor:[0,2,3,5,6,12],benchmark:4,best:1,between:[0,1,5],bind:[0,5,6],bind_receiv:0,bind_transceiv:0,bit:[6,7],block:0,bodi:0,body_data:0,bool:[0,6,12],both:2,breachhandl:6,bring:5,broker:2,brpop:2,bucket:[5,9],buffer:[0,6],buffer_s:[],bug:4,busi:2,byte_str:7,calcul:12,call:[0,1,2,3,5,6,7,8,12],can:[0,2,5,6,7,8,9,11],canari:5,capac:6,center:5,certain:6,chang:[2,5],charact:7,check:[0,5,6],choic:[2,5],choos:6,cleanli:0,cli:[2,4],client:[2,5,6,9,12],client_id:[0,2,5],close:[5,6],cmt:0,code:[0,2,11],codec:7,codec_class:0,codec_errors_level:0,com:6,come:1,command:[1,2,3,11],command_handl:[0,2],command_statu:2,command_status_valu:0,commandlin:5,commandstatu:[3,11],commit:5,commun:2,compos:5,condit:[6,12],config:5,confirm:2,conn:5,connect:[0,2,5],connection_lost:2,consult:[2,5],consum:5,contain:[2,5],content:5,continu:[0,5],control:[0,5,9],correl:[1,3,10],correlat:4,correlatinid:5,correlation_handl:0,could:6,counter:5,creat:[2,5],create_redis_pool:2,cthank:2,current:[2,5],cursor:5,custom:[2,5,9],customer_id:6,damn:6,data:[0,3,5,11],databas:5,datacod:11,debug:[5,6],decid:[5,6,12],decis:12,declar:0,decod:[0,2,7],def:[2,5],defin:[0,7],delet:1,delete_after_ttl:1,deliv:5,deliver_sm:[1,5],deliver_sm_resp:0,deliveri:[0,1,5],demo:[4,5,8],demo_naz:2,deni:[5,12],deny_request_at:[5,12],depend:5,dequed_item:2,dequeu:[0,2,5,8],dequeue_messag:[0,2,5],deriv:5,descript:[5,11],design:[0,5],dest_addr_npi:0,dest_addr_ton:0,destin:0,destination_addr:[0,2,5],determin:12,develop:[2,5,6],diagnost:6,dict:[0,6,8],dictionari:[1,5],did:6,differ:[0,1,3],directori:[2,5],doc:5,docker:[2,5],document:[2,5],doe:[0,5,6,9,12],domain:0,done:[1,2],dot:2,down:0,drain_dur:0,dry:2,dump:2,durat:[0,12],each:5,effort:1,elliot:6,els:2,emit:6,emoji:5,empti:2,enabl:[6,12],encod:[0,7,11],encoding1:0,end:2,enqueu:[0,2,5,8],enquire_link:[0,5],enquire_link_interv:0,enquire_link_resp:0,entiti:5,environ:5,error:[0,5,6,7],esm:[0,5],esm_class:0,esme_rmsgq:12,esme_rthrottl:5,etc:[2,6,7],even:[5,6],event:[2,5,6],everi:6,everytim:[6,12],everywher:4,exampl:[0,4,5,6,7,9],example_config:5,examplequeu:5,exce:12,exceed:6,except:[0,5,6],execut:[2,5],exist:0,exit:2,expect:2,expir:1,extern:5,fals:[0,2,6,12],featur:[1,4],field:[0,11],file:[2,5,6],flag:0,flow:0,flush:6,flushlevel:6,flushonclos:6,follow:5,forc:2,format:[2,5],formatt:[5,6],found:5,from:[0,1,2,3,5,6,7,12],from_smsc:[3,5],full:[0,3,12],gatewai:[0,5],gather:[0,5],gener:[0,5,10],get:[0,1,2,5,12],get_event_loop:[0,2,5],getenv:0,getlogg:[5,6],give:[2,5],given:[1,6,7],goe:12,going:[1,2],good:[5,6],googl:6,got:[6,12],greater:[5,12],gsm0338:[0,7],gsm:7,guarante:1,had:[1,2,3],hand:0,handl:[2,4,12],handler:[0,5,6,12],happen:5,happili:2,has:5,hasn:6,have:[2,5,12],heartbeat:6,heartbeatinterv:6,hello:5,help:[2,3,10],here:[0,5],higher:6,hip:5,hold:5,hook:[0,2,4],hook_metadata1:1,hook_metadata2:1,hook_metadata:[0,1,3,5],hop:5,host:[0,2,5],houston:6,how:[2,5,12],howev:[1,2],http:[5,6],ident:0,identifi:[0,1],ignor:7,implement:[0,1,2,3,5,6,7,8,9,10,12],implemet:0,implemnet:2,impos:12,inc:5,includ:[0,2,6],incompat:5,increas:10,increment:5,indic:0,info:[0,6],inform:5,inherit:[1,3,6,7,8,9,10,12],init:5,initi:[3,10],inject:5,input:7,inspir:6,instal:[2,4],instanc:[0,2],instantait:2,instanti:[0,2,6],integ:10,integr:4,interact:0,interfac:[1,2,3,5,6,7,8,9,10,12],interface_vers:0,introduct:4,issu:5,item:[0,1,2,5,8],iter:1,its:[0,2],itself:[6,12],jayz:6,join:5,json:[2,5],just:[0,3,5,12],kafka:2,keep:5,kei:[1,5],kenyan:5,klqk248jsk8:2,komuw:2,kvlog:5,kvlogger:5,last:12,later:[0,5],learn:2,let:[2,5,9],level:[0,5,6],leverag:5,librari:4,like:[0,1,5,6],limit:[0,2,4,9,12],line:2,list:0,listen:[0,2],load:[2,5,12],localhost:2,log:[0,2,3,4],log_data:[5,6],log_id1:1,log_id2:1,log_id:[0,1,2,3,5],log_metadata:[0,5,6],logger:[0,3,5,6,9,12],logger_nam:6,logic:2,loglevel:[0,5,6],look:[1,2,5],loop:[0,2,5],lost:0,lot:2,lpush:2,mai:[1,3,5,9,12],main:2,make:[0,2,5,12],mandat:1,mandatori:5,manner:5,max_ttl:1,maximum:[6,8,9,10],maxsiz:[0,2,5,8],mean:0,mechan:[0,5],memori:[1,6,8],memoryhandl:6,messag:[0,1,2,3,5,6,7,9,12],met:6,metadata:[0,6],method:[0,1,3,5,6,7,8,9,10,12],metric:5,minimum:12,minsiz:2,minut:6,missi:6,mkdir:2,mode:0,monitor:4,monoton:10,more:[2,5,6,12],mostli:6,msg:[0,2,6],msisdn:0,much:2,must:[1,3,6,7,8,9,10,12],my_app:5,my_client:2,my_config:5,my_naz_cli:[2,5],my_queu:[2,5],my_request:5,my_respons:5,myfil:5,myhook:5,myid12345:5,mykvlogg:5,mylimit:5,mylogg:6,myprometheushook:5,myredisqueu:2,mysmsdb:5,name:[0,5,6],naz:[0,1,3,6,7,8,9,10,11,12],naz_benchmarks_queu:2,nazclienterror:0,nazcodec:4,nazizi:5,ncodec:7,need:[2,5],network:0,next:2,next_sequ:10,none:[0,1,2,3,6,8,9,10,12],not_throttl:12,note:[1,8],notif:[1,5],notifi:6,notset:6,now:2,npi:0,number:[0,1,5,6,8,11,12],object:[0,5,7,11],observ:4,occur:5,ofcours:5,off:2,okai:2,older:1,omit:1,onc:2,one:[1,2,3],onli:[2,5,6,8],option:[1,2,11],order:2,origin:0,other:[1,2,5],ought:10,our:2,out:[0,2,5],outbound:8,outboundqueu:[0,2,5],outgo:5,over:[0,1,5,12],own:[2,5],paramet:[0,1,3,5,6,7,8,9,11,12],parti:5,particular:[1,2,12],pass:[0,2,5],password:[0,2,5],path:2,pdu:[0,3,5],per:[5,6],percent:12,percentag:[5,12],period:[0,5],pid:2,pip:[2,5],place:[2,5],plan:0,port:[0,2],possibl:2,predefin:0,previous:[1,3],print:5,prioriti:0,priority_flag:0,problem:6,prod:2,product:5,prometheu:5,prometheus_cli:5,properti:11,protocol:[0,5],protocol_id:0,purchas:2,purpos:[5,8],put:[1,6,8],put_nowait:5,python3:5,python:[0,1,2,5,6,7],python_path:2,queu:[0,4],queue:[0,2,4,5,12],queue_nam:2,rabbitmq:[2,5],rais:0,rang:[0,5,10],rate:[0,2,4,9,12],ratelimit:[0,4,5],re_establish_conn_bind:0,reach:10,read:[0,5],reader:5,readi:2,real:2,reason:[1,5,12],rebind:0,receipt:0,receipted_message_id:1,receiv:[0,3],receive_data:[0,2,5],recipi:0,reconnect:0,record:[5,6],redi:[2,5],registered_deliveri:0,regul:12,relat:[0,1,2],releas:5,reliabl:1,render:[5,6],replac:[0,2],replace_if_present_flag:0,repli:[5,12],repo:5,represenst:11,request:[0,3,5,9,10,12],requir:[0,5],respect:0,respond:12,respons:[0,2,3,5,10,12],ring:6,round:5,rout:[0,5],run:[0,2,5],run_forev:5,run_until_complet:[0,2,5],sai:5,said:0,same:[0,7],sample_s:[5,12],sampling_period:[5,12],san:5,satisfi:[1,2,3,5,6,7,8,9,10,12],save:8,schedul:0,schedule_delivery_tim:0,scheme:7,sdk:5,second:[0,1,5,6,9,12],see:[2,3,10],self:[1,2,3,5,10,12],send:[0,2,3,5,9,12],send_data:[0,2],send_messag:2,send_messsag:9,send_rat:[5,9],send_request:2,sender:0,sens:5,sent:[0,2,3],sentri:5,sentry_sdk:5,sequenc:[0,1,4],sequence_gener:0,sequence_numb:[0,1,10],sequence_number1:1,serv:0,server:[0,2,5,9],servic:[0,5],service_typ:0,session:[0,11],set:[2,5,6,7],setformatt:[5,6],setlevel:[5,6],setmessagestatehook:5,setup:5,ship:[2,5],shoe:2,short_messag:[0,2,5],should:[0,1,2,3,5,6,7,8,9,10,12],shouldflush:6,show:[2,5],shown:[1,3,6,7,8,9,10,12],shutdown:0,signal:0,signatur:[1,3,6,7,8,9,10,12],signifi:0,simpl:[1,5],simplecorrelat:1,simplehook:[3,5],simplelogg:6,simplenazcodec:7,simpleoutboundqueu:[0,5,8],simpleratelimit:[5,9],simplesequencegener:10,simplethrottlehandl:[5,12],simul:[2,5],singl:0,size:8,sleep:2,sm_default_msg_id:0,sme:0,smpp:[0,1,2,5,7,10,11,12],smpp_command:[0,1,2,3,5],smpp_server:2,smppclient1:[0,2,5],smppcommand:[5,11],smppcommandstatu:11,smppdatacod:11,smppoptionaltag:11,smppsessionst:11,smsc:[0,1,2,3,5,9,12],smsc_host:[0,2,5],smsc_message_id1:1,smsc_message_id:1,smsc_port:[0,2,5],smsc_respons:[],smstabl:5,socket:0,socket_timeout:0,softwar:2,some:0,someth:6,sometim:5,sourc:[0,1,3,6,7,8,9,10,11,12],source_addr:[0,2,5],source_addr_npi:0,source_addr_ton:0,specif:[0,10],specifi:[1,5,9],sql:5,sqlite3:5,stage:2,standard:7,standardconnectionhandl:2,start:[0,2,5,12],state:[0,2,3,4,5],statehook:5,statement:[0,6],statu:[0,3,5,11,12],status:11,stderr:6,stdlib:6,stdout:6,stop:5,storag:1,store:[0,1,2,6],stored_at:1,str:[0,1,3,5,6,7],stream:6,streamhandl:[5,6],streamread:0,streamwrit:0,strict:0,string:[0,1,3,5,7],string_to_encod:7,structur:6,style:5,submit:[0,2],submit_sm:[0,1,2,3,5],submit_sm_resp:[1,2,3],success:2,suppli:[1,3,5,6],support:[0,5],suppos:5,surpass:5,system:0,system_id:[0,2,5],system_typ:0,tabl:5,tag:[1,11],take:[2,5],taken:6,talk:[2,5],target:6,task:[0,5],termin:[0,5],test:[0,5,8],than:[1,5,12],thank:2,thei:[2,6],them:0,thi:[0,1,2,3,5,6,7,8,9,10,12],thing:2,third:5,those:5,throparserttl:0,throtll:[5,12],throttl:[0,2,4],throttle_delai:12,throttle_handl:[0,5],throttle_wait:12,throttler:5,through:[0,2],thu:[5,12],time:[0,1,12],timeout:2,timestamp:2,tmp:[2,5],to_smsc:[3,5],todo:0,token:[5,9],total:[5,12],track:[1,2,3],tracker:4,tracking_cod:2,tranceiv:[0,5],tranceiver_bind:[0,5],transceiv:0,transfer:5,trigger:6,trigger_level:[],tupl:[0,1,11],tweet:6,two:5,type:[0,1,3,6,7,8,9,10,12],typic:2,ultim:6,unbind:[0,5],unbind_resp:0,under:[5,12],union:[0,1,6],uniqu:[0,1,6],updat:5,upto:5,url:6,usag:[2,4,6,7,9],use:[1,2,5,6],used:[0,2,5,6,7,8],user:[0,1,3,6,7,8,9,10,12],uses:[0,1,5,7],using:[0,1,4,5,9],usual:[5,7],utf8:7,utf:7,valid:0,validity_period:0,valu:[1,5,6,11],variou:[0,2,11],version:[0,2,5,7],via:[0,5,12],wai:[2,5,6,12],wait:[0,2,12],want:[1,2,3,5,6],watch:5,web_request:6,wether:12,what:[0,2,5],whatev:[5,12],when:[0,2,3,5,6,10,12],whenev:[5,6],where:[2,5],wherea:2,whether:[0,2,6],which:[0,2,5,9,10,11,12],who:2,wikipedia:5,wire:0,work:[5,12],world:5,would:[0,5],wrap:[1,10],write:[0,5],writer:5,www:6,you:[0,2,5,6,9],your:[2,5],your_sentry_project_id:5,your_sentry_public_kei:5},titles:["Client","correlater","Example demo of using naz","hooks","naz - naz is an async SMPP client.","Introduction to naz","log","nazcodec","queue","ratelimiter","sequence","state","throttle"],titleterms:{api:4,app:5,async:[4,5],benchmark:5,bug:5,cli:5,client:[0,4],content:4,correlat:1,demo:2,everywher:5,exampl:2,featur:5,handl:5,hook:[3,5],instal:5,integr:5,introduct:5,librari:5,limit:5,log:[5,6],logger:[],monitor:5,naz:[2,4,5],nazcodec:7,observ:5,queu:5,queue:8,rate:5,ratelimit:9,refer:4,sequenc:10,smpp:4,state:11,throttl:[5,12],tracker:5,usag:5,using:2}}) \ No newline at end of file From 4bebabcb80aaa18b2b2a4ad6424bf9c14300da0a Mon Sep 17 00:00:00 2001 From: komuW Date: Fri, 6 Sep 2019 12:14:34 +0300 Subject: [PATCH 13/18] g --- naz/log.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/naz/log.py b/naz/log.py index ce583cef..b8689137 100644 --- a/naz/log.py +++ b/naz/log.py @@ -215,7 +215,7 @@ def __init__( capacity: the maximum number of log records to store in the ring buffer target: the ultimate `log handler `_ that will be used. flushOnClose: whether to flush the buffer when the handler is closed even if the flush level hasn't been exceeded - heartbeatInterval: can be an float or None. If it is an float, then a heartbeat log record will be emitted every :py:attr:`~heartbeatInterval` seconds. + heartbeatInterval: can be a float or None. If it is an float, then a heartbeat log record will be emitted every :py:attr:`~heartbeatInterval` seconds. If it is None(the default), then no heartbeat log record is emitted. If you do decide to set it, a good value is 1800(ie 30 minutes) or more. """ From d5789b3eca73eeb8540d96295cd1eaf2fc1a6fac Mon Sep 17 00:00:00 2001 From: komuW Date: Fri, 6 Sep 2019 12:14:46 +0300 Subject: [PATCH 14/18] g --- docs/_modules/naz/log.html | 2 +- docs/log.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/_modules/naz/log.html b/docs/_modules/naz/log.html index 7557c994..26c126c9 100644 --- a/docs/_modules/naz/log.html +++ b/docs/_modules/naz/log.html @@ -379,7 +379,7 @@

Source code for naz.log

             capacity: the maximum number of log records to store in the ring buffer
             target: the ultimate `log handler <https://docs.python.org/3.6/library/logging.html#logging.Handler>`_ that will be used.
             flushOnClose: whether to flush the buffer when the handler is closed even if the flush level hasn't been exceeded
-            heartbeatInterval: can be an float or None. If it is an float, then a heartbeat log record will be emitted every :py:attr:`~heartbeatInterval` seconds.
+            heartbeatInterval: can be a float or None. If it is an float, then a heartbeat log record will be emitted every :py:attr:`~heartbeatInterval` seconds.
                                If it is None(the default), then no heartbeat log record is emitted.
                                If you do decide to set it, a good value is 1800(ie 30 minutes) or more.
         """
diff --git a/docs/log.html b/docs/log.html
index 64af835e..424641e0 100644
--- a/docs/log.html
+++ b/docs/log.html
@@ -324,7 +324,7 @@
 
  • capacity (int) – the maximum number of log records to store in the ring buffer

  • target (Handler) – the ultimate log handler that will be used.

  • flushOnClose (bool) – whether to flush the buffer when the handler is closed even if the flush level hasn’t been exceeded

  • -
  • heartbeatInterval (Union[None, float]) – can be an float or None. If it is an float, then a heartbeat log record will be emitted every heartbeatInterval seconds. +

  • heartbeatInterval (Union[None, float]) – can be a float or None. If it is an float, then a heartbeat log record will be emitted every heartbeatInterval seconds. If it is None(the default), then no heartbeat log record is emitted. If you do decide to set it, a good value is 1800(ie 30 minutes) or more.

  • From 7b4257c5667bc41ef2fe353db632297335fd8add Mon Sep 17 00:00:00 2001 From: komuW Date: Fri, 6 Sep 2019 12:15:56 +0300 Subject: [PATCH 15/18] g --- docs/_modules/naz/log.html | 4 ++-- docs/log.html | 4 ++-- docs/searchindex.js | 2 +- naz/log.py | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/_modules/naz/log.html b/docs/_modules/naz/log.html index 26c126c9..664f446d 100644 --- a/docs/_modules/naz/log.html +++ b/docs/_modules/naz/log.html @@ -379,9 +379,9 @@

    Source code for naz.log

                 capacity: the maximum number of log records to store in the ring buffer
                 target: the ultimate `log handler <https://docs.python.org/3.6/library/logging.html#logging.Handler>`_ that will be used.
                 flushOnClose: whether to flush the buffer when the handler is closed even if the flush level hasn't been exceeded
    -            heartbeatInterval: can be a float or None. If it is an float, then a heartbeat log record will be emitted every :py:attr:`~heartbeatInterval` seconds.
    +            heartbeatInterval: can be a float or None. If it is a float, then a heartbeat log record will be emitted every :py:attr:`~heartbeatInterval` seconds.
                                    If it is None(the default), then no heartbeat log record is emitted.
    -                               If you do decide to set it, a good value is 1800(ie 30 minutes) or more.
    +                               If you do decide to set it, a good value is at least 1800(ie 30 minutes).
             """
             self._validate_args(
                 flushLevel=flushLevel,
    diff --git a/docs/log.html b/docs/log.html
    index 424641e0..12d0968f 100644
    --- a/docs/log.html
    +++ b/docs/log.html
    @@ -324,9 +324,9 @@
     
  • capacity (int) – the maximum number of log records to store in the ring buffer

  • target (Handler) – the ultimate log handler that will be used.

  • flushOnClose (bool) – whether to flush the buffer when the handler is closed even if the flush level hasn’t been exceeded

  • -
  • heartbeatInterval (Union[None, float]) – can be a float or None. If it is an float, then a heartbeat log record will be emitted every heartbeatInterval seconds. +

  • heartbeatInterval (Union[None, float]) – can be a float or None. If it is a float, then a heartbeat log record will be emitted every heartbeatInterval seconds. If it is None(the default), then no heartbeat log record is emitted. -If you do decide to set it, a good value is 1800(ie 30 minutes) or more.

  • +If you do decide to set it, a good value is at least 1800(ie 30 minutes).

    Return type
    diff --git a/docs/searchindex.js b/docs/searchindex.js index f39d3d76..041eaf03 100644 --- a/docs/searchindex.js +++ b/docs/searchindex.js @@ -1 +1 @@ -Search.setIndex({docnames:["client","correlater","example_demo","hooks","index","introduction","log","nazcodec","queue","ratelimiter","sequence","state","throttle"],envversion:{"sphinx.domains.c":1,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":1,"sphinx.domains.javascript":1,"sphinx.domains.math":2,"sphinx.domains.python":1,"sphinx.domains.rst":1,"sphinx.domains.std":1,"sphinx.ext.todo":2,"sphinx.ext.viewcode":1,sphinx:56},filenames:["client.rst","correlater.rst","example_demo.rst","hooks.rst","index.rst","introduction.rst","log.rst","nazcodec.rst","queue.rst","ratelimiter.rst","sequence.rst","state.rst","throttle.rst"],objects:{"naz.client":{Client:[0,1,1,""],NazClientError:[0,3,1,""]},"naz.client.Client":{__init__:[0,2,1,""],command_handlers:[0,2,1,""],connect:[0,2,1,""],deliver_sm_resp:[0,2,1,""],dequeue_messages:[0,2,1,""],enquire_link:[0,2,1,""],enquire_link_resp:[0,2,1,""],re_establish_conn_bind:[0,2,1,""],receive_data:[0,2,1,""],send_data:[0,2,1,""],shutdown:[0,2,1,""],submit_sm:[0,2,1,""],tranceiver_bind:[0,2,1,""],unbind:[0,2,1,""],unbind_resp:[0,2,1,""]},"naz.correlater":{BaseCorrelater:[1,1,1,""],SimpleCorrelater:[1,1,1,""]},"naz.correlater.BaseCorrelater":{get:[1,2,1,""],put:[1,2,1,""]},"naz.correlater.SimpleCorrelater":{__init__:[1,2,1,""],delete_after_ttl:[1,2,1,""],get:[1,2,1,""],put:[1,2,1,""]},"naz.hooks":{BaseHook:[3,1,1,""],SimpleHook:[3,1,1,""]},"naz.hooks.BaseHook":{from_smsc:[3,2,1,""],to_smsc:[3,2,1,""]},"naz.hooks.SimpleHook":{__init__:[3,2,1,""],from_smsc:[3,2,1,""],to_smsc:[3,2,1,""]},"naz.log":{BaseLogger:[6,1,1,""],BreachHandler:[6,1,1,""],SimpleLogger:[6,1,1,""]},"naz.log.BaseLogger":{bind:[6,2,1,""],log:[6,2,1,""]},"naz.log.BreachHandler":{__init__:[6,2,1,""],shouldFlush:[6,2,1,""]},"naz.log.SimpleLogger":{__init__:[6,2,1,""],bind:[6,2,1,""],log:[6,2,1,""]},"naz.nazcodec":{BaseNazCodec:[7,1,1,""],SimpleNazCodec:[7,1,1,""]},"naz.nazcodec.BaseNazCodec":{decode:[7,2,1,""],encode:[7,2,1,""]},"naz.nazcodec.SimpleNazCodec":{decode:[7,2,1,""],encode:[7,2,1,""]},"naz.q":{BaseOutboundQueue:[8,1,1,""],SimpleOutboundQueue:[8,1,1,""]},"naz.q.BaseOutboundQueue":{dequeue:[8,2,1,""],enqueue:[8,2,1,""]},"naz.q.SimpleOutboundQueue":{__init__:[8,2,1,""],dequeue:[8,2,1,""],enqueue:[8,2,1,""]},"naz.ratelimiter":{BaseRateLimiter:[9,1,1,""],SimpleRateLimiter:[9,1,1,""]},"naz.ratelimiter.BaseRateLimiter":{limit:[9,2,1,""]},"naz.ratelimiter.SimpleRateLimiter":{__init__:[9,2,1,""],limit:[9,2,1,""]},"naz.sequence":{BaseSequenceGenerator:[10,1,1,""],SimpleSequenceGenerator:[10,1,1,""]},"naz.sequence.BaseSequenceGenerator":{next_sequence:[10,2,1,""]},"naz.sequence.SimpleSequenceGenerator":{__init__:[10,2,1,""],next_sequence:[10,2,1,""]},"naz.state":{CommandStatus:[11,1,1,""],DataCoding:[11,1,1,""],SmppCommand:[11,1,1,""],SmppCommandStatus:[11,1,1,""],SmppDataCoding:[11,1,1,""],SmppOptionalTag:[11,1,1,""],SmppSessionState:[11,1,1,""]},"naz.state.CommandStatus":{code:[11,2,1,""],description:[11,2,1,""],value:[11,2,1,""]},"naz.state.DataCoding":{code:[11,2,1,""],description:[11,2,1,""],value:[11,2,1,""]},"naz.throttle":{BaseThrottleHandler:[12,1,1,""],SimpleThrottleHandler:[12,1,1,""]},"naz.throttle.BaseThrottleHandler":{allow_request:[12,2,1,""],not_throttled:[12,2,1,""],throttle_delay:[12,2,1,""],throttled:[12,2,1,""]},"naz.throttle.SimpleThrottleHandler":{__init__:[12,2,1,""],allow_request:[12,2,1,""],not_throttled:[12,2,1,""],throttle_delay:[12,2,1,""],throttled:[12,2,1,""]},naz:{client:[0,0,0,"-"],correlater:[1,0,0,"-"],hooks:[3,0,0,"-"],log:[6,0,0,"-"],nazcodec:[7,0,0,"-"],q:[8,0,0,"-"],ratelimiter:[9,0,0,"-"],sequence:[10,0,0,"-"],state:[11,0,0,"-"],throttle:[12,0,0,"-"]}},objnames:{"0":["py","module","Python module"],"1":["py","class","Python class"],"2":["py","method","Python method"],"3":["py","exception","Python exception"]},objtypes:{"0":"py:module","1":"py:class","2":"py:method","3":"py:exception"},terms:{"0r5nd6bsd3g4atwux":2,"16be":7,"20min":5,"2billion":1,"7wjf935mqgsjplq7e":2,"\u03c3cmt":2,"\u30c4":5,"abstract":[1,3,6,7,8,9,10,12],"byte":[0,3,7],"class":[0,1,2,3,5,6,7,8,9,10,11,12],"default":[5,6],"final":5,"float":[0,1,6,9,12],"function":0,"h\u00fclk":7,"import":[0,2,5,6,9,12],"int":[0,1,6,8,10],"long":[2,5,12],"return":[0,1,2,3,5,6,7,8,9,10,12],"short":[0,5],"true":2,"try":5,"while":[0,2],"zo\u00e3":7,"zo\u00eb":7,AND:12,AWS:2,And:[2,5],But:2,For:[2,5],One:1,REs:5,SMS:0,SQS:2,That:[0,5],The:[0,1,2,5,6,8,10,12],With:2,__init__:[0,1,2,3,5,6,8,9,10,12],_get_redi:2,_handler:6,_redi:2,abc:[1,3,6,7,8,9,10,12],abil:5,abl:2,about:5,abov:[5,12],accept:2,acct:0,accur:[3,10],acknowledg:0,activ:[0,5],addhandl:[5,6],addit:0,addr_npi:0,addr_ton:0,address:[0,2],address_rang:0,after:[0,1,3,5,12],again:12,agnost:2,aha:6,aioredi:2,algorithm:[5,9],alia:11,all:[0,1,2,5,6],allow:[5,9,10],allow_request:12,alpin:2,also:[0,1,2,5,7,12],altern:6,among:1,ani:[0,1,2,3,5,6,8,12],annot:5,anoth:[1,2,5],anymor:12,anyth:5,api:5,app:[2,4],applic:[0,1,2,3,5],argument:[0,2],around:[1,10],arrang:0,articl:6,artist:5,associ:0,async:[0,1,2,3,8,9,12],asynchron:0,asyncio:[0,2,5],authent:0,auto:1,avail:2,await:[2,5,9],awesom:2,awesomestor:2,b526gdnxfbf8sqlzz:2,backward:5,band:5,base:[0,1,3,6,7,8,9,10,11,12],basecorrelat:[0,1],basehook:[0,3,5],baselogg:[0,5,6],basenazcodec:[0,7],baseoutboundqueu:[0,2,5,8],baseratelimit:[0,5,9],basesequencegener:[0,10],basethrottlehandl:[0,5,12],basi:1,been:[0,2,6],befor:[0,2,3,5,6,12],benchmark:4,best:1,between:[0,1,5],bind:[0,5,6],bind_receiv:0,bind_transceiv:0,bit:[6,7],block:0,bodi:0,body_data:0,bool:[0,6,12],both:2,breachhandl:6,bring:5,broker:2,brpop:2,bucket:[5,9],buffer:[0,6],buffer_s:[],bug:4,busi:2,byte_str:7,calcul:12,call:[0,1,2,3,5,6,7,8,12],can:[0,2,5,6,7,8,9,11],canari:5,capac:6,center:5,certain:6,chang:[2,5],charact:7,check:[0,5,6],choic:[2,5],choos:6,cleanli:0,cli:[2,4],client:[2,5,6,9,12],client_id:[0,2,5],close:[5,6],cmt:0,code:[0,2,11],codec:7,codec_class:0,codec_errors_level:0,com:6,come:1,command:[1,2,3,11],command_handl:[0,2],command_statu:2,command_status_valu:0,commandlin:5,commandstatu:[3,11],commit:5,commun:2,compos:5,condit:[6,12],config:5,confirm:2,conn:5,connect:[0,2,5],connection_lost:2,consult:[2,5],consum:5,contain:[2,5],content:5,continu:[0,5],control:[0,5,9],correl:[1,3,10],correlat:4,correlatinid:5,correlation_handl:0,could:6,counter:5,creat:[2,5],create_redis_pool:2,cthank:2,current:[2,5],cursor:5,custom:[2,5,9],customer_id:6,damn:6,data:[0,3,5,11],databas:5,datacod:11,debug:[5,6],decid:[5,6,12],decis:12,declar:0,decod:[0,2,7],def:[2,5],defin:[0,7],delet:1,delete_after_ttl:1,deliv:5,deliver_sm:[1,5],deliver_sm_resp:0,deliveri:[0,1,5],demo:[4,5,8],demo_naz:2,deni:[5,12],deny_request_at:[5,12],depend:5,dequed_item:2,dequeu:[0,2,5,8],dequeue_messag:[0,2,5],deriv:5,descript:[5,11],design:[0,5],dest_addr_npi:0,dest_addr_ton:0,destin:0,destination_addr:[0,2,5],determin:12,develop:[2,5,6],diagnost:6,dict:[0,6,8],dictionari:[1,5],did:6,differ:[0,1,3],directori:[2,5],doc:5,docker:[2,5],document:[2,5],doe:[0,5,6,9,12],domain:0,done:[1,2],dot:2,down:0,drain_dur:0,dry:2,dump:2,durat:[0,12],each:5,effort:1,elliot:6,els:2,emit:6,emoji:5,empti:2,enabl:[6,12],encod:[0,7,11],encoding1:0,end:2,enqueu:[0,2,5,8],enquire_link:[0,5],enquire_link_interv:0,enquire_link_resp:0,entiti:5,environ:5,error:[0,5,6,7],esm:[0,5],esm_class:0,esme_rmsgq:12,esme_rthrottl:5,etc:[2,6,7],even:[5,6],event:[2,5,6],everi:6,everytim:[6,12],everywher:4,exampl:[0,4,5,6,7,9],example_config:5,examplequeu:5,exce:12,exceed:6,except:[0,5,6],execut:[2,5],exist:0,exit:2,expect:2,expir:1,extern:5,fals:[0,2,6,12],featur:[1,4],field:[0,11],file:[2,5,6],flag:0,flow:0,flush:6,flushlevel:6,flushonclos:6,follow:5,forc:2,format:[2,5],formatt:[5,6],found:5,from:[0,1,2,3,5,6,7,12],from_smsc:[3,5],full:[0,3,12],gatewai:[0,5],gather:[0,5],gener:[0,5,10],get:[0,1,2,5,12],get_event_loop:[0,2,5],getenv:0,getlogg:[5,6],give:[2,5],given:[1,6,7],goe:12,going:[1,2],good:[5,6],googl:6,got:[6,12],greater:[5,12],gsm0338:[0,7],gsm:7,guarante:1,had:[1,2,3],hand:0,handl:[2,4,12],handler:[0,5,6,12],happen:5,happili:2,has:5,hasn:6,have:[2,5,12],heartbeat:6,heartbeatinterv:6,hello:5,help:[2,3,10],here:[0,5],higher:6,hip:5,hold:5,hook:[0,2,4],hook_metadata1:1,hook_metadata2:1,hook_metadata:[0,1,3,5],hop:5,host:[0,2,5],houston:6,how:[2,5,12],howev:[1,2],http:[5,6],ident:0,identifi:[0,1],ignor:7,implement:[0,1,2,3,5,6,7,8,9,10,12],implemet:0,implemnet:2,impos:12,inc:5,includ:[0,2,6],incompat:5,increas:10,increment:5,indic:0,info:[0,6],inform:5,inherit:[1,3,6,7,8,9,10,12],init:5,initi:[3,10],inject:5,input:7,inspir:6,instal:[2,4],instanc:[0,2],instantait:2,instanti:[0,2,6],integ:10,integr:4,interact:0,interfac:[1,2,3,5,6,7,8,9,10,12],interface_vers:0,introduct:4,issu:5,item:[0,1,2,5,8],iter:1,its:[0,2],itself:[6,12],jayz:6,join:5,json:[2,5],just:[0,3,5,12],kafka:2,keep:5,kei:[1,5],kenyan:5,klqk248jsk8:2,komuw:2,kvlog:5,kvlogger:5,last:12,later:[0,5],learn:2,let:[2,5,9],level:[0,5,6],leverag:5,librari:4,like:[0,1,5,6],limit:[0,2,4,9,12],line:2,list:0,listen:[0,2],load:[2,5,12],localhost:2,log:[0,2,3,4],log_data:[5,6],log_id1:1,log_id2:1,log_id:[0,1,2,3,5],log_metadata:[0,5,6],logger:[0,3,5,6,9,12],logger_nam:6,logic:2,loglevel:[0,5,6],look:[1,2,5],loop:[0,2,5],lost:0,lot:2,lpush:2,mai:[1,3,5,9,12],main:2,make:[0,2,5,12],mandat:1,mandatori:5,manner:5,max_ttl:1,maximum:[6,8,9,10],maxsiz:[0,2,5,8],mean:0,mechan:[0,5],memori:[1,6,8],memoryhandl:6,messag:[0,1,2,3,5,6,7,9,12],met:6,metadata:[0,6],method:[0,1,3,5,6,7,8,9,10,12],metric:5,minimum:12,minsiz:2,minut:6,missi:6,mkdir:2,mode:0,monitor:4,monoton:10,more:[2,5,6,12],mostli:6,msg:[0,2,6],msisdn:0,much:2,must:[1,3,6,7,8,9,10,12],my_app:5,my_client:2,my_config:5,my_naz_cli:[2,5],my_queu:[2,5],my_request:5,my_respons:5,myfil:5,myhook:5,myid12345:5,mykvlogg:5,mylimit:5,mylogg:6,myprometheushook:5,myredisqueu:2,mysmsdb:5,name:[0,5,6],naz:[0,1,3,6,7,8,9,10,11,12],naz_benchmarks_queu:2,nazclienterror:0,nazcodec:4,nazizi:5,ncodec:7,need:[2,5],network:0,next:2,next_sequ:10,none:[0,1,2,3,6,8,9,10,12],not_throttl:12,note:[1,8],notif:[1,5],notifi:6,notset:6,now:2,npi:0,number:[0,1,5,6,8,11,12],object:[0,5,7,11],observ:4,occur:5,ofcours:5,off:2,okai:2,older:1,omit:1,onc:2,one:[1,2,3],onli:[2,5,6,8],option:[1,2,11],order:2,origin:0,other:[1,2,5],ought:10,our:2,out:[0,2,5],outbound:8,outboundqueu:[0,2,5],outgo:5,over:[0,1,5,12],own:[2,5],paramet:[0,1,3,5,6,7,8,9,11,12],parti:5,particular:[1,2,12],pass:[0,2,5],password:[0,2,5],path:2,pdu:[0,3,5],per:[5,6],percent:12,percentag:[5,12],period:[0,5],pid:2,pip:[2,5],place:[2,5],plan:0,port:[0,2],possibl:2,predefin:0,previous:[1,3],print:5,prioriti:0,priority_flag:0,problem:6,prod:2,product:5,prometheu:5,prometheus_cli:5,properti:11,protocol:[0,5],protocol_id:0,purchas:2,purpos:[5,8],put:[1,6,8],put_nowait:5,python3:5,python:[0,1,2,5,6,7],python_path:2,queu:[0,4],queue:[0,2,4,5,12],queue_nam:2,rabbitmq:[2,5],rais:0,rang:[0,5,10],rate:[0,2,4,9,12],ratelimit:[0,4,5],re_establish_conn_bind:0,reach:10,read:[0,5],reader:5,readi:2,real:2,reason:[1,5,12],rebind:0,receipt:0,receipted_message_id:1,receiv:[0,3],receive_data:[0,2,5],recipi:0,reconnect:0,record:[5,6],redi:[2,5],registered_deliveri:0,regul:12,relat:[0,1,2],releas:5,reliabl:1,render:[5,6],replac:[0,2],replace_if_present_flag:0,repli:[5,12],repo:5,represenst:11,request:[0,3,5,9,10,12],requir:[0,5],respect:0,respond:12,respons:[0,2,3,5,10,12],ring:6,round:5,rout:[0,5],run:[0,2,5],run_forev:5,run_until_complet:[0,2,5],sai:5,said:0,same:[0,7],sample_s:[5,12],sampling_period:[5,12],san:5,satisfi:[1,2,3,5,6,7,8,9,10,12],save:8,schedul:0,schedule_delivery_tim:0,scheme:7,sdk:5,second:[0,1,5,6,9,12],see:[2,3,10],self:[1,2,3,5,10,12],send:[0,2,3,5,9,12],send_data:[0,2],send_messag:2,send_messsag:9,send_rat:[5,9],send_request:2,sender:0,sens:5,sent:[0,2,3],sentri:5,sentry_sdk:5,sequenc:[0,1,4],sequence_gener:0,sequence_numb:[0,1,10],sequence_number1:1,serv:0,server:[0,2,5,9],servic:[0,5],service_typ:0,session:[0,11],set:[2,5,6,7],setformatt:[5,6],setlevel:[5,6],setmessagestatehook:5,setup:5,ship:[2,5],shoe:2,short_messag:[0,2,5],should:[0,1,2,3,5,6,7,8,9,10,12],shouldflush:6,show:[2,5],shown:[1,3,6,7,8,9,10,12],shutdown:0,signal:0,signatur:[1,3,6,7,8,9,10,12],signifi:0,simpl:[1,5],simplecorrelat:1,simplehook:[3,5],simplelogg:6,simplenazcodec:7,simpleoutboundqueu:[0,5,8],simpleratelimit:[5,9],simplesequencegener:10,simplethrottlehandl:[5,12],simul:[2,5],singl:0,size:8,sleep:2,sm_default_msg_id:0,sme:0,smpp:[0,1,2,5,7,10,11,12],smpp_command:[0,1,2,3,5],smpp_server:2,smppclient1:[0,2,5],smppcommand:[5,11],smppcommandstatu:11,smppdatacod:11,smppoptionaltag:11,smppsessionst:11,smsc:[0,1,2,3,5,9,12],smsc_host:[0,2,5],smsc_message_id1:1,smsc_message_id:1,smsc_port:[0,2,5],smsc_respons:[],smstabl:5,socket:0,socket_timeout:0,softwar:2,some:0,someth:6,sometim:5,sourc:[0,1,3,6,7,8,9,10,11,12],source_addr:[0,2,5],source_addr_npi:0,source_addr_ton:0,specif:[0,10],specifi:[1,5,9],sql:5,sqlite3:5,stage:2,standard:7,standardconnectionhandl:2,start:[0,2,5,12],state:[0,2,3,4,5],statehook:5,statement:[0,6],statu:[0,3,5,11,12],status:11,stderr:6,stdlib:6,stdout:6,stop:5,storag:1,store:[0,1,2,6],stored_at:1,str:[0,1,3,5,6,7],stream:6,streamhandl:[5,6],streamread:0,streamwrit:0,strict:0,string:[0,1,3,5,7],string_to_encod:7,structur:6,style:5,submit:[0,2],submit_sm:[0,1,2,3,5],submit_sm_resp:[1,2,3],success:2,suppli:[1,3,5,6],support:[0,5],suppos:5,surpass:5,system:0,system_id:[0,2,5],system_typ:0,tabl:5,tag:[1,11],take:[2,5],taken:6,talk:[2,5],target:6,task:[0,5],termin:[0,5],test:[0,5,8],than:[1,5,12],thank:2,thei:[2,6],them:0,thi:[0,1,2,3,5,6,7,8,9,10,12],thing:2,third:5,those:5,throparserttl:0,throtll:[5,12],throttl:[0,2,4],throttle_delai:12,throttle_handl:[0,5],throttle_wait:12,throttler:5,through:[0,2],thu:[5,12],time:[0,1,12],timeout:2,timestamp:2,tmp:[2,5],to_smsc:[3,5],todo:0,token:[5,9],total:[5,12],track:[1,2,3],tracker:4,tracking_cod:2,tranceiv:[0,5],tranceiver_bind:[0,5],transceiv:0,transfer:5,trigger:6,trigger_level:[],tupl:[0,1,11],tweet:6,two:5,type:[0,1,3,6,7,8,9,10,12],typic:2,ultim:6,unbind:[0,5],unbind_resp:0,under:[5,12],union:[0,1,6],uniqu:[0,1,6],updat:5,upto:5,url:6,usag:[2,4,6,7,9],use:[1,2,5,6],used:[0,2,5,6,7,8],user:[0,1,3,6,7,8,9,10,12],uses:[0,1,5,7],using:[0,1,4,5,9],usual:[5,7],utf8:7,utf:7,valid:0,validity_period:0,valu:[1,5,6,11],variou:[0,2,11],version:[0,2,5,7],via:[0,5,12],wai:[2,5,6,12],wait:[0,2,12],want:[1,2,3,5,6],watch:5,web_request:6,wether:12,what:[0,2,5],whatev:[5,12],when:[0,2,3,5,6,10,12],whenev:[5,6],where:[2,5],wherea:2,whether:[0,2,6],which:[0,2,5,9,10,11,12],who:2,wikipedia:5,wire:0,work:[5,12],world:5,would:[0,5],wrap:[1,10],write:[0,5],writer:5,www:6,you:[0,2,5,6,9],your:[2,5],your_sentry_project_id:5,your_sentry_public_kei:5},titles:["Client","correlater","Example demo of using naz","hooks","naz - naz is an async SMPP client.","Introduction to naz","log","nazcodec","queue","ratelimiter","sequence","state","throttle"],titleterms:{api:4,app:5,async:[4,5],benchmark:5,bug:5,cli:5,client:[0,4],content:4,correlat:1,demo:2,everywher:5,exampl:2,featur:5,handl:5,hook:[3,5],instal:5,integr:5,introduct:5,librari:5,limit:5,log:[5,6],logger:[],monitor:5,naz:[2,4,5],nazcodec:7,observ:5,queu:5,queue:8,rate:5,ratelimit:9,refer:4,sequenc:10,smpp:4,state:11,throttl:[5,12],tracker:5,usag:5,using:2}}) \ No newline at end of file +Search.setIndex({docnames:["client","correlater","example_demo","hooks","index","introduction","log","nazcodec","queue","ratelimiter","sequence","state","throttle"],envversion:{"sphinx.domains.c":1,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":1,"sphinx.domains.javascript":1,"sphinx.domains.math":2,"sphinx.domains.python":1,"sphinx.domains.rst":1,"sphinx.domains.std":1,"sphinx.ext.todo":2,"sphinx.ext.viewcode":1,sphinx:56},filenames:["client.rst","correlater.rst","example_demo.rst","hooks.rst","index.rst","introduction.rst","log.rst","nazcodec.rst","queue.rst","ratelimiter.rst","sequence.rst","state.rst","throttle.rst"],objects:{"naz.client":{Client:[0,1,1,""],NazClientError:[0,3,1,""]},"naz.client.Client":{__init__:[0,2,1,""],command_handlers:[0,2,1,""],connect:[0,2,1,""],deliver_sm_resp:[0,2,1,""],dequeue_messages:[0,2,1,""],enquire_link:[0,2,1,""],enquire_link_resp:[0,2,1,""],re_establish_conn_bind:[0,2,1,""],receive_data:[0,2,1,""],send_data:[0,2,1,""],shutdown:[0,2,1,""],submit_sm:[0,2,1,""],tranceiver_bind:[0,2,1,""],unbind:[0,2,1,""],unbind_resp:[0,2,1,""]},"naz.correlater":{BaseCorrelater:[1,1,1,""],SimpleCorrelater:[1,1,1,""]},"naz.correlater.BaseCorrelater":{get:[1,2,1,""],put:[1,2,1,""]},"naz.correlater.SimpleCorrelater":{__init__:[1,2,1,""],delete_after_ttl:[1,2,1,""],get:[1,2,1,""],put:[1,2,1,""]},"naz.hooks":{BaseHook:[3,1,1,""],SimpleHook:[3,1,1,""]},"naz.hooks.BaseHook":{from_smsc:[3,2,1,""],to_smsc:[3,2,1,""]},"naz.hooks.SimpleHook":{__init__:[3,2,1,""],from_smsc:[3,2,1,""],to_smsc:[3,2,1,""]},"naz.log":{BaseLogger:[6,1,1,""],BreachHandler:[6,1,1,""],SimpleLogger:[6,1,1,""]},"naz.log.BaseLogger":{bind:[6,2,1,""],log:[6,2,1,""]},"naz.log.BreachHandler":{__init__:[6,2,1,""],shouldFlush:[6,2,1,""]},"naz.log.SimpleLogger":{__init__:[6,2,1,""],bind:[6,2,1,""],log:[6,2,1,""]},"naz.nazcodec":{BaseNazCodec:[7,1,1,""],SimpleNazCodec:[7,1,1,""]},"naz.nazcodec.BaseNazCodec":{decode:[7,2,1,""],encode:[7,2,1,""]},"naz.nazcodec.SimpleNazCodec":{decode:[7,2,1,""],encode:[7,2,1,""]},"naz.q":{BaseOutboundQueue:[8,1,1,""],SimpleOutboundQueue:[8,1,1,""]},"naz.q.BaseOutboundQueue":{dequeue:[8,2,1,""],enqueue:[8,2,1,""]},"naz.q.SimpleOutboundQueue":{__init__:[8,2,1,""],dequeue:[8,2,1,""],enqueue:[8,2,1,""]},"naz.ratelimiter":{BaseRateLimiter:[9,1,1,""],SimpleRateLimiter:[9,1,1,""]},"naz.ratelimiter.BaseRateLimiter":{limit:[9,2,1,""]},"naz.ratelimiter.SimpleRateLimiter":{__init__:[9,2,1,""],limit:[9,2,1,""]},"naz.sequence":{BaseSequenceGenerator:[10,1,1,""],SimpleSequenceGenerator:[10,1,1,""]},"naz.sequence.BaseSequenceGenerator":{next_sequence:[10,2,1,""]},"naz.sequence.SimpleSequenceGenerator":{__init__:[10,2,1,""],next_sequence:[10,2,1,""]},"naz.state":{CommandStatus:[11,1,1,""],DataCoding:[11,1,1,""],SmppCommand:[11,1,1,""],SmppCommandStatus:[11,1,1,""],SmppDataCoding:[11,1,1,""],SmppOptionalTag:[11,1,1,""],SmppSessionState:[11,1,1,""]},"naz.state.CommandStatus":{code:[11,2,1,""],description:[11,2,1,""],value:[11,2,1,""]},"naz.state.DataCoding":{code:[11,2,1,""],description:[11,2,1,""],value:[11,2,1,""]},"naz.throttle":{BaseThrottleHandler:[12,1,1,""],SimpleThrottleHandler:[12,1,1,""]},"naz.throttle.BaseThrottleHandler":{allow_request:[12,2,1,""],not_throttled:[12,2,1,""],throttle_delay:[12,2,1,""],throttled:[12,2,1,""]},"naz.throttle.SimpleThrottleHandler":{__init__:[12,2,1,""],allow_request:[12,2,1,""],not_throttled:[12,2,1,""],throttle_delay:[12,2,1,""],throttled:[12,2,1,""]},naz:{client:[0,0,0,"-"],correlater:[1,0,0,"-"],hooks:[3,0,0,"-"],log:[6,0,0,"-"],nazcodec:[7,0,0,"-"],q:[8,0,0,"-"],ratelimiter:[9,0,0,"-"],sequence:[10,0,0,"-"],state:[11,0,0,"-"],throttle:[12,0,0,"-"]}},objnames:{"0":["py","module","Python module"],"1":["py","class","Python class"],"2":["py","method","Python method"],"3":["py","exception","Python exception"]},objtypes:{"0":"py:module","1":"py:class","2":"py:method","3":"py:exception"},terms:{"0r5nd6bsd3g4atwux":2,"16be":7,"20min":5,"2billion":1,"7wjf935mqgsjplq7e":2,"\u03c3cmt":2,"\u30c4":5,"abstract":[1,3,6,7,8,9,10,12],"byte":[0,3,7],"class":[0,1,2,3,5,6,7,8,9,10,11,12],"default":[5,6],"final":5,"float":[0,1,6,9,12],"function":0,"h\u00fclk":7,"import":[0,2,5,6,9,12],"int":[0,1,6,8,10],"long":[2,5,12],"return":[0,1,2,3,5,6,7,8,9,10,12],"short":[0,5],"true":2,"try":5,"while":[0,2],"zo\u00e3":7,"zo\u00eb":7,AND:12,AWS:2,And:[2,5],But:2,For:[2,5],One:1,REs:5,SMS:0,SQS:2,That:[0,5],The:[0,1,2,5,6,8,10,12],With:2,__init__:[0,1,2,3,5,6,8,9,10,12],_get_redi:2,_handler:6,_redi:2,abc:[1,3,6,7,8,9,10,12],abil:5,abl:2,about:5,abov:[5,12],accept:2,acct:0,accur:[3,10],acknowledg:0,activ:[0,5],addhandl:[5,6],addit:0,addr_npi:0,addr_ton:0,address:[0,2],address_rang:0,after:[0,1,3,5,12],again:12,agnost:2,aha:6,aioredi:2,algorithm:[5,9],alia:11,all:[0,1,2,5,6],allow:[5,9,10],allow_request:12,alpin:2,also:[0,1,2,5,7,12],altern:6,among:1,ani:[0,1,2,3,5,6,8,12],annot:5,anoth:[1,2,5],anymor:12,anyth:5,api:5,app:[2,4],applic:[0,1,2,3,5],argument:[0,2],around:[1,10],arrang:0,articl:6,artist:5,associ:0,async:[0,1,2,3,8,9,12],asynchron:0,asyncio:[0,2,5],authent:0,auto:1,avail:2,await:[2,5,9],awesom:2,awesomestor:2,b526gdnxfbf8sqlzz:2,backward:5,band:5,base:[0,1,3,6,7,8,9,10,11,12],basecorrelat:[0,1],basehook:[0,3,5],baselogg:[0,5,6],basenazcodec:[0,7],baseoutboundqueu:[0,2,5,8],baseratelimit:[0,5,9],basesequencegener:[0,10],basethrottlehandl:[0,5,12],basi:1,been:[0,2,6],befor:[0,2,3,5,6,12],benchmark:4,best:1,between:[0,1,5],bind:[0,5,6],bind_receiv:0,bind_transceiv:0,bit:[6,7],block:0,bodi:0,body_data:0,bool:[0,6,12],both:2,breachhandl:6,bring:5,broker:2,brpop:2,bucket:[5,9],buffer:[0,6],buffer_s:[],bug:4,busi:2,byte_str:7,calcul:12,call:[0,1,2,3,5,6,7,8,12],can:[0,2,5,6,7,8,9,11],canari:5,capac:6,center:5,certain:6,chang:[2,5],charact:7,check:[0,5,6],choic:[2,5],choos:6,cleanli:0,cli:[2,4],client:[2,5,6,9,12],client_id:[0,2,5],close:[5,6],cmt:0,code:[0,2,11],codec:7,codec_class:0,codec_errors_level:0,com:6,come:1,command:[1,2,3,11],command_handl:[0,2],command_statu:2,command_status_valu:0,commandlin:5,commandstatu:[3,11],commit:5,commun:2,compos:5,condit:[6,12],config:5,confirm:2,conn:5,connect:[0,2,5],connection_lost:2,consult:[2,5],consum:5,contain:[2,5],content:5,continu:[0,5],control:[0,5,9],correl:[1,3,10],correlat:4,correlatinid:5,correlation_handl:0,could:6,counter:5,creat:[2,5],create_redis_pool:2,cthank:2,current:[2,5],cursor:5,custom:[2,5,9],customer_id:6,damn:6,data:[0,3,5,11],databas:5,datacod:11,debug:[5,6],decid:[5,6,12],decis:12,declar:0,decod:[0,2,7],def:[2,5],defin:[0,7],delet:1,delete_after_ttl:1,deliv:5,deliver_sm:[1,5],deliver_sm_resp:0,deliveri:[0,1,5],demo:[4,5,8],demo_naz:2,deni:[5,12],deny_request_at:[5,12],depend:5,dequed_item:2,dequeu:[0,2,5,8],dequeue_messag:[0,2,5],deriv:5,descript:[5,11],design:[0,5],dest_addr_npi:0,dest_addr_ton:0,destin:0,destination_addr:[0,2,5],determin:12,develop:[2,5,6],diagnost:6,dict:[0,6,8],dictionari:[1,5],did:6,differ:[0,1,3],directori:[2,5],doc:5,docker:[2,5],document:[2,5],doe:[0,5,6,9,12],domain:0,done:[1,2],dot:2,down:0,drain_dur:0,dry:2,dump:2,durat:[0,12],each:5,effort:1,elliot:6,els:2,emit:6,emoji:5,empti:2,enabl:[6,12],encod:[0,7,11],encoding1:0,end:2,enqueu:[0,2,5,8],enquire_link:[0,5],enquire_link_interv:0,enquire_link_resp:0,entiti:5,environ:5,error:[0,5,6,7],esm:[0,5],esm_class:0,esme_rmsgq:12,esme_rthrottl:5,etc:[2,6,7],even:[5,6],event:[2,5,6],everi:6,everytim:[6,12],everywher:4,exampl:[0,4,5,6,7,9],example_config:5,examplequeu:5,exce:12,exceed:6,except:[0,5,6],execut:[2,5],exist:0,exit:2,expect:2,expir:1,extern:5,fals:[0,2,6,12],featur:[1,4],field:[0,11],file:[2,5,6],flag:0,flow:0,flush:6,flushlevel:6,flushonclos:6,follow:5,forc:2,format:[2,5],formatt:[5,6],found:5,from:[0,1,2,3,5,6,7,12],from_smsc:[3,5],full:[0,3,12],gatewai:[0,5],gather:[0,5],gener:[0,5,10],get:[0,1,2,5,12],get_event_loop:[0,2,5],getenv:0,getlogg:[5,6],give:[2,5],given:[1,6,7],goe:12,going:[1,2],good:[5,6],googl:6,got:[6,12],greater:[5,12],gsm0338:[0,7],gsm:7,guarante:1,had:[1,2,3],hand:0,handl:[2,4,12],handler:[0,5,6,12],happen:5,happili:2,has:5,hasn:6,have:[2,5,12],heartbeat:6,heartbeatinterv:6,hello:5,help:[2,3,10],here:[0,5],higher:6,hip:5,hold:5,hook:[0,2,4],hook_metadata1:1,hook_metadata2:1,hook_metadata:[0,1,3,5],hop:5,host:[0,2,5],houston:6,how:[2,5,12],howev:[1,2],http:[5,6],ident:0,identifi:[0,1],ignor:7,implement:[0,1,2,3,5,6,7,8,9,10,12],implemet:0,implemnet:2,impos:12,inc:5,includ:[0,2,6],incompat:5,increas:10,increment:5,indic:0,info:[0,6],inform:5,inherit:[1,3,6,7,8,9,10,12],init:5,initi:[3,10],inject:5,input:7,inspir:6,instal:[2,4],instanc:[0,2],instantait:2,instanti:[0,2,6],integ:10,integr:4,interact:0,interfac:[1,2,3,5,6,7,8,9,10,12],interface_vers:0,introduct:4,issu:5,item:[0,1,2,5,8],iter:1,its:[0,2],itself:[6,12],jayz:6,join:5,json:[2,5],just:[0,3,5,12],kafka:2,keep:5,kei:[1,5],kenyan:5,klqk248jsk8:2,komuw:2,kvlog:5,kvlogger:5,last:12,later:[0,5],learn:2,least:6,let:[2,5,9],level:[0,5,6],leverag:5,librari:4,like:[0,1,5,6],limit:[0,2,4,9,12],line:2,list:0,listen:[0,2],load:[2,5,12],localhost:2,log:[0,2,3,4],log_data:[5,6],log_id1:1,log_id2:1,log_id:[0,1,2,3,5],log_metadata:[0,5,6],logger:[0,3,5,6,9,12],logger_nam:6,logic:2,loglevel:[0,5,6],look:[1,2,5],loop:[0,2,5],lost:0,lot:2,lpush:2,mai:[1,3,5,9,12],main:2,make:[0,2,5,12],mandat:1,mandatori:5,manner:5,max_ttl:1,maximum:[6,8,9,10],maxsiz:[0,2,5,8],mean:0,mechan:[0,5],memori:[1,6,8],memoryhandl:6,messag:[0,1,2,3,5,6,7,9,12],met:6,metadata:[0,6],method:[0,1,3,5,6,7,8,9,10,12],metric:5,minimum:12,minsiz:2,minut:6,missi:6,mkdir:2,mode:0,monitor:4,monoton:10,more:[2,5,12],mostli:6,msg:[0,2,6],msisdn:0,much:2,must:[1,3,6,7,8,9,10,12],my_app:5,my_client:2,my_config:5,my_naz_cli:[2,5],my_queu:[2,5],my_request:5,my_respons:5,myfil:5,myhook:5,myid12345:5,mykvlogg:5,mylimit:5,mylogg:6,myprometheushook:5,myredisqueu:2,mysmsdb:5,name:[0,5,6],naz:[0,1,3,6,7,8,9,10,11,12],naz_benchmarks_queu:2,nazclienterror:0,nazcodec:4,nazizi:5,ncodec:7,need:[2,5],network:0,next:2,next_sequ:10,none:[0,1,2,3,6,8,9,10,12],not_throttl:12,note:[1,8],notif:[1,5],notifi:6,notset:6,now:2,npi:0,number:[0,1,5,6,8,11,12],object:[0,5,7,11],observ:4,occur:5,ofcours:5,off:2,okai:2,older:1,omit:1,onc:2,one:[1,2,3],onli:[2,5,6,8],option:[1,2,11],order:2,origin:0,other:[1,2,5],ought:10,our:2,out:[0,2,5],outbound:8,outboundqueu:[0,2,5],outgo:5,over:[0,1,5,12],own:[2,5],paramet:[0,1,3,5,6,7,8,9,11,12],parti:5,particular:[1,2,12],pass:[0,2,5],password:[0,2,5],path:2,pdu:[0,3,5],per:[5,6],percent:12,percentag:[5,12],period:[0,5],pid:2,pip:[2,5],place:[2,5],plan:0,port:[0,2],possibl:2,predefin:0,previous:[1,3],print:5,prioriti:0,priority_flag:0,problem:6,prod:2,product:5,prometheu:5,prometheus_cli:5,properti:11,protocol:[0,5],protocol_id:0,purchas:2,purpos:[5,8],put:[1,6,8],put_nowait:5,python3:5,python:[0,1,2,5,6,7],python_path:2,queu:[0,4],queue:[0,2,4,5,12],queue_nam:2,rabbitmq:[2,5],rais:0,rang:[0,5,10],rate:[0,2,4,9,12],ratelimit:[0,4,5],re_establish_conn_bind:0,reach:10,read:[0,5],reader:5,readi:2,real:2,reason:[1,5,12],rebind:0,receipt:0,receipted_message_id:1,receiv:[0,3],receive_data:[0,2,5],recipi:0,reconnect:0,record:[5,6],redi:[2,5],registered_deliveri:0,regul:12,relat:[0,1,2],releas:5,reliabl:1,render:[5,6],replac:[0,2],replace_if_present_flag:0,repli:[5,12],repo:5,represenst:11,request:[0,3,5,9,10,12],requir:[0,5],respect:0,respond:12,respons:[0,2,3,5,10,12],ring:6,round:5,rout:[0,5],run:[0,2,5],run_forev:5,run_until_complet:[0,2,5],sai:5,said:0,same:[0,7],sample_s:[5,12],sampling_period:[5,12],san:5,satisfi:[1,2,3,5,6,7,8,9,10,12],save:8,schedul:0,schedule_delivery_tim:0,scheme:7,sdk:5,second:[0,1,5,6,9,12],see:[2,3,10],self:[1,2,3,5,10,12],send:[0,2,3,5,9,12],send_data:[0,2],send_messag:2,send_messsag:9,send_rat:[5,9],send_request:2,sender:0,sens:5,sent:[0,2,3],sentri:5,sentry_sdk:5,sequenc:[0,1,4],sequence_gener:0,sequence_numb:[0,1,10],sequence_number1:1,serv:0,server:[0,2,5,9],servic:[0,5],service_typ:0,session:[0,11],set:[2,5,6,7],setformatt:[5,6],setlevel:[5,6],setmessagestatehook:5,setup:5,ship:[2,5],shoe:2,short_messag:[0,2,5],should:[0,1,2,3,5,6,7,8,9,10,12],shouldflush:6,show:[2,5],shown:[1,3,6,7,8,9,10,12],shutdown:0,signal:0,signatur:[1,3,6,7,8,9,10,12],signifi:0,simpl:[1,5],simplecorrelat:1,simplehook:[3,5],simplelogg:6,simplenazcodec:7,simpleoutboundqueu:[0,5,8],simpleratelimit:[5,9],simplesequencegener:10,simplethrottlehandl:[5,12],simul:[2,5],singl:0,size:8,sleep:2,sm_default_msg_id:0,sme:0,smpp:[0,1,2,5,7,10,11,12],smpp_command:[0,1,2,3,5],smpp_server:2,smppclient1:[0,2,5],smppcommand:[5,11],smppcommandstatu:11,smppdatacod:11,smppoptionaltag:11,smppsessionst:11,smsc:[0,1,2,3,5,9,12],smsc_host:[0,2,5],smsc_message_id1:1,smsc_message_id:1,smsc_port:[0,2,5],smsc_respons:[],smstabl:5,socket:0,socket_timeout:0,softwar:2,some:0,someth:6,sometim:5,sourc:[0,1,3,6,7,8,9,10,11,12],source_addr:[0,2,5],source_addr_npi:0,source_addr_ton:0,specif:[0,10],specifi:[1,5,9],sql:5,sqlite3:5,stage:2,standard:7,standardconnectionhandl:2,start:[0,2,5,12],state:[0,2,3,4,5],statehook:5,statement:[0,6],statu:[0,3,5,11,12],status:11,stderr:6,stdlib:6,stdout:6,stop:5,storag:1,store:[0,1,2,6],stored_at:1,str:[0,1,3,5,6,7],stream:6,streamhandl:[5,6],streamread:0,streamwrit:0,strict:0,string:[0,1,3,5,7],string_to_encod:7,structur:6,style:5,submit:[0,2],submit_sm:[0,1,2,3,5],submit_sm_resp:[1,2,3],success:2,suppli:[1,3,5,6],support:[0,5],suppos:5,surpass:5,system:0,system_id:[0,2,5],system_typ:0,tabl:5,tag:[1,11],take:[2,5],taken:6,talk:[2,5],target:6,task:[0,5],termin:[0,5],test:[0,5,8],than:[1,5,12],thank:2,thei:[2,6],them:0,thi:[0,1,2,3,5,6,7,8,9,10,12],thing:2,third:5,those:5,throparserttl:0,throtll:[5,12],throttl:[0,2,4],throttle_delai:12,throttle_handl:[0,5],throttle_wait:12,throttler:5,through:[0,2],thu:[5,12],time:[0,1,12],timeout:2,timestamp:2,tmp:[2,5],to_smsc:[3,5],todo:0,token:[5,9],total:[5,12],track:[1,2,3],tracker:4,tracking_cod:2,tranceiv:[0,5],tranceiver_bind:[0,5],transceiv:0,transfer:5,trigger:6,trigger_level:[],tupl:[0,1,11],tweet:6,two:5,type:[0,1,3,6,7,8,9,10,12],typic:2,ultim:6,unbind:[0,5],unbind_resp:0,under:[5,12],union:[0,1,6],uniqu:[0,1,6],updat:5,upto:5,url:6,usag:[2,4,6,7,9],use:[1,2,5,6],used:[0,2,5,6,7,8],user:[0,1,3,6,7,8,9,10,12],uses:[0,1,5,7],using:[0,1,4,5,9],usual:[5,7],utf8:7,utf:7,valid:0,validity_period:0,valu:[1,5,6,11],variou:[0,2,11],version:[0,2,5,7],via:[0,5,12],wai:[2,5,6,12],wait:[0,2,12],want:[1,2,3,5,6],watch:5,web_request:6,wether:12,what:[0,2,5],whatev:[5,12],when:[0,2,3,5,6,10,12],whenev:[5,6],where:[2,5],wherea:2,whether:[0,2,6],which:[0,2,5,9,10,11,12],who:2,wikipedia:5,wire:0,work:[5,12],world:5,would:[0,5],wrap:[1,10],write:[0,5],writer:5,www:6,you:[0,2,5,6,9],your:[2,5],your_sentry_project_id:5,your_sentry_public_kei:5},titles:["Client","correlater","Example demo of using naz","hooks","naz - naz is an async SMPP client.","Introduction to naz","log","nazcodec","queue","ratelimiter","sequence","state","throttle"],titleterms:{api:4,app:5,async:[4,5],benchmark:5,bug:5,cli:5,client:[0,4],content:4,correlat:1,demo:2,everywher:5,exampl:2,featur:5,handl:5,hook:[3,5],instal:5,integr:5,introduct:5,librari:5,limit:5,log:[5,6],logger:[],monitor:5,naz:[2,4,5],nazcodec:7,observ:5,queu:5,queue:8,rate:5,ratelimit:9,refer:4,sequenc:10,smpp:4,state:11,throttl:[5,12],tracker:5,usag:5,using:2}}) \ No newline at end of file diff --git a/naz/log.py b/naz/log.py index b8689137..c2884563 100644 --- a/naz/log.py +++ b/naz/log.py @@ -215,9 +215,9 @@ def __init__( capacity: the maximum number of log records to store in the ring buffer target: the ultimate `log handler `_ that will be used. flushOnClose: whether to flush the buffer when the handler is closed even if the flush level hasn't been exceeded - heartbeatInterval: can be a float or None. If it is an float, then a heartbeat log record will be emitted every :py:attr:`~heartbeatInterval` seconds. + heartbeatInterval: can be a float or None. If it is a float, then a heartbeat log record will be emitted every :py:attr:`~heartbeatInterval` seconds. If it is None(the default), then no heartbeat log record is emitted. - If you do decide to set it, a good value is 1800(ie 30 minutes) or more. + If you do decide to set it, a good value is at least 1800(ie 30 minutes). """ self._validate_args( flushLevel=flushLevel, From 1f8e7de5acaae62cc486272a2c1513eb4cac214e Mon Sep 17 00:00:00 2001 From: komuW Date: Fri, 6 Sep 2019 12:29:22 +0300 Subject: [PATCH 16/18] g --- docs/_modules/naz/log.html | 7 +++---- docs/log.html | 4 ++-- naz/log.py | 7 +++---- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/docs/_modules/naz/log.html b/docs/_modules/naz/log.html index 664f446d..4996f206 100644 --- a/docs/_modules/naz/log.html +++ b/docs/_modules/naz/log.html @@ -368,7 +368,7 @@

    Source code for naz.log

     
    [docs] def __init__( self, flushLevel: int = logging.WARNING, - capacity: int = 10_000, + capacity: int = 1_000, target: logging.Handler = logging.StreamHandler(), flushOnClose: bool = False, heartbeatInterval: typing.Union[None, float] = None, @@ -408,7 +408,7 @@

    Source code for naz.log

                 self.heartbeatInterval = heartbeatInterval  # seconds
                 self._s_time = time.monotonic()
     
    -        self.target.setLevel(logging.DEBUG)
    + self.target.setLevel(logging.DEBUG) # type: ignore
    [docs] def shouldFlush(self, record: logging.LogRecord) -> bool: """ @@ -442,8 +442,7 @@

    Source code for naz.log

                         },
                     }
                 )
    -
    -            self.target.emit(record=record)
    +            self.target.emit(record=record)  # pytype: disable=attribute-error
     
         def _validate_args(
             self,
    diff --git a/docs/log.html b/docs/log.html
    index 12d0968f..5bcb549e 100644
    --- a/docs/log.html
    +++ b/docs/log.html
    @@ -280,7 +280,7 @@
     
     
    -class naz.log.BreachHandler(flushLevel=30, capacity=10000, target=<StreamHandler <stderr> (NOTSET)>, flushOnClose=False, heartbeatInterval=None)[source]
    +class naz.log.BreachHandler(flushLevel=30, capacity=1000, target=<StreamHandler <stderr> (NOTSET)>, flushOnClose=False, heartbeatInterval=None)[source]

    Bases: logging.handlers.MemoryHandler

    This is an implementation of logging.Handler that puts logs in an in-memory ring buffer. When a trigger condition(eg a certain log level) is met; @@ -316,7 +316,7 @@

    -__init__(flushLevel=30, capacity=10000, target=<StreamHandler <stderr> (NOTSET)>, flushOnClose=False, heartbeatInterval=None)[source]
    +__init__(flushLevel=30, capacity=1000, target=<StreamHandler <stderr> (NOTSET)>, flushOnClose=False, heartbeatInterval=None)[source]
    Parameters
      diff --git a/naz/log.py b/naz/log.py index c2884563..58b09168 100644 --- a/naz/log.py +++ b/naz/log.py @@ -204,7 +204,7 @@ class BreachHandler(handlers.MemoryHandler): def __init__( self, flushLevel: int = logging.WARNING, - capacity: int = 10_000, + capacity: int = 1_000, target: logging.Handler = logging.StreamHandler(), flushOnClose: bool = False, heartbeatInterval: typing.Union[None, float] = None, @@ -244,7 +244,7 @@ def __init__( self.heartbeatInterval = heartbeatInterval # seconds self._s_time = time.monotonic() - self.target.setLevel(logging.DEBUG) + self.target.setLevel(logging.DEBUG) # type: ignore def shouldFlush(self, record: logging.LogRecord) -> bool: """ @@ -278,8 +278,7 @@ def _heartbeat(self): }, } ) - - self.target.emit(record=record) + self.target.emit(record=record) # pytype: disable=attribute-error def _validate_args( self, From ee0a81fbdb87cb6c192c2494aa28c231ee6dc44e Mon Sep 17 00:00:00 2001 From: komuW Date: Fri, 6 Sep 2019 12:30:35 +0300 Subject: [PATCH 17/18] g --- docs/_modules/naz/log.html | 1 - naz/log.py | 1 - 2 files changed, 2 deletions(-) diff --git a/docs/_modules/naz/log.html b/docs/_modules/naz/log.html index 4996f206..87b2173e 100644 --- a/docs/_modules/naz/log.html +++ b/docs/_modules/naz/log.html @@ -428,7 +428,6 @@

      Source code for naz.log

               _diff = _now - self._s_time
               if _diff >= self.heartbeatInterval:
                   self._s_time = _now
      -            #  name, level, pathname, lineno, msg, args, exc_info, func=None, sinfo=None, **kwargs
                   # see: https://docs.python.org/3/library/logging.html#logging.LogRecord
                   record = logging.makeLogRecord(
                       {
      diff --git a/naz/log.py b/naz/log.py
      index 58b09168..4d9d376e 100644
      --- a/naz/log.py
      +++ b/naz/log.py
      @@ -264,7 +264,6 @@ def _heartbeat(self):
               _diff = _now - self._s_time
               if _diff >= self.heartbeatInterval:
                   self._s_time = _now
      -            #  name, level, pathname, lineno, msg, args, exc_info, func=None, sinfo=None, **kwargs
                   # see: https://docs.python.org/3/library/logging.html#logging.LogRecord
                   record = logging.makeLogRecord(
                       {
      
      From 81bb679487e0ea7eff5155336309c97f23801acd Mon Sep 17 00:00:00 2001
      From: komuW 
      Date: Fri, 6 Sep 2019 12:38:56 +0300
      Subject: [PATCH 18/18] g
      
      ---
       tests/test_logger.py | 28 ++++++++++++++++++++++++++++
       1 file changed, 28 insertions(+)
      
      diff --git a/tests/test_logger.py b/tests/test_logger.py
      index 37db4f95..b93f1a86 100644
      --- a/tests/test_logger.py
      +++ b/tests/test_logger.py
      @@ -217,3 +217,31 @@ def test_heartbeat_exceeded(self):
               logger.log(level=logging.INFO, log_data={"song_id": 543, "name": "Zion"})
               self.assertIn("naz.BreachHandler.heartbeat", self._temp_stream.getvalue())
               self.assertIn(str(heartbeatInterval), self._temp_stream.getvalue())
      +
      +    def test_after_flush_buffer_is_empty(self):
      +        _handler = naz.log.BreachHandler(
      +            capacity=3, target=logging.StreamHandler(stream=self._temp_stream)
      +        )
      +        logger = naz.log.SimpleLogger("test_after_flush_buffer_is_empty", handler=_handler)
      +        logger.bind(level="INFO", log_metadata={"name": "JayZ"})
      +
      +        # log at level less than `_handler.trigger_level`
      +        logger.log(level=logging.INFO, log_data={"trace_id": 781125213295, "one": 1})
      +        logger.log(level=logging.INFO, log_data={"trace_id": 781125213295, "two": 2})
      +        logger.log(level=logging.INFO, log_data={"trace_id": 781125213295, "three": 3})
      +        # assert buffer has items
      +        self.assertEqual(len(_handler.buffer), 3)
      +
      +        # log at level greater than or equal to `_handler.trigger_level`
      +        logger.log(level=logging.WARN, log_data={"trace_id": 781125213295, "four": 7})
      +
      +        # assert everything in the buffer after trigger level is reached
      +        # is flushed to `_handler.stream`
      +        self.assertIn("two", self._temp_stream.getvalue())
      +        self.assertIn("three", self._temp_stream.getvalue())
      +        self.assertIn("four", self._temp_stream.getvalue())
      +        self.assertIn(str(781125213295), self._temp_stream.getvalue())
      +
      +        # assert buffer is cleared after flushing
      +        self.assertEqual(len(_handler.buffer), 0)
      +        self.assertEqual(_handler.buffer, [])