diff options
Diffstat (limited to 'doctor_tests/consumer')
-rw-r--r-- | doctor_tests/consumer/__init__.py | 2 | ||||
-rw-r--r-- | doctor_tests/consumer/base.py | 9 | ||||
-rw-r--r-- | doctor_tests/consumer/sample.py | 4 |
3 files changed, 13 insertions, 2 deletions
diff --git a/doctor_tests/consumer/__init__.py b/doctor_tests/consumer/__init__.py index 2c66a547..e5a36506 100644 --- a/doctor_tests/consumer/__init__.py +++ b/doctor_tests/consumer/__init__.py @@ -21,7 +21,7 @@ OPTS = [ help='the ip of consumer', required=True), cfg.IntOpt('port', - default='12346', + default=12346, help='the port of doctor consumer', required=True), ] diff --git a/doctor_tests/consumer/base.py b/doctor_tests/consumer/base.py index b6c4b34e..e21b0802 100644 --- a/doctor_tests/consumer/base.py +++ b/doctor_tests/consumer/base.py @@ -16,6 +16,15 @@ class BaseConsumer(object): def __init__(self, conf, log): self.conf = conf self.log = log + self._notified_time = None + + @property + def notified_time(self): + return self._notified_time + + @notified_time.setter + def notified_time(self, notified_time): + self._notified_time = notified_time @abc.abstractmethod def start(self): diff --git a/doctor_tests/consumer/sample.py b/doctor_tests/consumer/sample.py index eaf5fabd..c7dcf4f9 100644 --- a/doctor_tests/consumer/sample.py +++ b/doctor_tests/consumer/sample.py @@ -54,7 +54,9 @@ class ConsumerApp(Thread): @app.route('/failure', methods=['POST']) def event_posted(): - self.log.info('doctor consumer notified at %s' % time.time()) + notified_time = time.time() + self.log.info('doctor consumer notified at %s' % notified_time) + self.consumer.notified_time = notified_time data = json.loads(request.data.decode('utf8')) self.log.info('sample consumer received data = %s' % data) return 'OK' |