# Path: pypipeline/core/Destination.py
# class Destination:
#     def __init__(self, plumber, params):
#         self.plumber = plumber
#         self.params = params
# 
#     def process(self, exchange):
#         raise NotImplementedError("Subclass of destination needs to implement process method")
# 
# Path: pypipeline/core/Processor.py
# class Processor:
#     def __init__(self, obj):
#         self.object = obj
#         self.next = None
# 
#     def process(self, exchange):
#         try:
#             self._process(exchange)
#         except Exception as e:
#             raise e
# 
#     def _process(self, exchange):
#         self.object.process(exchange)
#         if self.next is not None:
#             self.next.process(exchange)
# 
# Path: pypipeline/core/Property.py
# class Property(Enum):
#     slip_endpoint = 1


from pypipeline.core.Destination import Destination
from pypipeline.core.Processor import Processor
from pypipeline.core.Property import Property


class DynamicRouterProcessor(Processor):
    def __init__(self, dynamic_router):
        super().__init__(None)
        self.dynamic_router = dynamic_router

    def _process(self, exchange):
        endpoint = self.dynamic_router.route(exchange)
        while endpoint is not None:
            assert issubclass(endpoint[0], Destination)
            destination = endpoint[0](self.dynamic_router.plumber, endpoint[1])

# Path: pypipeline/core/Destination.py
# class Destination:
#     def __init__(self, plumber, params):
#         self.plumber = plumber
#         self.params = params
# 
#     def process(self, exchange):
#         raise NotImplementedError("Subclass of destination needs to implement process method")
# 
# Path: pypipeline/core/Processor.py
# class Processor:
#     def __init__(self, obj):
#         self.object = obj
#         self.next = None
# 
#     def process(self, exchange):
#         try:
#             self._process(exchange)
#         except Exception as e:
#             raise e
# 
#     def _process(self, exchange):
#         self.object.process(exchange)
#         if self.next is not None:
#             self.next.process(exchange)
# 
# Path: pypipeline/core/Property.py
# class Property(Enum):
#     slip_endpoint = 1


# Path: pypipeline/eip/dynamic_router/DynamicRouterProcessor.py
from pypipeline.core.Destination import Destination
from pypipeline.core.Processor import Processor
from pypipeline.core.Property import Property



class DynamicRouterProcessor(Processor):
    def __init__(self, dynamic_router):
        super().__init__(None)
        self.dynamic_router = dynamic_router

    def _process(self, exchange):
        endpoint = self.dynamic_router.route(exchange)
        while endpoint is not None:
            assert issubclass(endpoint[0], Destination)
            destination = endpoint[0](self.dynamic_router.plumber, endpoint[1])

            destination.process(exchange)