blob: 2b338df2c866bb2e1a5c6ab22a34d93dd0b19f3b [file] [log] [blame]
tierno5c012612018-04-19 16:01:59 +02001
tierno3054f782018-04-25 16:59:53 +02002# import asyncio
tierno5c012612018-04-19 16:01:59 +02003from http import HTTPStatus
4
5__author__ = "Alfonso Tierno <alfonso.tiernosepulveda@telefonica.com>"
6
7
8class MsgException(Exception):
9 """
10 Base Exception class for all msgXXXX exceptions
11 """
12
tiernoa4eaefe2018-06-20 17:37:17 +020013 def __init__(self, message, http_code=HTTPStatus.SERVICE_UNAVAILABLE):
tierno5c012612018-04-19 16:01:59 +020014 """
15 General exception
16 :param message: descriptive text
17 :param http_code: <http.HTTPStatus> type. It contains ".value" (http error code) and ".name" (http error name
18 """
19 self.http_code = http_code
20 Exception.__init__(self, "messaging exception " + message)
21
22
23class MsgBase(object):
24 """
25 Base class for all msgXXXX classes
26 """
27
28 def __init__(self):
29 pass
30
31 def connect(self, config):
32 pass
33
34 def disconnect(self):
35 pass
36
37 def write(self, topic, key, msg):
tiernoebbf3532018-05-03 17:49:37 +020038 raise MsgException("Method 'write' not implemented")
tierno5c012612018-04-19 16:01:59 +020039
40 def read(self, topic):
tiernoebbf3532018-05-03 17:49:37 +020041 raise MsgException("Method 'read' not implemented")
tierno5c012612018-04-19 16:01:59 +020042
43 async def aiowrite(self, topic, key, msg, loop):
tiernoebbf3532018-05-03 17:49:37 +020044 raise MsgException("Method 'aiowrite' not implemented")
tierno5c012612018-04-19 16:01:59 +020045
46 async def aioread(self, topic, loop):
tiernoebbf3532018-05-03 17:49:37 +020047 raise MsgException("Method 'aioread' not implemented")