# Path: pq/utils/serializers.py
# class Message(metaclass=MessageMetaClass):
#     id = None
#     """Message ID - all messages should have one"""
# 
#     @classmethod
#     def consumer(cls):
#         pass
# 
#     def get(self, name):
#         return self.__dict__.get(name)
# 
#     def tojson(self):
#         '''A serializable dictionary
#         '''
#         data = self.__dict__.copy()
#         data['type'] = self.type
#         return data


from pulsar.api import PulsarException
from pulsar.utils.log import LazyString
from ..utils.serializers import Message
from . import states



__all__ = ['TaskError',
           'TaskNotAvailable',
           'TaskTimeout',
           'Task']


class TaskError(PulsarException):
    status = states.FAILURE


class TaskNotAvailable(TaskError):
    MESSAGE = 'Task {0} is not registered'

    def __init__(self, task_name):
        self.task_name = task_name
        super().__init__(self.MESSAGE.format(task_name))


class TaskTimeout(TaskError):
    pass



# Path: pq/utils/serializers.py
# class Message(metaclass=MessageMetaClass):
#     id = None
#     """Message ID - all messages should have one"""
# 
#     @classmethod
#     def consumer(cls):
#         pass
# 
#     def get(self, name):
#         return self.__dict__.get(name)
# 
#     def tojson(self):
#         '''A serializable dictionary
#         '''
#         data = self.__dict__.copy()
#         data['type'] = self.type
#         return data


# Path: pq/tasks/task.py
from pulsar.api import PulsarException
from pulsar.utils.log import LazyString
from ..utils.serializers import Message
from . import states




__all__ = ['TaskError',
           'TaskNotAvailable',
           'TaskTimeout',
           'Task']


class TaskError(PulsarException):
    status = states.FAILURE


class TaskNotAvailable(TaskError):
    MESSAGE = 'Task {0} is not registered'

    def __init__(self, task_name):
        self.task_name = task_name
        super().__init__(self.MESSAGE.format(task_name))


class TaskTimeout(TaskError):
    pass



class Task(Message):