Underlying data processing method and device
By periodically updating the data in the fallback database and generating and saving a business parameter agreement rule file, the problem of unchanging fallback data is solved, enabling the provision of the latest data and improving user experience and update efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-09
- Publication Date
- 2026-03-31
AI Technical Summary
In existing fallback data processing methods, the fallback data configured by operations is not updated, resulting in users receiving unchanging fallback data and a poor user experience.
By periodically updating the data in the fallback database, a business parameter convention rule file is generated and saved. Fallback data is generated based on the latest interface configuration information, and the fallback database is updated periodically.
Provide users with the latest backup data, improve user experience, reduce manual intervention, improve update efficiency, and reduce costs.
Smart Images

Figure CN114610732B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data disaster recovery backup data processing technology, and in particular to a backup data processing method and apparatus. Background Technology
[0002] With the rapid development of information technology, information systems are playing an increasingly important role in the critical business operations of various industries. Business interruptions in information systems can lead to huge economic losses, damage to brand image, and potential loss of important data. Therefore, ensuring business continuity is crucial for information system construction. In recent years, due to the frequent occurrence of large-scale natural disasters, reliable data disaster recovery and backup data processing have gained increasing attention and recognition in the industry to ensure business continuity.
[0003] There are several methods for handling fallback data. A common approach is for operations personnel to configure fixed return data based on business parameters, and then use this fixed data as the response content when the business becomes unavailable. However, since the fallback data configured by operations is pre-set and usually not updated, the fallback data provided to users remains unchanged, resulting in a poor user experience. Summary of the Invention
[0004] In view of this, embodiments of the present invention provide a fallback data processing method and apparatus. The present invention can periodically update the data in the fallback database, thereby avoiding the situation where the fallback data obtained by the user is unchanging, providing the user with more suitable and up-to-date fallback data, and providing the user with a better experience.
[0005] To achieve the above objectives, the embodiments of the present invention provide the following technical solutions:
[0006] The first aspect of this invention discloses a fallback data processing method, comprising:
[0007] According to the preset round sequence cycle, read the application configuration file in the configuration module;
[0008] The application configuration file is parsed to obtain the configuration information of each interface;
[0009] For each of the interface configuration information, a business parameter convention rule file for the core interface to which the interface configuration information belongs is generated, and the business parameter convention rule file is saved;
[0010] For each core interface, the fallback data for that core interface is generated using the business parameter convention rule file and interface configuration information of that core interface;
[0011] Based on the aforementioned fallback data, update the fallback database of the fallback service for the application to which the application configuration file belongs.
[0012] A second aspect of the present invention discloses a fallback data processing apparatus, comprising:
[0013] Configuration module and data update module;
[0014] The configuration module is used to obtain the application's configuration data and generate the application's configuration file based on the configuration data;
[0015] The data update module is used to read the application configuration file in the configuration module according to a preset round-robin cycle; parse the application configuration file to obtain the configuration information of each interface; for each interface configuration information, generate a business parameter convention rule file for the core interface to which the interface configuration information belongs, and save the business parameter convention rule file; for each core interface, use the business parameter convention rule file and interface configuration information of the core interface to generate fallback data for the core interface; and update the data to which the application configuration file belongs based on each fallback data.
[0016] Compared with the prior art, the present invention has the following advantages:
[0017] This invention provides a fallback data processing method and apparatus. The method includes: reading application configuration files from a configuration module according to a preset round-robin cycle; parsing the application configuration files to obtain configuration information for each interface; for each interface configuration information, generating a business parameter convention rule file for the core interface to which the interface configuration information belongs, and saving the business parameter convention rule file; for each core interface, generating fallback data for the core interface using the business parameter convention rule file and the interface configuration information; and updating the fallback database of the fallback service of the application to which the application configuration file belongs based on the fallback data. By updating the data in the fallback database, the method avoids providing users with unchanging fallback data, and can provide users with more suitable and demand-compliant fallback data, thereby improving the user experience. Attached Figure Description
[0018] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0019] Figure 1 A flowchart of a fallback data processing method provided in an embodiment of the present invention;
[0020] Figure 2A flowchart illustrating a method for generating a business parameter convention rule file for interface configuration information, as provided in an embodiment of the present invention.
[0021] Figure 3 A flowchart illustrating a method for generating fallback data for core interfaces using business parameter convention rules files and interface configuration information, as provided in this embodiment of the invention.
[0022] Figure 4 A flowchart illustrating a method for providing fallback data to users, as provided in an embodiment of the present invention;
[0023] Figure 5 This is a schematic diagram of the structure of a fallback data processing device provided in an embodiment of the present invention;
[0024] Figure 6 This is an architecture diagram of fallback data processing provided in an embodiment of the present invention;
[0025] Figure 7 A timing diagram of a fallback data processing method provided in an embodiment of the present invention;
[0026] Figure 8 A flowchart for generating catch-all data is provided in an embodiment of the present invention;
[0027] Figure 9 A flowchart for reading catch-all data is provided as an embodiment of the present invention;
[0028] Figure 10 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0029] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0030] In this application, the terms "comprising," "including," or any other variations thereof are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0031] As can be seen from the background technology, the fallback data in the existing technology is usually pre-set and is not updated, resulting in the fallback data obtained by users not being the latest data, which brings a poor user experience.
[0032] To address the aforementioned problems, embodiments of the present invention provide a fallback data processing method and apparatus that can update fallback data, thereby providing users with the latest fallback data and improving user experience.
[0033] This invention can be used in a wide variety of general-purpose or special-purpose computing environments or configurations. Examples include: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor devices, distributed computing environments including any of the above devices, etc. The executing entity of this invention can be a processor or a server.
[0034] Reference Figure 1 The following is a flowchart of a fallback data processing method provided by an embodiment of the present invention, which is described in detail below:
[0035] S101: Read the application configuration file in the configuration module according to the preset round sequence cycle.
[0036] In the method provided by this embodiment of the invention, the application configuration file in the configuration module is read periodically according to a preset polling cycle; in other words, the application configuration file in the configuration module is read periodically.
[0037] The application configuration file is generated after business users input configuration data for each core interface of the application in the configuration module. The application must have at least one core interface. Furthermore, business users can input configuration data for each core interface at any time in the configuration module. Preferably, the core interfaces are selected by the business users. If the application has multiple interfaces, the interface selected by the business users becomes the core interface.
[0038] Preferably, application configuration files of multiple applications can be obtained at once, and each application configuration file can be processed through steps S102 to S105.
[0039] S102: Parse the application configuration file to obtain configuration information for each interface.
[0040] Preferably, the application configuration file is a JSON file, and the interface configuration information includes data source interface information, parameter configuration, core interface information, etc.
[0041] S103: For each interface configuration information, generate a business parameter convention rule file for the core interface to which the interface configuration information belongs, and save the business parameter convention rule file.
[0042] Different interface configuration information corresponds to different core interfaces, and the rules for agreeing on business parameters can also be called schema files.
[0043] Reference Figure 2 The flowchart of the method for generating a business parameter convention rule file for interface configuration information provided in this embodiment of the invention is as follows:
[0044] S201: Determine the parameter convention rules field in the interface configuration information.
[0045] The interface configuration information is parsed to determine the parameter convention rule field in the interface configuration information. For example, the parameter convention rule field can also be called the fallback_schema field.
[0046] S202: Determine the first parameters of the core interface to which the interface configuration information belongs in the application.
[0047] Furthermore, the application can be understood as a client, which can determine the core interface to which the interface configuration information belongs, and the first parameters of each interface in the application. It should be noted that the first parameters are the parameters set by the business side. Taking the account application as an example, the password login interface is the core interface. In the account application, the first parameters of the password login interface can include username, password and verification code. Preferably, the first parameters can be understood as the core parameters of the core interface.
[0048] S203: Process each first parameter based on the preset parameter conversion fields to obtain the business parameter convention rule file of the core interface to which the interface configuration information belongs.
[0049] Furthermore, the preset parameter conversion fields are parsed, each first parameter is converted to obtain the conversion parameter name of each first parameter, and the first parameters and their conversion parameter names are arranged according to a preset sorting method to generate a business parameter convention document.
[0050] S204: Obtain the domain name and path information from the interface configuration information.
[0051] It should be noted that domain name information can be represented using the host, and path information can be represented using the path.
[0052] S205: Using the domain name information and the path information, generate a file storage directory.
[0053] After generating the file save directory, check if a directory with the same save directory exists in the storage space. If it does not exist, the file save directory needs to be created in the storage space. If it exists, the file save directory does not need to be created in the storage space.
[0054] S206: Save the business parameter convention rules file based on the file storage directory.
[0055] Save the business parameter and business rule files to the storage memory corresponding to the directory where the files are saved.
[0056] In the method provided by this embodiment of the invention, a business parameter convention rule file is generated using the core interface. The business parameter convention rule file is a description file. When saving the business parameter convention rules, it is saved in the form of a directory, and the directory used is related to the host and path of the core interface, which ensures the orderly saving of the business parameter convention rule file and facilitates the subsequent retrieval of the business parameter convention rule file.
[0057] S104: For each core interface, use the business parameter convention rule file and interface configuration information of the core interface to generate fallback data for the core interface.
[0058] Reference Figure 3 The flowchart of the method for generating fallback data for core interfaces using business parameter convention rules files and interface configuration information provided in this embodiment of the invention is described in detail below:
[0059] S301: Obtain the data source interface and parameter group of the core interface from the interface configuration information. The parameter group contains multiple second parameters.
[0060] The data source interface is used to obtain the data that the core interface needs to return to the user when it is working normally. The data provided by this interface is fallback data as the basis for the returned data.
[0061] Each of the second parameters in the parameter group is a parameter selected by the business personnel for the core interface.
[0062] S302: Call the data source interface to obtain a set of parameter values corresponding to the parameter group. The set of parameter values contains multiple parameter values, and each parameter value corresponds one-to-one with each second parameter.
[0063] It should be noted that the parameter value is the specific numerical value of the second parameter.
[0064] S303: Use the business parameter convention rule file to process the set of various parameter values and generate fallback data for the core interface.
[0065] Furthermore, when processing each set of parameter values using the business parameter convention rule file, for each second parameter in the parameter group, the first parameter corresponding to the second parameter and the conversion parameter name of the first parameter are determined in the business parameter convention rule;
[0066] For each parameter value in each set of parameter values, the parameter value is bound to the transformation parameter name of the first parameter corresponding to its second parameter, thereby obtaining the fallback data of the core interface.
[0067] In the method provided by this embodiment of the invention, when generating fallback data for the core data, the latest parameter values corresponding to the core interface can be obtained by calling the data source interface, thereby generating the latest fallback data.
[0068] S105: Based on the various fallback data, update the fallback database of the fallback service of the application to which the application configuration file belongs.
[0069] In the method provided by this invention, each piece of fallback data is updated to the fallback database of the application's fallback service, thereby completing the update of the fallback data. Furthermore, since this invention can be performed periodically, the fallback database is updated periodically. The update cycle can be set according to actual needs, and updating the data in the fallback database can be automated, requiring minimal manual intervention and reducing the cost of updating the fallback database, improving update efficiency, and providing users with a better experience using the fallback data.
[0070] In the method provided by this invention, the application configuration file in the configuration module is read according to a preset round-robin cycle; the application configuration file is parsed to obtain the configuration information of each interface; for each interface configuration information, a business parameter convention rule file for the core interface to which the interface configuration information belongs is generated and saved; for each core interface, the fallback data of the core interface is generated using the business parameter convention rule file and the interface configuration information; based on each fallback data, the fallback database of the fallback service of the application to which the application configuration file belongs is updated. By processing the application configuration file, the business parameter convention rule file and interface configuration information of each core interface of the application are obtained, and the fallback data is generated using the business parameter convention rule file and the interface configuration information. Finally, the fallback database is updated using the fallback data. Thus, it can be determined that the fallback data in the fallback database is constantly updated. The fallback database can be used to provide fallback data to users in the future. The fallback data provided to users is not static; the latest fallback data can be provided to users, bringing a better user experience.
[0071] It should be noted that after updating the fallback database with the various fallback data, the updated fallback database can be used to provide data to users, specifically as follows: Figure 4 The following is a flowchart illustrating a method for providing backup data to users, as provided in an embodiment of the present invention.
[0072] S401: When a data request belonging to the application is received by the user, the request domain name and request path in the data request are obtained.
[0073] It should be noted that when a user sends a data request belonging to the application, the request should be a filtered request, which may be a request that requires service degradation.
[0074] S402. Based on the request domain name and request path, determine whether there is a business parameter convention rule file corresponding to the data request; if there is a business parameter convention rule file corresponding to the data request, then execute S403; if there is no business parameter convention rule file corresponding to the data request, then execute S406.
[0075] When determining whether a business parameter convention rule file corresponding to a data request exists, a search directory can be generated using the data request domain name and request path. If the search directory does not contain a business parameter convention rule file, it is determined that no business parameter convention rule file corresponding to the data request exists. If the search directory contains a business parameter convention rule file, it is determined that a business parameter convention rule file corresponding to the data request exists.
[0076] S403: Use business parameter conventions to generate file paths.
[0077] The business parameter convention rules file is processed to generate the file path.
[0078] S404: Determine whether there is file data corresponding to the file path in the fallback database; if there is file data corresponding to the file path in the fallback database, then execute S405; if there is no file data corresponding to the file path in the fallback database, then execute S406.
[0079] S405: Feedback the file data corresponding to the file path in the fallback database to the user as the response data of the fallback service.
[0080] It should be noted that the response data provided to the user at this time is fallback data.
[0081] S406: Provides feedback to the user regarding the preset downgrade plan.
[0082] In the method provided by this invention, after receiving a data request from a user, the system uses the request domain name and request path in the data request to accurately determine whether a business parameter agreement rule file corresponding to the data request exists. If it does not exist, the system provides the user with another fallback solution. If it exists, the system uses the business parameter agreement rule file to generate a file path and sends the file data corresponding to the file path as response data back to the user. If no file data corresponding to the file path exists, the system sends the user another fallback solution, such as an HTTP Code 404 fallback solution or other executable solutions that can support the service. This maximizes the ability to continue providing services to the user. Furthermore, the response data sent back to the user is the latest data in the fallback database. Using the latest data ensures the continuity of services provided to the user and provides a better user experience.
[0083] Reference Figure 5 This is a schematic diagram of a fallback data processing device provided in an embodiment of the present invention. This structure can support the implementation of the aforementioned fallback data processing method in real life. The device can be installed in a computer terminal, such as... Figure 5 As shown, the device includes a configuration module 501, a data update module 502, and a data reading module 503;
[0084] The configuration module 501 is used to obtain the application's configuration data and generate the application's configuration file based on the configuration data;
[0085] The data update module 502 is used to read the application configuration file in the configuration module according to a preset round-robin cycle; parse the application configuration file to obtain the configuration information of each interface; for each interface configuration information, generate a business parameter convention rule file for the core interface to which the interface configuration information belongs, and save the business parameter convention rule file; for each core interface, use the business parameter convention rule file and interface configuration information of the core interface to generate fallback data for the core interface; and update the data to which the application configuration file belongs based on each fallback data.
[0086] The data reading module 503 is used to acquire data requests belonging to the application sent by the user, and based on the request domain name and request path in the data request, determine whether there is a business parameter convention rule file corresponding to the data request in the data update module; if there is a business parameter convention rule file corresponding to the data request, then use the business parameter convention rule file to generate a file path; determine whether there is file data corresponding to the file path in the data update module; if there is file data corresponding to the file path in the data update module, then use the file data corresponding to the file path in the data update module as the response data of the fallback service and feed it back to the user; if there is no file data corresponding to the file path in the data update module, then feed back a preset degradation scheme to the user.
[0087] Furthermore, the configuration module is used to provide an operation backend interface, set the core interface parameters and data sources for each application by application name, and generate a JSON file, which is the application configuration file.
[0088] The data update module is implemented using Lua timers. It reads the configured JSON file and generates a schema file for parameter mapping; calls the data source interface and obtains the fallback data returned by the data source; generates a file in the specified directory based on the configured domain host and parameters path and queryParam, and stores the fallback data in the file; and uses scheduled tasks to ensure real-time updates of configuration data and data source data.
[0089] The data reading module is implemented in the rewrite_by_lua_file block in Nginx. Internally, it uses Lua scripts to parse the host and parameters, read the schema file generated by the data update module, assemble the file name according to the schema, read the corresponding file and return it directly to the client.
[0090] By interacting with business logic through a configuration module to configure data sources, it provides fallback data services only to core interfaces defined by the business, saving fallback data storage space. A data update module provides real-time fallback data updates to the business. A data reading module directly locates the core interface data file requiring a response and quickly delivers the content to the client. This process defines a fallback data processing workflow that can be used by a large number of businesses, can be deployed arbitrarily regardless of data center, and saves significant human resources by providing fallback data services. The real-time fallback data update function enhances brand image and provides a user-friendly interactive experience.
[0091] It should be noted that, in the apparatus provided in this embodiment of the invention, the data update module in the fallback data processing device, when generating the business parameter convention rule file for the core interface to which the interface configuration information belongs, includes:
[0092] Determine the parameter convention rule field in the interface configuration information;
[0093] Determine the first parameters of the core interface to which the interface configuration information belongs in the application;
[0094] Based on preset parameter conversion fields, each of the first parameters is processed to obtain the business parameter convention rule file of the core interface to which the interface configuration information belongs.
[0095] In the apparatus provided in this embodiment of the invention, the data update module, when saving the business parameter agreement rule file, includes:
[0096] Obtain the domain name information and path information from the interface configuration information;
[0097] Using the domain name information and the path information, generate a file storage directory;
[0098] The business parameter convention rules file is saved based on the file storage directory.
[0099] In the apparatus provided in this embodiment of the invention, when the data update module generates fallback data for the core interface using the business parameter convention rule file and interface configuration information of the core interface, it includes:
[0100] Obtain the data source interface and parameter group of the core interface from the interface configuration information, wherein the parameter group contains multiple second parameters;
[0101] Call the data source interface to obtain a set of parameter values corresponding to the parameter group. The set of parameter values contains multiple parameter values, and each parameter value corresponds one-to-one with each second parameter.
[0102] Using the business parameter convention rule file, the various parameter value sets are processed to generate fallback data for the core interface.
[0103] To further illustrate the specific applications of the method provided by this invention in various other scenarios, this invention provides another implementation flow of the fallback data processing method, the specific flow of which is as follows:
[0104] Step 1: Configure the module to interact with the application access party. The application administrator fills in the application's domain name on the backend interface. If there are multiple domain names, they need to be filled in completely separated by commas. Fill in the Path and Param of the core interface. The Param parameter is defined in JSON format. For example, ParamA:param_a means to escape the ParamA parameter in the client request into the param_a parameter required by the data source. At the same time, configure the two interface addresses fallback_entity_url and fallback_data_url. This interface is the data source configuration for the fallback service provided by the business. The fallback_entity_url interface will return a list of core parameters and values, while the fallback_data_url interface can assemble and return the actual fallback content based on the parameters and values in fallback_entity_url.
[0105] Step 2: Based on the application administrator's configuration, the configuration module integrates all projects according to the rules and provides the complete application_A_fallback.json configuration file via an HTTP interface;
[0106] Step 3: The data update module is a module implemented in Lua. Its main function is to read the interface of the configuration module. The list data returned by the interface will list the configuration files of each interface. The multi-threaded processing of each application configuration is performed by traversing the data list.
[0107] Step 4: The data update module generates a directory based on the application's configuration information, using the host and path. This directory serves as the data storage directory for the application's current core interface. It reads the Param parameter definition and stores the parameters that need to be converted in a file named fallback_schema in the current directory.
[0108] Step 5: The data update module calls the fallback_entity_url interface to obtain the core data parameters defined by the business side for the downgraded data source to the current path, assembles the parameters into param, initiates a call to the fallback_data_url interface, and stores the content returned by the interface in ascending order according to the ASCII code of the parameters, such as param_a=1 ¶m_b=2 as the file name of the response content.
[0109] Step 6: The data reading module is a Lua code block of Niginx. It parses the host, path, param and other parameters of Nginx, locates the schema file based on the host and path, reads the contents of the schema file, obtains the key and value corresponding to the param of the client, and sorts the parameters in ascending order to get the target file name.
[0110] Step 7: The data reading module directly reads the target file name obtained in Step 6. If a file corresponding to the target file name exists, the file content is directly returned to the client as a response. If no file corresponding to the target file name exists, it means that the current interface is not a core data interface, and the business side accepts the fallback solution of directly returning HTTPCode=404.
[0111] For example, embodiments of the present invention also provide an architecture diagram for implementing a fallback data processing scenario, used to specifically illustrate the implementation process of the present invention in an application scenario, see reference. Figure 6 The following is a diagram illustrating the architecture of fallback data processing provided in an embodiment of the present invention, and is described in detail below:
[0112] Step 1: The fallback service is an independent service, separate from the business cluster. If the business cluster experiences an anomaly, all traffic at the traffic entry point, such as the gateway or load balancer, is forwarded to the independent fallback service. The fallback service requires each business to provide fallback interfaces for core data in order to quickly respond to user requests.
[0113] Step 2: All data for the fallback service is processed internally. As long as the rule data of the configuration module can be accessed, a set of real-time updated files for the fallback service can be generated independently, which can be quickly deployed and scaled up.
[0114] Step 3: Since only the operators of each business are most familiar with the core interfaces and core parameters of each application, the data configuration module is maintained by the business operations personnel of each application. The main responsibility of the data configuration module is to provide an operation management backend, where the business party fills in the interface host, path, parameter list, fallback data list and other information of its own core business, and finally provides an interface for the data update module to access. The interface uses the application name as the key and returns all configuration information under the application in JSON format.
[0115] Step 4: The data update module accesses the interface provided by the data configuration module to obtain the configuration information of each application. Each application is distinguished by a domain name. Based on the configuration information, the module generates a file directory for each interface and generates the required schema file in the file directory. Then, based on the parameters and interfaces provided in the configuration, the module traverses all interfaces to generate data files with specified parameter names. If the same application has multiple domain names, the first domain name is used as the main directory for storing data files, and symbolic links from other domain names point to the directory of the first domain name.
[0116] Step 5: The data reading module primarily uses an Nginx proxy service, supplemented by Lua scripts for logical processing. The Lua script first reads all parameters for GET / POST requests, then locates the directory based on the host and path. For RESTful paths, it recursively searches and removes unnecessary parameters until it finds a directory containing the schema file that is not a variable name. It then reads the schema file, removes the values of specified keys from the parameters, and assembles the values into a data file according to the keys in the schema file. After the Lua block reads the data file path, it directly returns it to Nginx, which is responsible for reading the actual file content and returning it to the client.
[0117] It should be noted that this invention provides some coding examples, the specific content of which is as follows:
[0118]
[0119] The above content constitutes part of the coded content provided by this invention.
[0120] Reference Figure 7 The following is a timing diagram of a fallback data processing method provided in an embodiment of the present invention, which is described in detail below:
[0121] Step 1: The operations staff configures the application's core interface information and the application's fallback data interface through the management backend.
[0122] Furthermore, after configuration, the overall program will look like this:
[0123]
[0124]
[0125] The above is an example code showing how operations personnel configure the application's core interface information and fallback data interface through the management backend.
[0126] Step 2: Based on the above configuration information, each application has an application-level interface configuration file. The data update module periodically reads the configuration interface information, determines the file storage path of the current interface based on the domain and path, generates a schema file based on the content of the fallback_schema field, and stores it in the file storage path of the current interface. Then, by reading the content of the data and entity interfaces, the core parameters are obtained from the entity interface, assembled into a request string to call the data interface. After obtaining the data, the parameters and schema are combined to generate a filename with the actual parameter key=value and sorted in ascending ASCII order. The file stores the content returned by the data interface, which is the fallback data returned when the client requests the fallback service.
[0127] Step 3: When the gateway or load balancer determines that a regular service needs to be downgraded, the specific downgrade method could be enabling a switch or detecting an anomaly during liveness detection. In this case, client request traffic will be directly forwarded to the Nginx proxy of the fallback service. At this time, the Lua data reading module based on Nginx begins to parse all the parameters of the client and finds the schema file according to the requested host and path. According to the parameter name conversion rules defined in the schema file, the actual parameters of the client are obtained. If the actual parameters are empty, an empty string is taken. The data is assembled into a complete fallback data file and then the file path is returned to Nginx. Nginx forwards the data to the specified directory, reads the file, and returns it. If the file exists, the core downgrade data of the core interface is hit, and the file content is returned directly. If the file is not hit, the HTTPCode=404 is returned directly, which means that no downgrade processing is required because the core data was not hit.
[0128] Furthermore, the core logic of the Lua script rewrite_by_lua_downgrade.lua is as follows:
[0129]
[0130]
[0131]
[0132] The above content constitutes the core logic code of the Lua script rewrite_by_lua_downgrade.lua.
[0133] Reference Figure 8 The following is a flowchart of a fallback data generation process provided by an embodiment of the present invention, the specific content of which is as follows:
[0134] Step 1: Read all application data in the configuration according to the interface provided by the configuration module, parse the host and path in the configuration, check if the data file directory under the corresponding application exists, and create the directory if it does not exist;
[0135] Step 2: Parse the `fallback_schema` parameter in the configuration file to generate a schema file. The filename is fixed as `schema`, and this name is a fixed value agreed upon with the reading module. The content of the schema file follows the format `key1 = transferKey1 & key2 = transferKey2`. The keys are sorted in ascending order of ASCII code and then connected with an equals sign `=` to form the parameter names to be converted. The first `key1` is the actual input parameter from the client, and the second `transferKey1` is the intermediate process parameter name to which the actual input parameter from the client is converted. Multiple parameters are concatenated with an ampersand (&).
[0136] Step 3: Parse the entityUrl in the configuration file, call the interface to get the parameter list of all core parameters; iterate through each group of parameters, assemble the parameters and proceed to the next step;
[0137] Step 4: Parse the dataUrl in the configuration file, use the parameters from the previous step as request parameters, call the dataUrl interface, compare the data returned by the interface with the configured success_key and success_code to determine if the interface request was successful. If the interface request is successful, concatenate the parameter values according to the schema rules into the format transferKey1=value1&transferKey2=value2. Similarly, the parameter names are sorted by ASCII value, and the rules are consistent with the conversion rules defined in the schema. Use this format as the filename to store all the content returned by dataUrl; this file is the fallback data file used when facing the client interface.
[0138] Reference Figure 9 The following is a flowchart of reading fallback data provided by an embodiment of the present invention, which is described in detail below:
[0139] Step 1: The gateway or load balancer forwards the degraded traffic to the fallback server. The server has Lua scripts embedded in Nginx. The Lua scripts parse the Host, Path and Param (the core parameters of the interface) of the client request.
[0140] Step 2: Convert Host and Path to directory names, check if a Schema file exists in the specified directory. If it exists, proceed to Step 3. If it does not exist, use a recursive approach to backtrack one level from the directory in Path and continue searching for a Schema file. If a Schema file is not found until Path contains only / , the current traffic is considered non-core traffic and a 404 error is returned directly.
[0141] Step 3: Extract the client parameter values corresponding to the parameter names in the schema, and assemble them into a complete file path according to the filenames defined in the schema file, such as: transferKey1 = value1 & transferKey2 = value2. The rule for assembling the path is as follows: the actual file is stored in / data / fallback / host / path / transferKey1 = value1 & transferKey2 = value2. The request path is rewritten using Nginx's built-in Lua syntax set_uri() function to / fallback / host / path / transferKey1 = value1 & transferKey2 = value2. Nginx will forward the request to the ^fallback block of the configuration block for processing, and the processing block will concatenate the / data / root directory. If the file exists, the file content is returned directly; if the file does not exist, a 404 response is sent.
[0142] This invention utilizes Lua scripts to implement real-time updates of fallback data. When a backend service experiences an anomaly, traffic is forwarded to a fallback server. The Nginx server on this fallback server then processes client request parameters and reads the specified data file using Lua scripts, quickly returning the fallback data. The business side defines the interfaces and parameters that need to be provided during service degradation through a configuration module. This ensures that the normal data response of core interfaces can provide users with impaired but sustainable service during business service failures, guaranteeing the normal use of core functions. The configuration module ultimately stores the data in JSON format on the server. The data update module reads the JSON configuration data and invokes the fallback function according to the configuration. The service interface stores its content as files in a specific directory and format according to the schema definition in the configuration. Simultaneously, the corresponding schema file is stored in the directory. The data update module uses a scheduled task to perform real-time updates of the fallback data, storing the updated files as text to the disk of the fallback server. The data reading module receives client requests, reads the specified schema configuration based on the host and path in the request, assembles the actual filename based on the queryConfig defined in the schema and the queryParam requested by the client, reads the file from the local disk of the fallback server, and directly returns the file content. In the method provided by this invention, business users only need to focus on which core business interfaces still need to provide services to users after the backend business server goes down, and configure the corresponding interfaces and their important parameters in the configuration module. By providing a fallback data source service, the business user can provide a powerful fallback data service, greatly simplifying the fallback service access process, providing a faster fallback data update mechanism, and enabling real-time updates of the fallback data, resulting in a better user experience for both businesses and users.
[0143] This invention also provides a storage medium that includes stored instructions, wherein the execution of the instructions controls the device containing the storage medium to perform the aforementioned fallback data processing method.
[0144] This invention also provides an electronic device, the structural schematic of which is shown below. Figure 10 As shown, it specifically includes a memory 601 and one or more instructions 602, wherein one or more instructions 602 are stored in the memory 601 and configured to be executed by one or more processors 603 to perform the above-mentioned fallback data processing method.
[0145] The specific implementation processes and derivative methods of the above embodiments are all within the protection scope of this invention.
[0146] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, for system or system embodiments, since they are basically similar to method embodiments, the description is relatively simple, and relevant parts can be referred to the descriptions in the method embodiments. The systems and system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0147] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0148] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily 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 invention. Therefore, the invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method of data processing, characterized in that, The application comprises the following steps: According to the preset wheel sequence cycle, read the application configuration file generated by the configuration module based on the application configuration data input by the business personnel; The application configuration file includes interface configuration information of at least one core interface of the application; the core interface configuration information includes data source interface information, parameter configuration, and core interface information; The application configuration file is parsed to obtain each interface configuration information; For each interface configuration information, a business parameter agreement rule file of the core interface to which the interface configuration information belongs is generated, and the business parameter agreement rule file is saved; For each core interface, the business parameter agreement rule file and the interface configuration information of the core interface are used to generate the bottom-up data of the core interface; The use of the business parameter agreement rule file and the interface configuration information of the core interface to generate the bottom-up data of the core interface comprises: Obtain the data source interface and parameter group of the core interface from the interface configuration information, and the parameter group contains multiple second parameters; Call the data source interface to obtain multiple parameter value sets corresponding to the parameter group, and the parameter value set contains multiple parameter values, each parameter value corresponding to each second parameter; Use the business parameter agreement rule file to process each parameter value set to generate the bottom-up data of the core interface; Based on each bottom-up data, update the bottom-up database of the bottom-up service of the application to which the application configuration file belongs.
2. The method of claim 1, wherein, Further comprising: When a data request belonging to the application sent by a user is obtained, determine whether there is a business parameter agreement rule file corresponding to the data request based on the request domain name and the request path in the data request; If there is a business parameter agreement rule file corresponding to the data request, use the business parameter agreement rule file to generate a file path; Determine whether there is file data corresponding to the file path in the bottom-up database; If there is file data corresponding to the file path in the bottom-up database, the file data corresponding to the file path in the bottom-up database is used as the response data of the bottom-up service to feedback to the user; If there is no file data corresponding to the file path in the bottom-up database, a preset degradation scheme is fed back to the user.
3. The method of claim 1, wherein, The generation of the business parameter agreement rule file of the core interface to which the interface configuration information belongs comprises: Determine the parameter agreement rule field in the interface configuration information; Determine each first parameter of the core interface belonging to the interface configuration information in the application; Based on the preset parameter conversion field, process each first parameter to obtain the business parameter agreement rule file of the core interface belonging to the interface configuration information.
4. The method of claim 1, wherein, The saving of the business parameter agreement rule file comprises: Obtain the domain name information and path information in the interface configuration information; Use the domain name information and the path information to generate a file saving directory; Save the business parameter agreement rule file based on the file saving directory.
5. A floor data processing apparatus characterized by comprising: The application comprises the following steps: The configuration module and the data update module; The configuration module is configured to obtain configuration data of an application input by a service personnel, and generate a configuration file of the application based on the configuration data; the application configuration file comprises interface configuration information of at least one core interface of the application; the core interface configuration information comprises data source interface information, parameter configuration, and core interface information; The data updating module is configured to read the application configuration file in the configuration module according to a preset round sequence period; The application configuration file is parsed to obtain each interface configuration information; for each interface configuration information, a service parameter agreement rule file of a core interface to which the interface configuration information belongs is generated, and the service parameter agreement rule file is saved; for each core interface, the service parameter agreement rule file and the interface configuration information of the core interface are used to generate bottom-up data of the core interface; based on each bottom-up data, a bottom-up database of a bottom-up service of an application to which the application configuration file belongs is updated; The data updating module comprises the following when using the service parameter agreement rule file and the interface configuration information of the core interface to generate the bottom-up data of the core interface: The data source interface and a parameter group of the core interface are obtained from the interface configuration information; the parameter group comprises a plurality of second parameters; The data source interface is called to obtain a plurality of parameter value sets corresponding to the parameter group; the parameter value sets comprise a plurality of parameter values, and each parameter value corresponds to each second parameter; The service parameter agreement rule file is used to process each parameter value set to generate the bottom-up data of the core interface.
6. The apparatus of claim 5, wherein, Further comprising: A data reading module: The data reading module is configured to obtain a data request of the application sent by a user, determine whether there is a service parameter agreement rule file corresponding to the data request in the data updating module based on a request domain name and a request path in the data request; if there is a service parameter agreement rule file corresponding to the data request, a file path is generated using the service parameter agreement rule file; it is judged whether there is file data corresponding to the file path in the data updating module; if there is file data corresponding to the file path in the data updating module, the file data corresponding to the file path in the data updating module is used as response data of the bottom-up service to feed back to the user; if there is no file data corresponding to the file path in the data updating module, a preset degradation scheme is fed back to the user.
7. The apparatus of claim 5, wherein, The data updating module comprises the following when generating the service parameter agreement rule file of the core interface to which the interface configuration information belongs: A parameter agreement rule field in the interface configuration information is determined; Each first parameter of the core interface to which the interface configuration information belongs in the application is determined; Each first parameter is processed based on a preset parameter conversion field to obtain the service parameter agreement rule file of the core interface to which the interface configuration information belongs.
8. The apparatus of claim 5, wherein, The data updating module comprises the following when saving the service parameter agreement rule file: Obtaining domain name information and path information in the interface configuration information; Generating a file saving directory using the domain name information and the path information; Saving the service parameter agreement rule file based on the file saving directory.
Citation Information
Patent Citations
Data disaster tolerance method and related device
CN110399249A
Interface calling method and device and related equipment
CN112948723A
Page display control method and device, storage medium and electronic equipment
CN113094136A