[go: up one dir, main page]

CN112988274B - Microservice gateway plug-in dynamic loading method, device, system and storage medium thereof - Google Patents

Microservice gateway plug-in dynamic loading method, device, system and storage medium thereof Download PDF

Info

Publication number
CN112988274B
CN112988274B CN202110318551.2A CN202110318551A CN112988274B CN 112988274 B CN112988274 B CN 112988274B CN 202110318551 A CN202110318551 A CN 202110318551A CN 112988274 B CN112988274 B CN 112988274B
Authority
CN
China
Prior art keywords
plug
gateway
file
filter
instance
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110318551.2A
Other languages
Chinese (zh)
Other versions
CN112988274A (en
Inventor
彭彩和
叶建林
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Dipu Technology Co., Ltd.
Original Assignee
Beijing Deepexi Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Deepexi Technology Co Ltd filed Critical Beijing Deepexi Technology Co Ltd
Priority to CN202110318551.2A priority Critical patent/CN112988274B/en
Publication of CN112988274A publication Critical patent/CN112988274A/en
Application granted granted Critical
Publication of CN112988274B publication Critical patent/CN112988274B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
    • G06F9/44526Plug-ins; Add-ons
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/66Arrangements for connecting between networks having differing types of switching systems, e.g. gateways

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

本发明涉及网络技术领域,具体涉及一种微服务网关插件动态加载方法、装置、系统及其存储介质,其方法包括:对存储管理器进行实时监测,当监测到所述存储管理器中所存储的插件文件发生变更时,获取当前的插件文件;将当前所缓存的插件实例进行释放,然后对当前的插件文件进行实例化,得到新的插件实例并进行缓存;将缓存后的新的插件实例适配成插件过滤器;将所述插件过滤器加入至网关的过滤链中,构建新的过滤链;在本发明不需要重启网关服务就能对网关过滤的需求进行调整,实现了热插拔的功能,其有效地提高用户的使用体验。

Figure 202110318551

The present invention relates to the field of network technology, in particular to a method, device, system and storage medium for dynamic loading of microservice gateway plug-ins. When the plug-in file changes, get the current plug-in file; release the currently cached plug-in instance, and then instantiate the current plug-in file to get a new plug-in instance and cache it; cache the new plug-in instance Adapt to a plug-in filter; add the plug-in filter to the filter chain of the gateway to build a new filter chain; in the present invention, the requirements of gateway filtering can be adjusted without restarting the gateway service, and hot swapping is realized functions, which effectively improve the user experience.

Figure 202110318551

Description

微服务网关插件动态加载方法、装置、系统及其存储介质Microservice gateway plug-in dynamic loading method, device, system and storage medium thereof

技术领域technical field

本发明涉及图像处理技术领域,具体涉及一种微服务网关插件动态加载方法、一种微服务网关插件动态加载装置、一种微服务网关插件动态加载系统以及一种存储有上述方法的可读存储介质。The present invention relates to the technical field of image processing, in particular to a method for dynamically loading a microservice gateway plug-in, a dynamic loading device for a microservice gateway plug-in, a dynamic loading system for a microservice gateway plug-in, and a readable memory storing the above method medium.

背景技术Background technique

随着网络科技的迅速发展,微服务的使用率也越来越高;其中,微服务是一种架构风格,即将单体应用划分为小型的服务单元,而微服务之间使用HTTP的API进行资源访问与操作。在现有的微服务中的客户端和服务器端之间均会设有网关,所有的外部请求都会先经过网关这一层;该网关的作用在微服务中提供统一入口、鉴权校验、动态路由、降低耦合度的功能;而Spring Cloud是一种市面上常用的对微服务架构解决方案的综合套件组件,其中,Spring Cloud Gateway是Spring Cloud中的网关,Gateway在于提供-种简单而有效的方式来对API进行路由,以及提供一些过滤器功能。With the rapid development of network technology, the utilization rate of microservices is also increasing; among them, microservices is an architectural style, which divides a single application into small service units, and the HTTP API is used between microservices. Resource access and manipulation. There will be a gateway between the client and the server in the existing microservice, and all external requests will first pass through the gateway layer; the function of the gateway is to provide unified entry, authentication verification, Functions of dynamic routing and coupling reduction; and Spring Cloud is a comprehensive suite of components commonly used in the market for microservice architecture solutions. Among them, Spring Cloud Gateway is the gateway in Spring Cloud. Gateway is to provide a simple and effective The way to route the API, and provide some filter functions.

在现有的Spring Cloud Gateway中,当用户需要对网关的过滤需求进行调整时,其需要在网关源代码的基础上修改并添加自定义的过滤器类,然后经过编译、打包一系列动作,最后需要通过重启网关服务后才能完成定制需求;故其不支持插件的动态加载和实现热插拔,使得用户不能快速地对网关的过滤需求进行调整,其极大地影响到用户的使用体验。In the existing Spring Cloud Gateway, when users need to adjust the filtering requirements of the gateway, they need to modify and add custom filter classes on the basis of the gateway source code, and then compile and package a series of actions, and finally It is necessary to restart the gateway service to complete the customization requirements; therefore, it does not support dynamic loading and hot swapping of plug-ins, so that users cannot quickly adjust the filtering requirements of the gateway, which greatly affects the user experience.

发明内容Contents of the invention

为克服上述缺陷,本发明的目的即在于提供一种可实现热插拔的微服务网关插件动态加载方法、装置、系统以及存储有其方法的可读存储介质。In order to overcome the above-mentioned defects, the object of the present invention is to provide a method, device, system and readable storage medium storing the method for dynamically loading microservice gateway plug-ins that can realize hot swapping.

本发明的目的是通过以下技术方案来实现的:The purpose of the present invention is achieved through the following technical solutions:

本发明是一种微服务网关插件动态加载方法,其包括:The present invention is a microservice gateway plug-in dynamic loading method, which includes:

对存储管理器进行实时监测,当监测到所述存储管理器中所存储的插件文件发生变更时,获取当前的插件文件;Perform real-time monitoring on the storage manager, and obtain the current plug-in file when the plug-in file stored in the storage manager is detected to be changed;

将当前所缓存的插件实例进行释放,然后对当前的插件文件进行实例化,得到新的插件实例并进行缓存;Release the currently cached plug-in instance, and then instantiate the current plug-in file to obtain a new plug-in instance and cache it;

将缓存后的新的插件实例适配成插件过滤器;Adapt the cached new plug-in instance to a plug-in filter;

将所述插件过滤器加入至网关的过滤链中,构建新的过滤链。The plug-in filter is added to the filter chain of the gateway to construct a new filter chain.

在本发明中,所述监测到所述存储管理器中所存储的插件文件发生变更之前包括:In the present invention, the monitoring includes:

对所述存储管理器中的插件文件进行调整。Make adjustments to the plugin files in the storage manager.

在本发明中,所述对所述存储管理器中的插件文件进行调整包括:In the present invention, said adjusting the plug-in files in the storage manager includes:

对所述存储管理器中的插件文件进行上传、移除、修改。Upload, remove and modify the plug-in files in the storage manager.

在本发明中,所述将所述插件过滤器加入至网关的过滤链中,构建新的过滤链包括:In the present invention, adding the plug-in filter to the filter chain of the gateway, and constructing a new filter chain includes:

将网关中的内置过滤器和所述插件过滤器按照预定的顺序加入到过滤链中,构建新的过滤链。The built-in filter in the gateway and the plug-in filter are added to the filter chain in a predetermined order to construct a new filter chain.

在本发明中,所述当监测到所述存储管理器中所存储的插件文件发生变更时,获取当前的插件文件包括:In the present invention, when it is detected that the plug-in file stored in the storage manager changes, obtaining the current plug-in file includes:

对存储管理器中所存储的插件文件的定义标识进行读取,并判断该定义标识是否发生变更,若发生变更,则判断该插件文件当前所缓存的插件实例中的插件文件是否相同,若不相同,则获取当前的插件文件。Read the definition identifier of the plug-in file stored in the storage manager, and determine whether the definition identifier has changed, and if so, determine whether the plug-in file in the plug-in instance currently cached by the plug-in file is the same, if not same, get the current plugin file.

在本发明中,所述对存储管理器进行实时监测之前包括:In the present invention, the real-time monitoring of the storage manager includes:

接收客户端的访问请求,当该访问请求与网关配置的路由匹配时,执行对存储管理器进行实时监测。Receive the access request from the client, and when the access request matches the route configured by the gateway, perform real-time monitoring on the storage manager.

在本发明中,所述构建新的过滤链之后包括:In the present invention, after the new filter chain is constructed, it includes:

按照新的过滤链将所接收到的访问请求进行过滤,并将过滤后的访问请求发送至服务器端中。The received access requests are filtered according to the new filtering chain, and the filtered access requests are sent to the server.

基于同样的构思,本发明还提供一种微服务网关插件动态加载装置,其包括:Based on the same idea, the present invention also provides a microservice gateway plug-in dynamic loading device, which includes:

存储管理模块,所述存储管理模块用于对插件文件进行管理和存储;A storage management module, the storage management module is used to manage and store plug-in files;

监测管理模块,所述监测管理模块与所述存储管理模块相连接,用于对存储管理模块进行实时监测,当监测到所述存储管理模块中所存储的插件文件发生变更时,获取该存储管理模块中当前的插件文件并驱动实例缓存模块和监测管理模块;并将缓存后的新的插件实例适配成插件过滤器,将所述插件过滤器加入至网关的过滤链中,构建新的过滤链;A monitoring management module, the monitoring management module is connected to the storage management module, and is used for real-time monitoring of the storage management module, and when it is detected that the plug-in files stored in the storage management module are changed, the storage management module is obtained. The current plug-in file in the module drives the instance cache module and the monitoring management module; adapts the cached new plug-in instance to a plug-in filter, adds the plug-in filter to the filter chain of the gateway, and builds a new filter chain;

实例缓存模块,所述实例缓存模块与所述监测管理模块相连接,用于根据所述监测管理模块的驱动将当前所缓存的插件实例进行释放,或将新的插件实例进行缓存;An instance cache module, the instance cache module is connected to the monitoring management module, and is used to release the currently cached plug-in instance or cache a new plug-in instance according to the driver of the monitoring management module;

实例化模块,所述实例化模块分别与实例缓存模块和监测管理模块相连接,用于对监测管理模块所获得的插件文件进行实例化,得到新的插件实例。An instantiation module, the instantiation module is respectively connected with the instance cache module and the monitoring management module, and is used to instantiate the plug-in file obtained by the monitoring management module to obtain a new plug-in instance.

基于同样的构思,本发明还提供一种微服务网关插件动态加载系统,其包括:客户端、服务器端、网关;Based on the same idea, the present invention also provides a microservice gateway plug-in dynamic loading system, which includes: a client, a server, and a gateway;

所述网关设置于所述客户端与服务器端之间,且所述网关中设有如上所述的微服务网关插件动态加载装置。The gateway is set between the client and the server, and the gateway is provided with the above-mentioned microservice gateway plug-in dynamic loading device.

基于同样的构思,本发明还提供一种计算机可读程序存储介质,其存储有计算机程序指令,当所述计算机程序指令被计算机执行时,使计算机执行如上所述的方法。Based on the same idea, the present invention also provides a computer-readable program storage medium, which stores computer program instructions, and when the computer program instructions are executed by a computer, the computer is made to execute the above method.

在本发明的微服务网关插件动态加载方法中,其实时监测插件文件的变更情况,对更新后的插件文件进行实例化后形成新的插件过滤器,对新的插件过滤器进行读取以动态完成插件的加载,故用户不需要重启网关服务就能对网关过滤的需求进行调整,实现了热插拔的功能,其有效地提高用户的使用体验。In the microservice gateway plug-in dynamic loading method of the present invention, it monitors the change of the plug-in file in real time, instantiates the updated plug-in file to form a new plug-in filter, and reads the new plug-in filter to dynamically The loading of the plug-in is completed, so the user can adjust the requirements of the gateway filtering without restarting the gateway service, and realizes the function of hot swapping, which effectively improves the user experience.

附图说明Description of drawings

为了易于说明,本发明由下述的较佳实施例及附图作详细描述。For ease of illustration, the present invention is described in detail by the following preferred embodiments and accompanying drawings.

图1为本发明微服务网关插件动态加载方法一个实施例的工作流程示意图;Fig. 1 is a schematic workflow diagram of an embodiment of the microservice gateway plug-in dynamic loading method of the present invention;

图2为本发明微服务网关插件动态加载方法另一个实施例的工作流程示意图;Fig. 2 is a schematic workflow diagram of another embodiment of the microservice gateway plug-in dynamic loading method of the present invention;

图3为本发明微服务网关插件动态加载装置的逻辑结构示意图;Fig. 3 is a schematic diagram of the logical structure of the microservice gateway plug-in dynamic loading device of the present invention;

图4为本发明微服务网关插件动态加载系统的逻辑结构示意图。Fig. 4 is a schematic diagram of the logical structure of the microservice gateway plug-in dynamic loading system of the present invention.

具体实施方式Detailed ways

为了使本发明的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本发明进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不用于限定本发明。In order to make the object, technical solution and advantages of the present invention more clear, the present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described here are only used to explain the present invention, not to limit the present invention.

在本发明的描述中,需要理解的是,术语“中心”、“纵向”、“横向”、“长度”、“宽度”、“厚度”、“上”、“下”、“前”、“后”、“左”、“右”、“竖直”、“水平”、“顶”、“底”、“内”、“外”、“顺时针”、“逆时针”等指示的方位或位置关系为基于附图所示的方位或位置关系,仅是为了便于描述本发明和简化描述,而不是指示或暗示所指的装置或元件必须具有特定的方位、以特定的方位构造和操作,因此不能理解为对本发明的限制。此外,术语“第一”、“第二”仅用于描述目的,而不能理解为指示或暗示相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括一个或者更多个所述特征。在本发明的描述中,“多个”的含义是两个或两个以上,除非另有明确具体的限定。In describing the present invention, it should be understood that the terms "center", "longitudinal", "transverse", "length", "width", "thickness", "upper", "lower", "front", " Orientation indicated by rear, left, right, vertical, horizontal, top, bottom, inside, outside, clockwise, counterclockwise, etc. The positional relationship is based on the orientation or positional relationship shown in the drawings, which is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the referred device or element must have a specific orientation, be constructed and operated in a specific orientation, Therefore, it should not be construed as limiting the invention. In addition, the terms "first" and "second" are used for descriptive purposes only, and cannot be interpreted as indicating or implying relative importance or implicitly specifying the quantity of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of said features. In the description of the present invention, "plurality" means two or more, unless otherwise specifically defined.

在本发明的描述中,需要说明的是,除非另有明确的规定和限定,术语“安装”、“相连”、“连接”应做广义理解,例如,可以是固定连接,也可以是可拆卸连接,或一体地连接。可以是机械连接,也可以是电连接。可以是直接相连,也可以通过中间媒介间接相连,可以是两个元件内部的连通或两个元件的相互作用关系。对于本领域的普通技术人员而言,可以根据具体情况理解上述术语在本发明中的具体含义。In the description of the present invention, it should be noted that unless otherwise specified and limited, the terms "installation", "connection" and "connection" should be understood in a broad sense, for example, it can be a fixed connection or a detachable connection. connected, or integrally connected. It can be a mechanical connection or an electrical connection. It can be directly connected or indirectly connected through an intermediary, and it can be the internal communication of two elements or the interaction relationship between two elements. Those of ordinary skill in the art can understand the specific meanings of the above terms in the present invention according to specific situations.

下面以一个实施例对本发明的一种Spring Cloud Gateway网关插件动态加载方法进行具体描述,请参阅图1,其包括:A kind of Spring Cloud Gateway gateway plug-in dynamic loading method of the present invention is specifically described below with an embodiment, please refer to Fig. 1, and it comprises:

S101.对存储管理器进行实时监测S101. Real-time monitoring of the storage manager

对存储管理器进行实时监测;其中,该存储管理器中存储有一个以上的插件文件,该插件文件被打包为Jar文件包;在本实施例中其具体为:实时监测存储管理器中的Jar文件包是否有发生变更。The storage manager is monitored in real time; wherein, more than one plug-in file is stored in the storage manager, and the plug-in file is packaged as a Jar file package; in this embodiment, it is specifically: real-time monitoring of the Jar in the storage manager Whether the package has changed.

S102.获取当前的插件文件S102. Get the current plug-in file

当监测到所述存储管理器中所存储的插件文件发生变更时,获取当前的插件文件;其中,该插件文件发生变更包括:有新的Jar文件包上传、Jar文件包被删除、Jar文件包的内容被更改;用户可以根据其具体的过滤需求,对Jar文件包进行调整。When it is detected that the plug-in file stored in the storage manager changes, the current plug-in file is obtained; wherein, the plug-in file changes include: a new Jar file package is uploaded, the Jar file package is deleted, the Jar file package The content of is changed; users can adjust the Jar file package according to their specific filtering requirements.

S103.释放当前的插件实例S103. Release the current plug-in instance

将当前所缓存的插件实例进行释放,在本实施例中,网关中缓存有上次的插件实例,由于后续步骤中需要生成新的插件实例,故本步骤中需要对当前所缓存的插件实例进行释放。Release the currently cached plug-in instance. In this embodiment, the last plug-in instance is cached in the gateway. Since a new plug-in instance needs to be generated in the subsequent steps, the current cached plug-in instance needs to be updated in this step. freed.

S104.对新的插件文件进行实例化S104. Instantiate the new plug-in file

对当前的插件文件进行实例化,得到新的插件实例并进行缓存;其中,实例化是指在面向对象的编程中,把用类创建对象的过程称为实例化;其是将一个抽象的概念类,具体到该类实物的过程。Instantiate the current plug-in file, get a new plug-in instance and cache it; among them, instantiation refers to the process of creating an object with a class in object-oriented programming. It is an abstract concept Class, the process specific to the object of this class.

S105.将新的插件实例适配成插件过滤器S105. Adapt the new plug-in instance to a plug-in filter

将缓存后的新的插件实例适配成插件过滤器,同时,将所有插件过滤器收集起来,供构建过滤器链时使用;Adapt the cached new plug-in instance into a plug-in filter, and at the same time, collect all plug-in filters for use when building a filter chain;

S106.构建新的过滤链S106. Build a new filtering chain

将所述插件过滤器加入至网关的过滤链中,构建新的过滤链;故网关可在不重启的情况下根据其新的过滤链执行过滤请求。The plug-in filter is added to the filter chain of the gateway to construct a new filter chain; therefore, the gateway can execute the filter request according to its new filter chain without restarting.

下面以另一个实施例对本发明的一种Spring Cloud Gateway网关插件动态加载方法进行具体描述,请参阅图2,其包括:A kind of Spring Cloud Gateway gateway plug-in dynamic loading method of the present invention is described in detail with another embodiment below, please refer to Fig. 2, and it comprises:

S201.接收客户端的访问请求S201. Receive an access request from the client

接收客户端的访问请求,当该访问请求与网关配置的路由匹配时,执行对存储管理器进行实时监测。Receive the access request from the client, and when the access request matches the route configured by the gateway, perform real-time monitoring on the storage manager.

S202.对插件文件进行调整S202. Adjust the plug-in file

对所述存储管理器中的插件文件进行调整;具体地,对所述存储管理器中的插件文件进行上传、移除、修改。Adjust the plug-in files in the storage manager; specifically, upload, remove, and modify the plug-in files in the storage manager.

S203.对存储管理器进行实时监测S203. Real-time monitoring of the storage manager

对存储管理器进行实时监测;其中,该存储管理器中存储有一个以上的插件文件,该插件文件被打包为Jar文件包,且该插件文件中设有定义标识;在本实施例中其具体为:实时监测存储管理器中的Jar文件包是否有发生变更。The storage manager is monitored in real time; wherein, more than one plug-in file is stored in the storage manager, the plug-in file is packaged as a Jar file package, and the plug-in file is provided with a definition mark; in this embodiment, its specific For: to monitor in real time whether the Jar file package in the storage manager has changed.

S204.获取当前的插件文件S204. Get the current plug-in file

对存储管理器中所存储的插件文件的定义标识进行读取,并判断该定义标识是否发生变更,若发生变更,则判断该插件文件当前所缓存的插件实例中的插件文件是否相同,若不相同,则获取当前的插件文件;在本实施例中,该定义标识用于判断插件文件发生变更是否变更,当定义标识发生变更后,判断插件文件的内容是否相同,若相同,则直接获取当前已经缓存的插件实例,其有效避免相同内容的插件频繁初始化问题;其中,该插件文件发生变更包括:有新的Jar文件包上传、Jar文件包被删除、Jar文件包的内容被更改;用户可以根据其具体的过滤需求,对Jar文件包进行调整。Read the definition identifier of the plug-in file stored in the storage manager, and determine whether the definition identifier has changed, and if so, determine whether the plug-in file in the plug-in instance currently cached by the plug-in file is the same, if not If they are the same, then obtain the current plug-in file; in this embodiment, the definition identifier is used to judge whether the plug-in file has been changed. When the definition identifier changes, it is judged whether the content of the plug-in file is the same. The plug-in instance that has been cached can effectively avoid the problem of frequent initialization of plug-ins with the same content; among them, the change of the plug-in file includes: a new Jar file package is uploaded, the Jar file package is deleted, and the content of the Jar file package is changed; the user can Adjust the Jar file package according to its specific filtering requirements.

S205.释放当前的插件实例S205. Release the current plug-in instance

将当前所缓存的插件实例进行释放,在本实施例中,网关中缓存有上次的插件实例,由于后续步骤中需要生成新的插件实例,故本步骤中需要对当前所缓存的插件实例进行释放。Release the currently cached plug-in instance. In this embodiment, the last plug-in instance is cached in the gateway. Since a new plug-in instance needs to be generated in the subsequent steps, the current cached plug-in instance needs to be updated in this step. freed.

S206.对新的插件文件进行实例化S206. Instantiate the new plug-in file

对当前的插件文件进行实例化,得到新的插件实例并进行缓存;其中,实例化是指在面向对象的编程中,把用类创建对象的过程称为实例化;其是将一个抽象的概念类,具体到该类实物的过程。Instantiate the current plug-in file, get a new plug-in instance and cache it; among them, instantiation refers to the process of creating an object with a class in object-oriented programming. It is an abstract concept Class, the process specific to the object of this class.

S207.将新的插件实例适配成插件过滤器S207. Adapt the new plug-in instance to a plug-in filter

将缓存后的新的插件实例适配成插件过滤器,同时,将所有插件过滤器收集起来,供构建过滤器链时使用;Adapt the cached new plug-in instance into a plug-in filter, and at the same time, collect all plug-in filters for use when building a filter chain;

S208.构建新的过滤链S208. Build a new filtering chain

将网关中的内置过滤器和所述插件过滤器按照其排序号从小到大排序,然后加入到过滤链中,构建新的过滤链;其中,该内置过滤器为网关中预先设置的过滤器,在本实施例中,通过将内置过滤器和插件过滤器进行整合,得到新的过滤链。sort the built-in filters in the gateway and the plug-in filters according to their sorting numbers from small to large, and then add them to the filter chain to construct a new filter chain; wherein, the built-in filter is a preset filter in the gateway, In this embodiment, a new filtering chain is obtained by integrating the built-in filter and the plug-in filter.

S209.按照新的过滤链将访问请求进行过滤S209. Filter the access request according to the new filtering chain

按照新的过滤链将所接收到的访问请求进行过滤,并将过滤后的访问请求发送至服务器端中。The received access requests are filtered according to the new filtering chain, and the filtered access requests are sent to the server.

本发明包括一种计算机可读存储介质,其上存储有能够实现本说明书上述方法的程序产品。在一些可能的实施方式中,本发明的各个方面还可以实现为一种程序产品的形式,其包括程序代码,当所述程序产品在终端设备上运行时,所述程序代码用于使所述终端设备执行本说明书上述“示例性方法”部分中描述的根据本发明各种示例性实施方式的步骤。The present invention includes a computer-readable storage medium on which a program product capable of implementing the above-mentioned method in this specification is stored. In some possible implementations, various aspects of the present invention can also be implemented in the form of a program product, which includes program code, and when the program product is run on a terminal device, the program code is used to make the The terminal device executes the steps according to various exemplary embodiments of the present invention described in the "Exemplary Method" section above in this specification.

所述程序产品可以采用一个或多个可读介质的任意组合。可读介质可以是可读信号介质或者可读存储介质。可读存储介质例如可以为但不限于电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。可读存储介质的更具体的例子(非穷举的列表)包括:具有一个或多个导线的电连接、便携式盘、硬盘、随机存取存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。The program product may reside on any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any combination thereof. More specific examples (non-exhaustive list) of readable storage media include: electrical connection with one or more conductors, portable disk, hard disk, random access memory (RAM), read only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

计算机可读信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了可读程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。可读信号介质还可以是可读存储介质以外的任何可读介质,该可读介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。A computer readable signal medium may include a data signal carrying readable program code in baseband or as part of a carrier wave. Such propagated data signals may take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. A readable signal medium may also be any readable medium other than a readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device.

以上可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于无线、有线、光缆、RF等等,或者上述的任意合适的组合。The program code contained on the above readable medium can be transmitted by any appropriate medium, including but not limited to wireless, cable, optical cable, RF, etc., or any suitable combination of the above.

下面以一个实施例对本发明的一种Spring Cloud Gateway网关插件动态加载装置进行具体描述,请参阅图3,其包括:The following is a specific description of a Spring Cloud Gateway gateway plug-in dynamic loading device of the present invention in an embodiment, please refer to Figure 3, which includes:

存储管理模块Plugin Definition Store,所述存储管理模块用于对插件文件进行管理和存储;其具体包括:包括插件文件的上传、移除、修改和读取,其中,该插件文件为Jar文件包,用户可以根据其具体的过滤需求,对Jar文件包进行调整。The storage management module Plugin Definition Store, the storage management module is used to manage and store the plug-in files; it specifically includes: uploading, removing, modifying and reading the plug-in files, wherein the plug-in files are Jar file packages, Users can adjust the Jar file package according to their specific filtering requirements.

监测管理模块Plugin Loader,所述监测管理模块与所述存储管理模块相连接,用于对存储管理模块进行实时监测,当监测到所述存储管理模块中所存储的插件文件发生变更时,如:有新的插件文件上传、现有的插件文件被移除、现有的插件文件被修改等;则获取该存储管理模块中当前的插件文件并驱动实例缓存模块和监测管理模块;并将缓存后的新的插件实例适配成插件过滤器,将所述插件过滤器加入至网关的过滤链中,构建新的过滤链;故网关可在不重启的情况下根据其新的过滤链执行过滤请求。The monitoring management module Plugin Loader, the monitoring management module is connected with the storage management module, and is used for real-time monitoring of the storage management module. When it is detected that the plug-in files stored in the storage management module change, such as: A new plug-in file is uploaded, an existing plug-in file is removed, an existing plug-in file is modified, etc.; the current plug-in file in the storage management module is obtained and the instance cache module and the monitoring management module are driven; and the cached The new plug-in instance is adapted as a plug-in filter, and the plug-in filter is added to the filter chain of the gateway to build a new filter chain; therefore, the gateway can perform filtering requests according to its new filter chain without restarting .

实例缓存模块Plugin Class Loader Manager,所述实例缓存模块与所述监测管理模块相连接,用于根据所述监测管理模块的驱动将当前所缓存的插件实例进行释放,或将新的插件实例进行缓存。An instance cache module Plugin Class Loader Manager, the instance cache module is connected to the monitoring management module, and is used to release the currently cached plug-in instance or cache a new plug-in instance according to the driver of the monitoring management module .

实例化模块Plugin Class Loader,所述实例化模块分别与实例缓存模块和监测管理模块相连接,用于对监测管理模块所获得的插件文件进行实例化,得到新的插件实例;其中,实例化是指在面向对象的编程中,把用类创建对象的过程称为实例化;其是将一个抽象的概念类,具体到该类实物的过程。The instantiation module Plugin Class Loader, the instantiation module is respectively connected with the instance cache module and the monitoring management module, and is used to instantiate the plug-in file obtained by the monitoring management module to obtain a new plug-in instance; wherein, the instantiation is In object-oriented programming, the process of creating an object with a class is called instantiation; it is the process of converting an abstract concept class to a specific object of that class.

下面以一个实施例对本发明的一种Spring Cloud Gateway网关插件动态加载系统进行具体描述,请参阅图4,其包括:A kind of Spring Cloud Gateway gateway plug-in dynamic loading system of the present invention is specifically described below with an embodiment, please refer to Fig. 4, and it comprises:

客户端、服务器端、网关;其中,该网关为Spring Cloud Gateway;Client, server, and gateway; where the gateway is Spring Cloud Gateway;

所述网关设置于所述客户端与服务器端之间,且所述网关中设有如上所述的微服务网关插件动态加载装置。其具体的过程为:客户端发起请求,且当发起的请求与配置的路由匹配的时候,插件动态加载装置就会收集内置过滤器、插件过滤器,并重新构建与执行过滤链;使得客户端所发起的请求经过过滤链的过滤后进入至服务器端,以执行相应的操作。The gateway is set between the client and the server, and the gateway is provided with the above-mentioned microservice gateway plug-in dynamic loading device. The specific process is: the client initiates a request, and when the initiated request matches the configured route, the plug-in dynamic loading device will collect built-in filters and plug-in filters, and rebuild and execute the filter chain; so that the client The initiated request is filtered by the filter chain and then sent to the server to perform corresponding operations.

在本说明书的描述中,参考术语“一个实施方式”、“一些实施方式”、“示意性实施方式”、“示例”、“具体示例”、或“一些示例”等的描述意指结合实施方式或示例描述的具体特征、结构、材料或者特点包含于本发明的至少一个实施方式或示例中。在本说明书中,对上述术语的示意性表述不一定指的是相同的实施方式或示例。而且,描述的具体特征、结构、材料或者特点可以在任何的一个或多个实施方式或示例中以合适的方式结合。In the description of this specification, descriptions referring to the terms "one embodiment", "some embodiments", "exemplary embodiments", "examples", "specific examples", or "some examples" etc. mean that the embodiments are combined A specific feature, structure, material, or characteristic described or exemplified is included in at least one embodiment or example of the present invention. In this specification, schematic representations of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the described specific features, structures, materials or characteristics may be combined in any suitable manner in any one or more embodiments or examples.

以上所述仅为本发明的较佳实施例而已,并不用以限制本发明,凡在本发明的精神和原则之内所作的任何修改、等同替换和改进等,均应包含在本发明的保护范围之内。The above descriptions are only preferred embodiments of the present invention, and are not intended to limit the present invention. Any modifications, equivalent replacements and improvements made within the spirit and principles of the present invention should be included in the protection of the present invention. within range.

Claims (9)

1.一种微服务网关插件动态加载方法,其特征在于,包括:1. A method for dynamically loading a microservice gateway plug-in, comprising: 对存储管理器进行实时监测,当监测到所述存储管理器中所存储的插件文件发生变更时,获取当前的插件文件;Perform real-time monitoring on the storage manager, and obtain the current plug-in file when the plug-in file stored in the storage manager is detected to be changed; 将当前所缓存的插件实例进行释放,然后对当前的插件文件进行实例化,得到新的插件实例并进行缓存;Release the currently cached plug-in instance, and then instantiate the current plug-in file to obtain a new plug-in instance and cache it; 将缓存后的新的插件实例适配成插件过滤器;Adapt the cached new plug-in instance to a plug-in filter; 将所述插件过滤器加入至网关的过滤链中,构建新的过滤链。The plug-in filter is added to the filter chain of the gateway to construct a new filter chain. 2.根据权利要求1所述的微服务网关插件动态加载方法,其特征在于,所述监测到所述存储管理器中所存储的插件文件发生变更之前包括:2. The microservice gateway plug-in dynamic loading method according to claim 1, wherein the monitoring includes before the plug-in file stored in the storage manager is changed: 对所述存储管理器中的插件文件进行调整。Make adjustments to the plugin files in the storage manager. 3.根据权利要求2所述的微服务网关插件动态加载方法,其特征在于,所述对所述存储管理器中的插件文件进行调整包括:3. The microservice gateway plug-in dynamic loading method according to claim 2, wherein said adjusting the plug-in file in the storage manager comprises: 对所述存储管理器中的插件文件进行上传、移除、修改。Upload, remove and modify the plug-in files in the storage manager. 4.根据权利要求3所述的微服务网关插件动态加载方法,其特征在于,所述将所述插件过滤器加入至网关的过滤链中,构建新的过滤链包括:4. The microservice gateway plug-in dynamic loading method according to claim 3, wherein said adding the plug-in filter to the filter chain of the gateway, and constructing a new filter chain include: 将网关中的内置过滤器和所述插件过滤器按照预定的顺序加入到过滤链中,构建新的过滤链。The built-in filter in the gateway and the plug-in filter are added to the filter chain in a predetermined order to construct a new filter chain. 5.根据权利要求4所述的微服务网关插件动态加载方法,其特征在于,所述当监测到所述存储管理器中所存储的插件文件发生变更时,获取当前的插件文件包括:5. The microservice gateway plug-in dynamic loading method according to claim 4, characterized in that, when it is detected that the plug-in file stored in the storage manager changes, obtaining the current plug-in file includes: 对存储管理器中所存储的插件文件的定义标识进行读取,并判断该定义标识是否发生变更,若发生变更,则判断该插件文件当前所缓存的插件实例中的插件文件是否相同,若不相同,则获取当前的插件文件。Read the definition identifier of the plug-in file stored in the storage manager, and determine whether the definition identifier has changed, and if so, determine whether the plug-in file in the plug-in instance currently cached by the plug-in file is the same, if not same, get the current plugin file. 6.根据权利要求5所述的微服务网关插件动态加载方法,其特征在于,所述对存储管理器进行实时监测之前包括:6. The microservice gateway plug-in dynamic loading method according to claim 5, characterized in that, before performing real-time monitoring on the storage manager, the method includes: 接收客户端的访问请求,当该访问请求与网关配置的路由匹配时,执行对存储管理器进行实时监测。Receive the access request from the client, and when the access request matches the route configured by the gateway, perform real-time monitoring on the storage manager. 7.根据权利要求6所述的微服务网关插件动态加载方法,其特征在于,所述构建新的过滤链之后包括:7. The microservice gateway plug-in dynamic loading method according to claim 6, characterized in that, after constructing a new filter chain, the method includes: 按照新的过滤链将所接收到的访问请求进行过滤,并将过滤后的访问请求发送至服务器端中。The received access requests are filtered according to the new filtering chain, and the filtered access requests are sent to the server. 8.一种微服务网关插件动态加载装置,其特征在于,包括:8. A microservice gateway plug-in dynamic loading device, characterized in that it comprises: 插件监测模块,用于对存储管理器进行实时监测,当监测到所述存储管理器中所存储的插件文件发生变更时,获取当前的插件文件;The plug-in monitoring module is used to monitor the storage manager in real time, and obtain the current plug-in file when the plug-in file stored in the storage manager is detected to be changed; 实例缓存模块,用于将当前所缓存的插件实例进行释放,然后对当前的插件文件进行实例化,得到新的插件实例并进行缓存;The instance cache module is used to release the currently cached plug-in instance, and then instantiate the current plug-in file to obtain a new plug-in instance and cache it; 适配模块,用于将缓存后的新的插件实例适配成插件过滤器;以及an adaptation module, adapted to adapt the cached new plug-in instance to a plug-in filter; and 过滤链构建模块,用于将所述插件过滤器加入至网关的过滤链中,构建新的过滤链。The filter chain building module is used to add the plug-in filter to the filter chain of the gateway to build a new filter chain. 9.一种计算机可读程序存储介质,其特征在于,其存储有计算机程序指令,当所述计算机程序指令被计算机执行时,使计算机执行根据权利要求1至7中任一项所述的方法。9. A computer-readable program storage medium, characterized in that it stores computer program instructions, and when the computer program instructions are executed by a computer, the computer is made to perform the method according to any one of claims 1 to 7 .
CN202110318551.2A 2021-03-25 2021-03-25 Microservice gateway plug-in dynamic loading method, device, system and storage medium thereof Active CN112988274B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110318551.2A CN112988274B (en) 2021-03-25 2021-03-25 Microservice gateway plug-in dynamic loading method, device, system and storage medium thereof

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110318551.2A CN112988274B (en) 2021-03-25 2021-03-25 Microservice gateway plug-in dynamic loading method, device, system and storage medium thereof

Publications (2)

Publication Number Publication Date
CN112988274A CN112988274A (en) 2021-06-18
CN112988274B true CN112988274B (en) 2023-01-31

Family

ID=76333742

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110318551.2A Active CN112988274B (en) 2021-03-25 2021-03-25 Microservice gateway plug-in dynamic loading method, device, system and storage medium thereof

Country Status (1)

Country Link
CN (1) CN112988274B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113347041B (en) * 2021-06-21 2022-03-01 深圳壹账通智能科技有限公司 Dynamic current limiting fuse configuration method, device, equipment and storage medium
CN113595788B (en) * 2021-07-28 2024-05-28 上海华兴数字科技有限公司 API gateway management method and device based on plug-in
CN113726662B (en) * 2021-08-19 2023-02-10 成都民航西南凯亚有限责任公司 Micro-service routing and management system
CN115102849A (en) * 2022-05-11 2022-09-23 浪潮云信息技术股份公司 A method and device for dynamically loading and configuring a service gateway plug-in
CN115134235A (en) * 2022-06-22 2022-09-30 武汉东湖学院 Microservice gateway plug-in dynamic loading method, device, system and storage medium thereof
CN115883353A (en) * 2022-12-08 2023-03-31 普元信息技术股份有限公司 Routing plug-in arranging and executing system based on Spring Cloud Gateway in trusted environment

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101646995A (en) * 2007-03-26 2010-02-10 国际商业机器公司 Data stream filters and plug-ins for storage managers
CN111610979A (en) * 2020-04-15 2020-09-01 河南大学 An API gateway optimized for persistence and coupling and its method
WO2020237797A1 (en) * 2019-05-31 2020-12-03 烽火通信科技股份有限公司 Dynamic configuration management method and system in microservice framework

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101626117B1 (en) * 2009-06-22 2016-05-31 삼성전자주식회사 Client, brokerage sever and method for providing cloud storage

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101646995A (en) * 2007-03-26 2010-02-10 国际商业机器公司 Data stream filters and plug-ins for storage managers
WO2020237797A1 (en) * 2019-05-31 2020-12-03 烽火通信科技股份有限公司 Dynamic configuration management method and system in microservice framework
CN111610979A (en) * 2020-04-15 2020-09-01 河南大学 An API gateway optimized for persistence and coupling and its method

Also Published As

Publication number Publication date
CN112988274A (en) 2021-06-18

Similar Documents

Publication Publication Date Title
CN112988274B (en) Microservice gateway plug-in dynamic loading method, device, system and storage medium thereof
CN113709810B (en) Method, equipment and medium for configuring network service quality
US9141364B2 (en) Caching and analyzing images for faster and simpler cloud application deployment
CN112148678B (en) A file access method, system, device and medium
CN111045833B (en) Interface calling method and device
CN108712454A (en) A kind of document handling method, device and equipment
WO2019051948A1 (en) Method, apparatus, server, and storage medium for processing monitoring data
CN103220325A (en) Acquiring information dynamically regarding a hardware component in the cloud computing system while on the floor of the data center
CN107426023A (en) Cloud platform log collection and retransmission method, system, equipment and storage medium
CN115357198B (en) Mounting method and device of storage volume, storage medium and electronic equipment
US11677716B2 (en) System of a distributed web application firewall cluster
WO2016127656A1 (en) Data caching method and device for net disk client
KR20140004799A (en) Peer-to-peer data migration
WO2020024750A1 (en) Method and system for defining camera by using software, and camera
WO2023174013A1 (en) Video memory allocation method and apparatus, and medium and electronic device
CN110780887B (en) A method and device for providing application installation package
CN112035402A (en) A file storage method, device and terminal device
CN109947718A (en) A kind of date storage method, storage platform and storage device
CN114365107A (en) Network-based media processing (NBMP) workflow management controlled by 5G real-time uplink streaming framework (plus)
CN107643959B (en) Image file processing method and device
CN109862069B (en) Message processing method and device
CN108718329B (en) Method and device for supporting cloud storage mobile routing device accessed in multiple modes
CN118484796A (en) Tenant rights management method, system, device and medium for SaaS platform
CN118820176A (en) Object storage service calling and management method and device
CN118626171A (en) A method, device and system for loading resource files

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CP03 Change of name, title or address

Address after: No. 1, Building 1, Yuanlin Garden, No. 62 Xueyuan South Road, Haidian District, Beijing

Patentee after: Dipu Technology Co., Ltd.

Country or region after: China

Address before: 100000 Beijing City, Haidian District, Caihefang Road No. 8, 4th floor, Room 406

Patentee before: BEIJING DEEPEXI TECHNOLOGY Co.,Ltd.

Country or region before: China

CP03 Change of name, title or address