# Path: pylm/parts/messages_pb2.py
# DESCRIPTOR = _descriptor.FileDescriptor(
#   name='messages.proto',
#   package='',
#   syntax='proto3',
#   serialized_pb=_b('\n\x0emessages.proto\"p\n\x0bPalmMessage\x12\x10\n\x08pipeline\x18\x01 \x01(\t\x12\x0e\n\x06\x63lient\x18\x02 \x01(\t\x12\r\n\x05stage\x18\x03 \x01(\x03\x12\x10\n\x08\x66unction\x18\x04 \x01(\t\x12\r\n\x05\x63\x61\x63he\x18\x05 \x01(\t\x12\x0f\n\x07payload\x18\x06 \x01(\x0c\x62\x06proto3')
# )
# _PALMMESSAGE = _descriptor.Descriptor(
#   name='PalmMessage',
#   full_name='PalmMessage',
#   filename=None,
#   file=DESCRIPTOR,
#   containing_type=None,
#   fields=[
#     _descriptor.FieldDescriptor(
#       name='pipeline', full_name='PalmMessage.pipeline', index=0,
#       number=1, type=9, cpp_type=9, label=1,
#       has_default_value=False, default_value=_b("").decode('utf-8'),
#       message_type=None, enum_type=None, containing_type=None,
#       is_extension=False, extension_scope=None,
#       options=None),
#     _descriptor.FieldDescriptor(
#       name='client', full_name='PalmMessage.client', index=1,
#       number=2, type=9, cpp_type=9, label=1,
#       has_default_value=False, default_value=_b("").decode('utf-8'),
#       message_type=None, enum_type=None, containing_type=None,
#       is_extension=False, extension_scope=None,
#       options=None),
#     _descriptor.FieldDescriptor(
#       name='stage', full_name='PalmMessage.stage', index=2,
#       number=3, type=3, cpp_type=2, label=1,
#       has_default_value=False, default_value=0,
#       message_type=None, enum_type=None, containing_type=None,
#       is_extension=False, extension_scope=None,
#       options=None),
#     _descriptor.FieldDescriptor(
#       name='function', full_name='PalmMessage.function', index=3,
#       number=4, type=9, cpp_type=9, label=1,
#       has_default_value=False, default_value=_b("").decode('utf-8'),
#       message_type=None, enum_type=None, containing_type=None,
#       is_extension=False, extension_scope=None,
#       options=None),
#     _descriptor.FieldDescriptor(
#       name='cache', full_name='PalmMessage.cache', index=4,
#       number=5, type=9, cpp_type=9, label=1,
#       has_default_value=False, default_value=_b("").decode('utf-8'),
#       message_type=None, enum_type=None, containing_type=None,
#       is_extension=False, extension_scope=None,
#       options=None),
#     _descriptor.FieldDescriptor(
#       name='payload', full_name='PalmMessage.payload', index=5,
#       number=6, type=12, cpp_type=9, label=1,
#       has_default_value=False, default_value=_b(""),
#       message_type=None, enum_type=None, containing_type=None,
#       is_extension=False, extension_scope=None,
#       options=None),
#   ],
#   extensions=[
#   ],
#   nested_types=[],
#   enum_types=[
#   ],
#   options=None,
#   is_extendable=False,
#   syntax='proto3',
#   extension_ranges=[],
#   oneofs=[
#   ],
#   serialized_start=18,
#   serialized_end=130,
# )


from pylm.parts.messages_pb2 import PalmMessage
from uuid import uuid4
import traceback
import zmq
import sys
                 socket_type,
                 reply=True,
                 broker_address="inproc://broker",
                 bind=False,
                 logger=None,
                 cache=None,
                 messages=sys.maxsize):
        self.name = name.encode('utf-8')
        self.listen_to = zmq_context.socket(socket_type)
        self.bind = bind
        self.listen_address = listen_address
        self.broker = zmq_context.socket(zmq.REP)
        self.broker.identity = self.name
        self.broker.connect(broker_address)
        self.logger = logger
        self.cache = cache
        self.messages = messages
        self.reply = reply
        self.last_message = b''

    def _translate_to_broker(self, message: PalmMessage):
        """
        Translate the message that the component has got to be digestible by
        the broker

        :param message:
        :return:
        """
        return message


# Path: pylm/parts/messages_pb2.py
# DESCRIPTOR = _descriptor.FileDescriptor(
#   name='messages.proto',
#   package='',
#   syntax='proto3',
#   serialized_pb=_b('\n\x0emessages.proto\"p\n\x0bPalmMessage\x12\x10\n\x08pipeline\x18\x01 \x01(\t\x12\x0e\n\x06\x63lient\x18\x02 \x01(\t\x12\r\n\x05stage\x18\x03 \x01(\x03\x12\x10\n\x08\x66unction\x18\x04 \x01(\t\x12\r\n\x05\x63\x61\x63he\x18\x05 \x01(\t\x12\x0f\n\x07payload\x18\x06 \x01(\x0c\x62\x06proto3')
# )
# _PALMMESSAGE = _descriptor.Descriptor(
#   name='PalmMessage',
#   full_name='PalmMessage',
#   filename=None,
#   file=DESCRIPTOR,
#   containing_type=None,
#   fields=[
#     _descriptor.FieldDescriptor(
#       name='pipeline', full_name='PalmMessage.pipeline', index=0,
#       number=1, type=9, cpp_type=9, label=1,
#       has_default_value=False, default_value=_b("").decode('utf-8'),
#       message_type=None, enum_type=None, containing_type=None,
#       is_extension=False, extension_scope=None,
#       options=None),
#     _descriptor.FieldDescriptor(
#       name='client', full_name='PalmMessage.client', index=1,
#       number=2, type=9, cpp_type=9, label=1,
#       has_default_value=False, default_value=_b("").decode('utf-8'),
#       message_type=None, enum_type=None, containing_type=None,
#       is_extension=False, extension_scope=None,
#       options=None),
#     _descriptor.FieldDescriptor(
#       name='stage', full_name='PalmMessage.stage', index=2,
#       number=3, type=3, cpp_type=2, label=1,
#       has_default_value=False, default_value=0,
#       message_type=None, enum_type=None, containing_type=None,
#       is_extension=False, extension_scope=None,
#       options=None),
#     _descriptor.FieldDescriptor(
#       name='function', full_name='PalmMessage.function', index=3,
#       number=4, type=9, cpp_type=9, label=1,
#       has_default_value=False, default_value=_b("").decode('utf-8'),
#       message_type=None, enum_type=None, containing_type=None,
#       is_extension=False, extension_scope=None,
#       options=None),
#     _descriptor.FieldDescriptor(
#       name='cache', full_name='PalmMessage.cache', index=4,
#       number=5, type=9, cpp_type=9, label=1,
#       has_default_value=False, default_value=_b("").decode('utf-8'),
#       message_type=None, enum_type=None, containing_type=None,
#       is_extension=False, extension_scope=None,
#       options=None),
#     _descriptor.FieldDescriptor(
#       name='payload', full_name='PalmMessage.payload', index=5,
#       number=6, type=12, cpp_type=9, label=1,
#       has_default_value=False, default_value=_b(""),
#       message_type=None, enum_type=None, containing_type=None,
#       is_extension=False, extension_scope=None,
#       options=None),
#   ],
#   extensions=[
#   ],
#   nested_types=[],
#   enum_types=[
#   ],
#   options=None,
#   is_extendable=False,
#   syntax='proto3',
#   extension_ranges=[],
#   oneofs=[
#   ],
#   serialized_start=18,
#   serialized_end=130,
# )


# Path: pylm/parts/core.py
from pylm.parts.messages_pb2 import PalmMessage
from uuid import uuid4
import traceback
import zmq
import sys

                 socket_type,
                 reply=True,
                 broker_address="inproc://broker",
                 bind=False,
                 logger=None,
                 cache=None,
                 messages=sys.maxsize):
        self.name = name.encode('utf-8')
        self.listen_to = zmq_context.socket(socket_type)
        self.bind = bind
        self.listen_address = listen_address
        self.broker = zmq_context.socket(zmq.REP)
        self.broker.identity = self.name
        self.broker.connect(broker_address)
        self.logger = logger
        self.cache = cache
        self.messages = messages
        self.reply = reply
        self.last_message = b''

    def _translate_to_broker(self, message: PalmMessage):
        """
        Translate the message that the component has got to be digestible by
        the broker

        :param message:
        :return:
        """
        return message


    def _translate_from_broker(self, message: PalmMessage):