def reload(self): tyk.log("Reloading event handlers and middlewares.", "info") self.purge_event_handlers() self.load_event_handlers() self.load_middlewares()
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)
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()
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)
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()
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()
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 = {}
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 = {}
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
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
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
def reload(self): tyk.log("Reloading event handlers and middlewares.", "info")
def __init__(self, bundle_root_path): tyk.log("Initializing dispatcher", "info") self.bundle_root_path = bundle_root_path self.bundles = [] self.hook_table = {}
def purge_event_handlers(self): tyk.log( "Purging event handlers.", "debug" ) self.event_handlers = []
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
def purge_event_handlers(self): tyk.log("Purging event handlers.", "debug") self.event_handlers = []
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