Esempio n. 1
0
    def reload(self):
        tyk.log("Reloading event handlers and middlewares.", "info")

        self.purge_event_handlers()
        self.load_event_handlers()

        self.load_middlewares()
Esempio n. 2
0
 def purge_middlewares(self):
     tyk.log( "Purging middlewares.", "debug" )
     available_modules = self.get_modules(self.middleware_path)
     for middleware in self.middlewares:
         if not middleware.filepath in available_modules:
             tyk.log( "Purging middleware: '{0}'".format(middleware.filepath), "warning" )
             self.middlewares.remove(middleware)
Esempio n. 3
0
    def reload(self):
        tyk.log( "Reloading event handlers and middlewares.", "info" )

        self.purge_event_handlers()
        self.load_event_handlers()

        self.purge_middlewares()
        self.load_middlewares()
Esempio n. 4
0
 def purge_middlewares(self):
     tyk.log("Purging middlewares.", "debug")
     available_modules = self.get_modules(self.middleware_path)
     for middleware in self.middlewares:
         if not middleware.filepath in available_modules:
             tyk.log(
                 "Purging middleware: '{0}'".format(middleware.filepath),
                 "warning")
             self.middlewares.remove(middleware)
Esempio n. 5
0
 def load_middlewares(self):
     tyk.log("Loading middlewares.", "debug")
     available_modules = self.get_modules(self.middleware_path)
     for module_name in available_modules:
         middleware = self.find_middleware(module_name)
         if middleware:
             middleware.reload()
         else:
             middleware = TykMiddleware(module_name)
             self.middlewares.append(middleware)
     self.update_hook_table()
Esempio n. 6
0
 def load_middlewares(self):
     tyk.log( "Loading middlewares.", "debug" )
     available_modules = self.get_modules(self.middleware_path)
     for module_name in available_modules:
         middleware = self.find_middleware(module_name)
         if middleware:
             middleware.reload()
         else:
             middleware = TykMiddleware(module_name)
             self.middlewares.append(middleware)
     self.update_hook_table()
Esempio n. 7
0
    def __init__(self, middleware_path, event_handler_path, bundle_paths):
        tyk.log("Initializing dispatcher", "info")
        self.event_handler_path = path.join(event_handler_path, '*.py')
        self.event_handlers = {}
        self.load_event_handlers()

        self.middleware_path = path.join(middleware_path, '*.py')

        self.bundle_paths = bundle_paths.split(":")

        self.middlewares = []
        self.hook_table = {}
Esempio n. 8
0
    def __init__(self, middleware_path, event_handler_path, bundle_paths):
        tyk.log( "Initializing dispatcher", "info" )
        self.event_handler_path = path.join(event_handler_path, '*.py')
        self.event_handlers = {}
        self.load_event_handlers()

        self.middleware_path = path.join(middleware_path, '*.py')

        self.bundle_paths = bundle_paths.split(":")

        self.middlewares = []
        self.hook_table = {}
Esempio n. 9
0
 def dispatch_hook(self, object_msg):
     try:
         object = TykCoProcessObject(object_msg)
         middleware, hook_handler = self.find_hook_by_name(object.hook_name)
         if hook_handler:
             object = middleware.process(hook_handler, object)
         else:
             tyk.log( "Can't dispatch '{0}', hook is not defined.".format(object.hook_name), "error")
         return object.dump()
     except:
         tyk.log_error( "Can't dispatch, error:" )
         return object_msg
Esempio n. 10
0
 def dispatch_hook(self, object_msg):
     try:
         object = TykCoProcessObject(object_msg)
         api_id = object.spec['APIID']
         middleware, hook_handler = self.find_hook(api_id, object.hook_name)
         if hook_handler:
             object = middleware.process(hook_handler, object)
         else:
             tyk.log( "Can't dispatch '{0}', hook is not defined.".format(object.hook_name), "error")
         return object.dump()
     except:
         tyk.log_error( "Can't dispatch, error:" )
         return object_msg
Esempio n. 11
0
    def dispatch_hook(self, object_msg):
        try:
            object = TykCoProcessObject(object_msg)
            middleware, hook_handler = self.find_hook_by_name(object.hook_name)
            if hook_handler:
                object = middleware.process(hook_handler, object)
            else:
                tyk.log(
                    "Can't dispatch '{0}', hook is not defined.".format(
                        object.hook_name), "error")
            return object.dump()
        except:
            exc_trace = traceback.format_exc()
            print(exc_trace)
            tyk.log_error("Can't dispatch, error:")

            return object_msg
Esempio n. 12
0
 def reload(self):
     tyk.log("Reloading event handlers and middlewares.", "info")
Esempio n. 13
0
 def __init__(self, bundle_root_path):
     tyk.log("Initializing dispatcher", "info")
     self.bundle_root_path = bundle_root_path
     self.bundles = []
     self.hook_table = {}
Esempio n. 14
0
 def purge_event_handlers(self):
     tyk.log( "Purging event handlers.", "debug" )
     self.event_handlers = []
Esempio n. 15
0
 def load_event_handlers(self):
     tyk.log( "Loading event handlers.", "debug" )
     for module_name in self.get_modules(self.event_handler_path):
         event_handlers = TykEventHandler.from_module(module_name)
         for event_handler in event_handlers:
             self.event_handlers[event_handler.name] = event_handler
Esempio n. 16
0
 def purge_event_handlers(self):
     tyk.log("Purging event handlers.", "debug")
     self.event_handlers = []
Esempio n. 17
0
 def load_event_handlers(self):
     tyk.log("Loading event handlers.", "debug")
     for module_name in self.get_modules(self.event_handler_path):
         event_handlers = TykEventHandler.from_module(module_name)
         for event_handler in event_handlers:
             self.event_handlers[event_handler.name] = event_handler