Functional module storage method, device and system based on microservice gateway
By using file servers and network-attached storage servers in the microservice gateway to synchronize functional modules, the gateway service abnormality caused by functional module storage in the prior art is solved, and the gateway service is high availability and normal operation is achieved.
Patent Information
- Application Number
- CN202211278621.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-19
- Publication Date
- 2025-04-08
- Estimated Expiration
- 2042-10-19
AI Technical Summary
The existing functional module storage method based on microservice gateways cannot ensure the normal operation of gateway services, and the high availability of gateway services is difficult to ensure.
By sending the imported legal functional module to the file server to generate an identity and sending the identity to the network-attached storage server, when the gateway starts or reloads, it is possible to determine whether the functional module is missing in the local disk, and synchronize the missing functional module from the network-attached storage server or file server to the local disk.
It realizes high availability of storage function modules in gateway services, avoids gateway service abnormalities caused by loss of functional modules, and ensures the normal operation and high availability of gateway services.
Smart Images

Figure CN115622838B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of Internet technology, and more specifically, to a method, device and system for storing functional modules based on a microservice gateway. Background Art
[0002] With the continuous increase in user demand, microservice architecture has gradually become the preferred architecture for software development. In the microservice architecture, the gateway provides a unified entrance for many microservices and has the ability to centrally process common non-business needs. The non-business needs processed by the gateway are often provided in the form of functional modules, such as service routing, traffic control, log monitoring, security authentication, etc.
[0003] In the microservice architecture, gateways are often deployed in multi-cluster mode. When deploying multi-cluster gateway services, each gateway needs to maintain its own functional modules. If the functional modules are lost due to abnormal events, the gateway service will be abnormal. For multi-cluster gateway services, the inconsistency of functional modules in different gateways in the same cluster or different clusters will also cause gateway service abnormalities. How to store functional modules to ensure the normal operation of gateway services has become an urgent problem to be solved.
[0004] In the existing functional module storage solution based on microservice gateway, the functional modules are stored in the gateway image file. However, due to the strong binding between the functional modules and the gateway, the iterative update of the former is inevitably accompanied by the redeployment of the latter, which makes the iterative update of the functional modules a high-risk operation. The abnormality of the functional modules will lead to the abnormality of the gateway service, and the normal operation of the gateway service cannot be guaranteed, and the high availability of the gateway service is difficult to guarantee. Summary of the invention
[0005] In view of this, the present application provides a method, device and system for storing functional modules based on a microservice gateway, which is used to solve the problem that the existing method for storing functional modules based on a microservice gateway cannot guarantee the normal operation of the gateway service and the high availability of the gateway service is difficult to guarantee.
[0006] In order to achieve the above objectives, the proposed solution is as follows:
[0007] A function module storage method based on a microservice gateway is applied to the gateway, and the method includes:
[0008] Sending the imported legal function module to the file server, so that the file server receives the function module and generates an identifier of the function module, and returns the identifier;
[0009] Receiving the identifier sent by the file server;
[0010] Sending the identifier to a network attached storage server in the cluster so that the network attached storage server downloads the functional module corresponding to the identifier from the file server;
[0011] When startup or reload occurs, determine whether the function module is missing in the local disk;
[0012] If so, synchronizing the missing functional modules from the network attached storage server to the local disk;
[0013] If synchronization fails, synchronizing the missing functional modules from the file server to the local disk;
[0014] The function module is loaded from the local disk to provide corresponding functions externally.
[0015] Preferably, after sending the identifier to the network attached storage server in the cluster, the method further includes:
[0016] Maintaining the identification and attribute information of the functional module in a database;
[0017] Before determining whether the local disk lacks a functional module, the method further includes:
[0018] Determine whether there is a changed functional module in the local disk according to the attribute information of the functional module in the database;
[0019] If not, directly execute the step of determining whether the function module is missing in the local disk;
[0020] If yes, acquiring the latest identification and attribute information of the changed functional module from the database and sending the information to the network attached storage server, so that the network attached storage server registers the changed functional module according to the latest identification and attribute information of the changed functional module;
[0021] The determining whether the local disk lacks a functional module includes:
[0022] Whether the local disk lacks a functional module is determined according to the registration status of the functional module by the network attached storage server.
[0023] Preferably, maintaining the identification and attribute information of the functional modules in a database includes:
[0024] Maintain the identification and abbreviation of the functional module, version information, update time, and the cluster to which it belongs in the database;
[0025] The step of judging whether there is a changed functional module in the local disk according to the attribute information of the functional module in the database includes:
[0026] Determine whether the version information of the function module with the same abbreviation in the local disk is consistent with the latest version information in the database;
[0027] If they are consistent, it is determined that there is no changed functional module in the local disk;
[0028] If they are inconsistent, it is determined that there are changed functional modules in the local disk.
[0029] Preferably, judging whether the local disk lacks a functional module according to the registration status of the functional module by the network attached storage server includes:
[0030] Determining whether the identification and attribute information of the function module in the local disk is consistent with the identification and attribute information of the function module in the configuration information stored in the network-attached storage server, wherein the configuration information includes the identification and attribute information of the registered function module;
[0031] If they are consistent, it is determined that there is no lack of functional modules in the local disk;
[0032] If they are inconsistent, it is determined that the local disk lacks a functional module.
[0033] Preferably, after synchronizing the missing functional modules from the file server to the local disk, the method further includes:
[0034] The identifier of the missing functional module is sent to the network attached storage server, so that the network attached storage server downloads the functional module corresponding to the identifier of the missing functional module from the file server for backup.
[0035] A functional module storage device based on a microservice gateway, applied to the gateway, comprising:
[0036] A function module sending unit, used to send the imported legal function module to the file server, so that the file server receives the function module and generates an identifier of the function module, and returns the identifier;
[0037] A function module identifier receiving unit, used for receiving an identifier sent by the file server;
[0038] a function module identification sending unit, configured to send the identification to a network attached storage server in the cluster, so that the network attached storage server downloads the function module corresponding to the identification from the file server;
[0039] A function module missing judgment unit is used to judge whether a function module is missing in a local disk when startup or reload occurs;
[0040] If yes, then execute the following steps of the first functional module synchronization unit;
[0041] A first function module synchronization unit, configured to synchronize the missing function modules from the network attached storage server to the local disk;
[0042] If the synchronization fails, the following steps of the second functional module synchronization unit are executed;
[0043] A second function module synchronization unit, used for synchronizing the missing function module from the file server to the local disk;
[0044] The function module loading unit is used to load the function module from the local disk to provide corresponding functions externally.
[0045] Preferably, the functional module storage device based on the microservice gateway further includes:
[0046] A function module information maintenance unit, used to maintain the identification and attribute information of the function module in a database;
[0047] A function module change determination unit, used for determining whether there is a changed function module in the local disk according to the attribute information of the function module in the database;
[0048] If not, directly execute the step of the function module lacking judgment unit, if so, first execute the step of the function module information sending unit described below;
[0049] a changed function module information sending unit, configured to obtain the latest identification and attribute information of the changed function module from the database and send the information to the network attached storage server, so that the network attached storage server registers the changed function module according to the latest identification and attribute information of the changed function module;
[0050] The process of the function module missing judgment unit judging whether the function module is missing in the local disk includes:
[0051] Whether the local disk lacks a functional module is determined according to the registration status of the functional module by the network attached storage server.
[0052] Preferably, the process of the function module information maintenance unit maintaining the identification and attribute information of the function module in a database includes:
[0053] Maintain the identification and abbreviation of the functional module, version information, update time, and the cluster to which it belongs in the database;
[0054] The process of the function module change judgment unit judging whether there is a changed function module in the local disk according to the attribute information of the function module in the database includes:
[0055] Determine whether the version information of the function module with the same abbreviation in the local disk is consistent with the latest version information in the database;
[0056] If they are consistent, it is determined that there is no changed functional module in the local disk;
[0057] If they are inconsistent, it is determined that there are changed functional modules in the local disk.
[0058] Preferably, the functional module storage device based on the microservice gateway further includes:
[0059] The missing function module identification sending unit is used to send the identification of the missing function module to the network attached storage server, so that the network attached storage server downloads the function module corresponding to the identification of the missing function module from the file server for backup.
[0060] A functional module storage system based on a microservice gateway, comprising: a gateway, a network-attached storage server, and a file server, wherein each gateway-attached storage server is mounted to its gateway cluster in the form of an attached disk, all gateways in a single gateway cluster share the network-attached storage server in the cluster, and all gateways and network-attached storage servers in all clusters share the file server;
[0061] The gateway is used to send the imported legal function module to the file server, receive the identifier sent by the file server, send the identifier to the network attached storage server in the cluster, and when startup or reload occurs, determine whether the function module is missing in the local disk, if so, synchronize the missing function module from the network attached storage server to the local disk, if synchronization fails, synchronize the missing function module from the file server to the local disk, and load the function module from the local disk to provide corresponding functions externally;
[0062] The network attached storage server is used to receive the identifier sent by the gateway and download the functional module corresponding to the identifier from the file server;
[0063] The file server is used to receive the function module sent by the gateway, generate an identifier of the function module, and return the identifier to the gateway.
[0064] It can be seen from the above technical solution that the functional module storage method based on the microservice gateway provided in the embodiment of the present application, when the gateway re-imports a legitimate functional module, will store the functional module in the network attached storage server and the file server in the cluster respectively. No matter which cluster the gateway is started or reloaded, it will determine whether the local disk is missing a functional module. If so, the missing functional module is first synchronized to the local disk through the network attached storage server in the cluster. If the synchronization fails, the missing functional module is synchronized from the file server to the local disk, and the functional modules of the gateway are stored in the local disk, the network attached storage server, and the file server respectively, avoiding the gateway service anomalies caused by the loss of functional modules and the inconsistency of functional modules of different gateways in the same cluster or different clusters. The gateway service can operate normally and the high availability of the gateway service is guaranteed.
[0065] Furthermore, on the basis of ensuring the normal operation of the gateway service, the functional module will be loaded from the local disk to provide corresponding functions to the outside world, ensuring the startup efficiency of the gateway. BRIEF DESCRIPTION OF THE DRAWINGS
[0066] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0067] Figure 1 A flow chart of a function module storage method based on a microservice gateway disclosed in an embodiment of the present application;
[0068] Figure 2 A schematic diagram of the structure of a functional module storage device based on a microservice gateway disclosed in an embodiment of the present application;
[0069] Figure 3 A hardware structure block diagram of a functional module storage device based on a microservice gateway disclosed in an embodiment of the present application;
[0070] Figure 4 This is a structural diagram of a functional module storage system based on a microservice gateway disclosed in an embodiment of the present application. DETAILED DESCRIPTION
[0071] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0072] The present application provides a method for storing functional modules based on a microservice gateway, wherein microservice is an architectural solution for software development. Microservice is a loosely coupled distributed architecture framework, each application consists of several independently deployable components, changes to a single component will not affect the entire application, and the development team can quickly build new components to meet changing business needs.
[0073] The present application embodiment provides a functional module storage solution based on a microservice gateway. Figure 1 The function module storage method based on the microservice gateway of the present application is described from the perspective of the gateway, such as Figure 1 As shown, the method may include:
[0074] Step S100: Send the imported legal function module to the file server.
[0075] Specifically, after the gateway imports a new functional module, it will perform a legitimacy check on the newly imported functional module. If the check fails, it will be re-imported. After each successful import of a legal functional module, the legal functional module will be sent to the file server so that the file server receives the functional module to implement storage of the functional module, generate an identifier of the functional module, and return the identifier.
[0076] Among them, the functional module is a general term for non-business functions in the gateway. The gateway centrally manages modules such as communication anti-counterfeiting, flow control, encryption and decryption. Each function is called a functional module. Customization of needs is achieved through the free combination of functional modules. The file server is a public file storage device. Any authorized user can read and write files on it. The file server is responsible for the management, transmission and reception of shared resources, and provides file sharing services for users in the network. In this application, the file server is shared between different clusters.
[0077] Step S110: Receive the identifier sent by the file server.
[0078] Step S120: Send the identifier to the network attached storage server in the cluster.
[0079] Specifically, after receiving the identifier of the function module sent by the file server, the identifier is sent to the network attached storage server in the cluster, so that the network attached storage server downloads the function module corresponding to the identifier from the file server to implement storage of the function module.
[0080] Among them, a network-attached storage server is a device connected to the network and has a data storage function. As a dedicated data storage server, the network-attached storage server completely separates the storage device from the server, and its storage efficiency is much higher than server storage. In this application, the network-attached storage server is mounted to the gateway cluster where it is located in the form of an attached disk, and all gateways in a single gateway cluster share the network-attached storage server in the cluster.
[0081] Step S130: When startup or reloading occurs, determine whether the local disk lacks a functional module.
[0082] Specifically, reloading refers to the process of reloading functional modules. During the reloading stage, the effective functional modules are loaded, and corresponding functions are provided to the outside world based on the functional modules owned. Therefore, when startup or reloading occurs, it should be determined first whether the functional modules are missing in the local disk to avoid gateway service abnormalities due to the missing functional modules or inconsistency with the functional modules stored in the local disk of other gateways.
[0083] If yes, execute the following step S140.
[0084] Step S140: Synchronize the missing functional modules from the network attached storage server to the local disk.
[0085] Specifically, since the missing functional modules may be stored in the network attached storage server in the cluster, the missing functional modules may be first synchronized to the local disk through the network attached storage server in the cluster.
[0086] If the synchronization fails, the following step S150 is executed.
[0087] Step S150: Synchronize the missing functional modules from the file server to the local disk.
[0088] Specifically, if synchronization from the network-attached storage server in the cluster fails, it means that the missing functional module is imported by the gateway in other clusters, so the gateway-attached storage server in this cluster does not store the missing functional module, or the network-attached storage server loses the missing functional module due to an abnormal event. Since the gateways in all clusters will send the imported functional modules to the file server, the file server stores all the functional modules. Therefore, in the event of a synchronization failure from the network-attached storage server, the missing functional module is synchronized from the file server.
[0089] Step S160: Load the function module from the local disk to provide corresponding functions externally.
[0090] Specifically, since the speed of loading function modules from a network-attached storage server and a file server is lower than the speed of loading function modules from a local disk, the present application preferentially loads function modules from a local disk to provide corresponding functions externally.
[0091] The functional module storage method based on the microservice gateway provided in the embodiment of the present application, when the gateway re-imports a legitimate functional module, the functional module will be stored in the network attached storage server and the file server in the cluster respectively. No matter which cluster the gateway is started or reloaded, it will be determined whether the local disk is missing the functional module. If so, the missing functional module is first synchronized to the local disk through the network attached storage server in the cluster. If the synchronization fails, the missing functional module is synchronized from the file server to the local disk, thereby avoiding gateway service anomalies caused by the loss of functional modules and gateway service anomalies caused by inconsistent functional modules of different gateways in the same cluster or different clusters, so that the gateway service can operate normally and ensure the high availability of the gateway service.
[0092] Furthermore, on the basis of ensuring the normal operation of the gateway service, the functional module will be loaded from the local disk to provide corresponding functions to the outside world, ensuring the startup efficiency of the gateway.
[0093] Optionally, in a function module storage method based on a microservice gateway provided in an embodiment of the present application, in order to implement the above step S130 to determine whether the local disk lacks a function module, the following steps may be performed after the identifier is sent to a network attached storage server in the cluster in the above step S120:
[0094] Step S121: Maintain the identification and attribute information of the functional module in a database.
[0095] Specifically, after receiving the identifier of the function module sent by the file server, the identifier and attribute information of the function module are maintained in the database, and all gateways in the gateway cluster can monitor the changes of the data in the database.
[0096] Based on this, before determining whether the local disk lacks a functional module in the above step S130, the following steps may be performed:
[0097] Step S122: Determine whether there is a changed functional module in the local disk according to the attribute information of the functional module in the database.
[0098] Specifically, each functional module has its corresponding attribute information. For functional modules that implement the same function, their attribute information may be the same or different. Since the functional module identifier and attribute information are maintained in the database whenever the functional module identifier is received from the file server, the database stores attribute information of functional modules with different functions and different attribute information of functional modules with the same functions. The attribute information of the functional modules in the database can be used to determine whether there are changed functional modules in the local disk. That is, for functional modules that implement the same function, if the attribute information in the local disk is inconsistent with the attribute information in the database, it means that the functional module has changed.
[0099] If not, directly execute step S130 to determine whether the local disk lacks a functional module; if so, execute the following step S123.
[0100] Step S123: Acquire the latest identification and attribute information of the changed functional module from the database and send them to the NAS server.
[0101] Specifically, since the database stores different identifications and attribute information of functional modules with the same functions, when there is a changed functional module in the local disk, the latest identification and attribute information of the changed functional module can be obtained from the database and sent to the network attached storage server in the cluster, so that the network attached storage server can register the changed functional module according to the latest identification and attribute information of the changed functional module.
[0102] Based on this, the process of determining whether the local disk lacks a functional module in the above step S130 may include:
[0103] Whether the local disk lacks a functional module is determined according to the registration status of the functional module by the network attached storage server.
[0104] Specifically, if there is a changed functional module in the local disk, the network attached storage server in the cluster where it is located will register the changed functional module. Therefore, it is possible to determine whether the local disk is missing a functional module based on the registration status of the functional module by the network attached storage server. If the functional module registered in the network attached storage server is consistent with the functional module in the local disk, it means that there is no lack of functional module in the local disk. If they are inconsistent, it means that there is a lack of functional module in the local disk.
[0105] Optionally, the network-attached storage server may store configuration information of the gateway, the configuration information including identification and attribute information of registered functional modules. Registration of functional modules by the network-attached storage server is to modify the identification and attribute information of the functional modules in the configuration information stored therein. Therefore, whether the functional modules are missing in the local disk may be determined by judging whether the identification and attribute information of the functional modules in the local disk are consistent with the identification and attribute information of the functional modules in the configuration information stored by the network-attached storage server. If they are consistent, it is determined that the functional modules are not missing in the local disk. If they are inconsistent, it is determined that the functional modules are missing in the local disk.
[0106] Optionally, in a method for storing a function module based on a microservice gateway provided in an embodiment of the present application, the process of maintaining the identification and attribute information of the function module in a database in step S121 may include:
[0107] The identification and abbreviation of the functional module, version information, update time, and the cluster to which it belongs are maintained in the database.
[0108] Based on this, the process of determining whether there is a changed functional module in the local disk according to the attribute information of the functional module in the database in step S122 may include:
[0109] It is determined whether the version information of the function module with the same abbreviation in the local disk is consistent with the latest version information in the database.
[0110] If they are consistent, it is determined that there is no changed functional module in the local disk.
[0111] If they are inconsistent, it is determined that there are changed functional modules in the local disk.
[0112] Specifically, functional modules with the same abbreviation are functional modules that implement the same function. Whether the functional module has changed can be determined based on the abbreviation and version information in the functional module attribute information. If the version information of the functional module with the same abbreviation in the local disk is inconsistent with the latest version information in the database, it means that the functional module has changed.
[0113] Optionally, based on the above embodiment, if the synchronization of the missing functional module from the network-attached storage server fails, it means that the network-attached storage server does not store the missing functional module, or the network-attached storage server loses the missing functional module due to an abnormal event. In order to avoid synchronization failure when the missing functional module needs to be synchronized from the network-attached storage server again, in a functional module storage method based on a microservice gateway provided in an embodiment of the present application, after synchronizing the missing functional module from the file server to the local disk in the above step S150, the following steps may be performed:
[0114] Step S151: Send the identifier of the missing functional module to the network attached storage server, so that the network attached storage server downloads the functional module corresponding to the identifier of the missing functional module from the file server for backup.
[0115] In some embodiments of the present application, in the event that synchronization of missing functional modules from a network-attached storage server fails, the network-attached storage server will download the missing functional modules from a file server for backup, so that when a gateway of a cluster where the network-attached storage server is located needs to synchronize the missing functional modules, it can be synchronized directly from the network-attached storage server without having to synchronize from the file server again, thereby improving the startup efficiency of the gateway.
[0116] The above embodiments are illustrated by means of specific examples. For example, in a certain microservice architecture, there are clusters A and cluster B. Cluster A includes gateway 1, gateway 2, and network-attached storage server 1. Cluster B includes gateway 3, gateway 4, and network-attached storage server 2. All gateways and network-attached storage servers in cluster A and cluster B share file server 1. It is assumed that the local disks in gateway 1, gateway 2, gateway 3, and gateway 4 and network-attached storage server 1, network-attached storage server 2, and file server 1 all store flow control modules. The flow control module is identified by identification 1, referred to as flow control, with version information 1.0, update time 2022 / 10 / 11, and the cluster to which it belongs is cluster A. The data stored in the database is (identification 1, flow control, 1.0, 2022 / 10 / 11, cluster A), and the configuration information in network-attached storage server 1 and network-attached storage server 2 is (identification 1, flow control, 1.0, 2022 / 10 / 11, cluster A).
[0117] Assume that gateway 3 has re-imported the flow control module. The re-imported flow control module is abbreviated as flow control, the version information is 2.0, the upload time is 2022 / 10 / 21, and the cluster it belongs to is cluster B. Gateway 3 sends the re-imported flow control module to file server 1. File server 1 receives and generates identifier 2, and returns identifier 2 to gateway 3. Gateway 3 maintains (identifier 2, flow control, 2.0, 2022 / 10 / 21, cluster B) and (identifier 2, flow control, 2.0, 2022 / 10 / 21, cluster A) to the database. At this time, the data stored in the database are: (identifier 2, flow control, 2.0, 2022 / 10 / 21, cluster A) and (identifier 2, flow control, 2.0, 2022 / 10 / 21, cluster B).
[0118] Taking gateway 1 as an example, when gateway 1 is started or reloaded, it is found that the version information of the flow control in the local disk is 1.0, and the latest version information of the flow control in the database is 2.0, indicating that the flow control function module has changed, updated from version 1.0 to 2.0. At this time, the latest flow control information is obtained from the database: (identifier 2, flow control, 2.0, 2022 / 10 / 21, cluster A), and the information is sent to the network-attached storage server 1. The network-attached storage server 1 modifies the configuration information (identifier 1, flow control, 1.0, 2022 / 10 / 11, cluster A) to (identifier 2, flow control, 2.0, 2022 / 10 / 21, cluster A) to register the changed flow control module and obtain the configuration in the network-attached storage server 1. The information is (identifier 2, flow control, 2.0, 2022 / 10 / 21, cluster A), and the information of the functional module in the local disk is (identifier 1, flow control, 1.0, 2022 / 10 / 11, cluster A). It is also a flow control module. The identification and attribute information of the two are inconsistent, indicating that the flow control module identified as identifier 2 is missing in the local disk. At this time, the module is synchronized through the network attached storage server 1, and the synchronization fails. The module is synchronized again through the file server 1. After the synchronization is successful, the flow control module identified as identifier 2 is loaded from the local disk to provide functions to the outside world, and identifier 2 is sent to the network attached storage server 1. The network attached storage server 1 downloads the flow control module corresponding to identifier 2 from the file server 1 according to identifier 2 for backup.
[0119] The following is a description of a functional module storage device based on a microservice gateway provided in an embodiment of the present application. The functional module storage device based on a microservice gateway described below and the functional module storage device based on a microservice gateway described above can correspond to each other.
[0120] First, combine Figure 2 , a functional module storage device based on a microservice gateway is introduced, which is applied to the gateway, such as Figure 2As shown, the functional module storage device based on the microservice gateway may include:
[0121] The function module sending unit 200 is used to send the imported legal function module to the file server, so that the file server receives the function module and generates an identifier of the function module, and returns the identifier;
[0122] Function module identification receiving unit 210, used to receive the identification sent by the file server;
[0123] The function module identification sending unit 220 is used to send the identification to the network attached storage server in the cluster, so that the network attached storage server downloads the function module corresponding to the identification from the file server;
[0124] The function module missing judgment unit 230 is used to judge whether the function module is missing in the local disk when starting or reloading occurs;
[0125] If yes, then execute the following steps of the first functional module synchronization unit;
[0126] A first function module synchronization unit 240, configured to synchronize the missing function modules from the network attached storage server to the local disk;
[0127] If the synchronization fails, the following steps of the second functional module synchronization unit are executed;
[0128] A second function module synchronization unit 250, configured to synchronize the missing function modules from the file server to the local disk;
[0129] The function module loading unit 260 is used to load the function module from the local disk to provide corresponding functions externally.
[0130] Optionally, the functional module storage device based on the microservice gateway may further include:
[0131] A function module information maintenance unit, used to maintain the identification and attribute information of the function module in a database;
[0132] A function module change determination unit, used for determining whether there is a changed function module in the local disk according to the attribute information of the function module in the database;
[0133] If not, directly execute the step of the function module lacking judgment unit, if so, first execute the step of the function module information sending unit described below;
[0134] a changed function module information sending unit, configured to obtain the latest identification and attribute information of the changed function module from the database and send the information to the network attached storage server, so that the network attached storage server registers the changed function module according to the latest identification and attribute information of the changed function module;
[0135] The process of the function module missing determination unit determining whether the function module is missing in the local disk may include:
[0136] Whether the local disk lacks a functional module is determined according to the registration status of the functional module by the network attached storage server.
[0137] Optionally, the process in which the function module information maintenance unit maintains the identification and attribute information of the function module in a database may include:
[0138] Maintain the identification and abbreviation of the functional module, version information, update time, and the cluster to which it belongs in the database;
[0139] The process of the function module change determination unit determining whether there is a changed function module in the local disk according to the attribute information of the function module in the database may include:
[0140] Determine whether the version information of the function module with the same abbreviation in the local disk is consistent with the latest version information in the database;
[0141] If they are consistent, it is determined that there is no changed functional module in the local disk;
[0142] If they are inconsistent, it is determined that there are changed functional modules in the local disk.
[0143] Optionally, the process of determining whether the local disk lacks a functional module according to the registration status of the functional module by the network attached storage server may include:
[0144] Determining whether the identification and attribute information of the function module in the local disk is consistent with the identification and attribute information of the function module in the configuration information stored in the network-attached storage server, wherein the configuration information includes the identification and attribute information of the registered function module;
[0145] If they are consistent, it is determined that there is no lack of functional modules in the local disk;
[0146] If they are inconsistent, it is determined that the local disk lacks a functional module.
[0147] Optionally, the functional module storage device based on the microservice gateway may further include:
[0148] The missing function module identification sending unit is used to send the identification of the missing function module to the network attached storage server, so that the network attached storage server downloads the function module corresponding to the identification of the missing function module from the file server for backup.
[0149] The functional module storage device based on a microservice gateway provided in the embodiment of the present application can be applied to a functional module storage device based on a microservice gateway. Figure 3 The hardware structure diagram of the functional module storage device based on the microservice gateway is shown. Figure 3 ,The hardware structure of the functional module storage device based on the microservice gateway may include: at least one processor 1, at least one communication interface 2, at least one memory 3 and at least one communication bus 4;
[0150] In the embodiment of the present application, the number of the processor 1, the communication interface 2, the memory 3, and the communication bus 4 is at least one, and the processor 1, the communication interface 2, and the memory 3 communicate with each other through the communication bus 4;
[0151] The processor 1 may be a central processing unit CPU, or an application-specific integrated circuit ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement the embodiments of the present invention, etc.;
[0152] The memory 3 may include a high-speed RAM memory, and may also include a non-volatile memory, such as at least one disk memory;
[0153] Among them, the memory stores a program, and the processor can call the program stored in the memory, and the program is used to: implement the steps of the functional module storage method based on the microservice gateway described in any of the aforementioned embodiments.
[0154] An embodiment of the present application also provides a storage medium, which may store a program suitable for execution by a processor, wherein the program is used to: implement the steps of the functional module storage method based on the microservice gateway described in any of the aforementioned embodiments.
[0155] See also Figure 4 , Figure 4 A structural diagram of a functional module storage system based on a microservice gateway provided in an embodiment of the present application. A functional module storage system based on a microservice gateway provided in an embodiment of the present application may include: a gateway 10, a network-attached storage server 20, and a file server 30.
[0156] Among them, each gateway-attached storage server is mounted to its gateway cluster in the form of an attached disk, all gateways in a single gateway cluster share the network-attached storage server in the cluster, and all gateways and network-attached storage servers in the cluster share the file server;
[0157] The gateway is used to send the imported legal function module to the file server, receive the identifier sent by the file server, send the identifier to the network attached storage server in the cluster, and when startup or reload occurs, determine whether the function module is missing in the local disk, if so, synchronize the missing function module from the network attached storage server to the local disk, if synchronization fails, synchronize the missing function module from the file server to the local disk, and load the function module from the local disk to provide corresponding functions externally;
[0158] The network attached storage server is used to receive the identifier sent by the gateway and download the functional module corresponding to the identifier from the file server;
[0159] The file server is used to receive the function module sent by the gateway, generate an identifier of the function module, and return the identifier to the gateway.
[0160] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0161] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0162] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A function module storage method based on a microservice gateway, characterized in that: Applied to the gateway, the methods include: Sending the imported legal function module to the file server, so that the file server receives the function module and generates an identifier of the function module, and returns the identifier; Receiving the identifier sent by the file server; Sending the identifier to a network attached storage server in the cluster so that the network attached storage server downloads the functional module corresponding to the identifier from the file server; When startup or reload occurs, determine whether the function module is missing in the local disk; If so, synchronizing the missing functional modules from the network attached storage server to the local disk; If synchronization fails, synchronizing the missing functional modules from the file server to the local disk; Loading function modules from the local disk to provide corresponding functions externally; After sending the identifier to the network attached storage server in the cluster, the method further includes: Maintaining the identification and attribute information of the functional module in a database; wherein all gateways in the gateway cluster can monitor changes in data in the database; Before determining whether the local disk lacks a functional module, the method further includes: Judging whether there is a changed functional module in the local disk according to the attribute information of the functional module in the database; wherein judging whether it has changed is based on whether the attribute information of the functional module in the local disk is consistent with the attribute information in the database; If not, directly execute the step of determining whether the function module is missing in the local disk; If yes, obtaining the latest identification and attribute information of the changed functional module from the database and sending it to the network attached storage server, so that the network attached storage server registers the changed functional module according to the latest identification and attribute information of the changed functional module; The determining whether the function module is missing in the local disk includes: Determining whether the local disk lacks a functional module according to the registration status of the functional module by the network attached storage server; The step of judging whether the local disk lacks a functional module according to the registration status of the functional module by the network attached storage server includes: Determining whether the identification and attribute information of the function module in the local disk is consistent with the identification and attribute information of the function module in the configuration information stored in the network-attached storage server, wherein the configuration information includes the identification and attribute information of the registered function module; If they are consistent, it is determined that there is no lack of functional modules in the local disk; If they are inconsistent, it is determined that the local disk lacks a functional module.
2. The method according to claim 1, characterized in that: Maintaining the identification and attribute information of the functional module in the database includes: Maintain the identification and abbreviation of the functional module, version information, update time, and the cluster to which it belongs in the database; The step of judging whether there is a changed functional module in the local disk according to the attribute information of the functional module in the database includes: Determine whether the version information of the function module with the same abbreviation in the local disk is consistent with the latest version information in the database; If they are consistent, it is determined that there is no changed functional module in the local disk; If they are inconsistent, it is determined that there are changed functional modules in the local disk.
3. The method according to any one of claims 1 to 2, characterized in that: After synchronizing the missing functional modules from the file server to the local disk, the method further includes: The identifier of the missing functional module is sent to the network attached storage server, so that the network attached storage server downloads the functional module corresponding to the identifier of the missing functional module from the file server for backup.
4. A functional module storage device based on a microservice gateway, characterized in that: Applied to gateway, the device includes: A function module sending unit, used for sending the imported legal function module to the file server, so that the file server receives the function module and generates an identifier of the function module, and returns the identifier; A function module identifier receiving unit, used for receiving an identifier sent by the file server; a function module identification sending unit, configured to send the identification to a network attached storage server in the cluster, so that the network attached storage server downloads the function module corresponding to the identification from the file server; A function module missing judgment unit is used to judge whether a function module is missing in a local disk when startup or reload occurs; If yes, then execute the following steps of the first functional module synchronization unit; A first function module synchronization unit, configured to synchronize the missing function modules from the network attached storage server to the local disk; If the synchronization fails, the following steps of the second functional module synchronization unit are executed; A second function module synchronization unit, used for synchronizing the missing function module from the file server to the local disk; A function module loading unit, used to load function modules from the local disk to provide corresponding functions externally; Among them, it also includes: A function module information maintenance unit, used to maintain the identification and attribute information of the function module in a database; wherein all gateways in the gateway cluster can monitor changes in the data in the database; A function module change judgment unit, used to judge whether there is a changed function module in the local disk according to the attribute information of the function module in the database; wherein whether the function module has changed is judged according to whether the attribute information of the function module in the local disk is consistent with the attribute information in the database; If not, directly execute the step of the function module lacking judgment unit, if so, first execute the step of the function module information sending unit described below; a function module information sending unit, configured to obtain the latest identification and attribute information of the changed function module from the database and send the information to the network attached storage server, so that the network attached storage server registers the changed function module according to the latest identification and attribute information of the changed function module; The process of the function module missing judgment unit judging whether the function module is missing in the local disk includes: Determining whether the local disk lacks a functional module according to the registration status of the functional module by the network attached storage server; Among them, judging whether the local disk lacks a functional module according to the registration status of the functional module by the network attached storage server is specifically used to: judge whether the identification and attribute information of the functional module in the local disk are consistent with the identification and attribute information of the functional module in the configuration information stored by the network attached storage server, and the configuration information includes the identification and attribute information of the registered functional module; if they are consistent, it is determined that the local disk does not lack a functional module; if they are inconsistent, it is determined that the local disk lacks a functional module.
5. The device according to claim 4, characterized in that The process of the function module information maintenance unit maintaining the identification and attribute information of the function module in the database includes: Maintain the identification and abbreviation of the functional module, version information, update time, and the cluster to which it belongs in the database; The process of the function module change judgment unit judging whether there is a changed function module in the local disk according to the attribute information of the function module in the database includes: Determine whether the version information of the function module with the same abbreviation in the local disk is consistent with the latest version information in the database; If they are consistent, it is determined that there is no changed functional module in the local disk; If they are inconsistent, it is determined that there are changed functional modules in the local disk.
6. The device according to any one of claims 4 to 5, characterized in that: Also includes: The missing function module identification sending unit is used to send the identification of the missing function module to the network attached storage server, so that the network attached storage server downloads the function module corresponding to the identification of the missing function module from the file server for backup.
7. A functional module storage system based on a microservice gateway, characterized in that: include: Gateways, network-attached storage servers, and file servers, wherein each gateway-attached storage server is mounted to its gateway cluster in the form of an attached disk, all gateways in a single gateway cluster share the network-attached storage servers in the cluster, and all gateways and network-attached storage servers in all clusters share the file server; The gateway is used to send the imported legal function module to the file server, receive the identifier sent by the file server, send the identifier to the network attached storage server in the cluster, and when startup or reload occurs, determine whether the function module is missing in the local disk. If so, synchronize the missing function module from the network attached storage server to the local disk. If the synchronization fails, synchronize the missing function module from the file server to the local disk, and load the function module from the local disk to provide corresponding functions externally; wherein, after sending the identifier to the network attached storage server in the cluster, it is also used to: maintain the identifier and attribute information of the function module in the database; wherein all gateway clusters The gateways in the local disk can monitor the changes of data in the database; before judging whether the local disk lacks a functional module, it is also used to: judge whether there is a changed functional module in the local disk according to the attribute information of the functional module in the database; wherein, judging whether it has changed is based on whether the attribute information of the functional module in the local disk is consistent with the attribute information in the database; if not, directly executing the step of judging whether the local disk lacks a functional module; if so, obtaining the latest identification and attribute information of the changed functional module from the database and sending them to the network attached storage server, so that the network attached storage server registers the changed functional module according to the latest identification and attribute information of the changed functional module; The determining whether the local disk lacks a functional module is specifically used to: determine whether the local disk lacks a functional module according to the registration status of the functional module by the network attached storage server; Wherein, judging whether the local disk lacks a functional module according to the registration status of the functional module by the network attached storage server comprises: judging whether the identification and attribute information of the functional module in the local disk are consistent with the identification and attribute information of the functional module in the configuration information stored by the network attached storage server, wherein the configuration information comprises the identification and attribute information of the registered functional module; if they are consistent, determining that the local disk does not lack a functional module; if they are inconsistent, determining that the local disk lacks a functional module; The network attached storage server is used to receive the identifier sent by the gateway and download the functional module corresponding to the identifier from the file server; The file server is used to receive the function module sent by the gateway, generate an identifier of the function module, and return the identifier to the gateway.
Citation Information
Patent Citations
Gateway system based on micro-service and gateway dynamic routing method
CN111884917A
Micro-service gateway management method, system and device, readable storage medium and product
CN113572689A