Configuration file processing method

By identifying and correcting hierarchical errors of configuration files in the service governance platform and using business code to correct the hierarchical structure of configuration files, the low robustness caused by configuration file errors in the existing technology is solved, ensuring the normal operation of the application and robustness.

CN119271296APending Publication Date: 2025-01-07AVATR CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411302633.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-18
Publication Date
2025-01-07

AI Technical Summary

Technical Problem

In the prior art, when the configuration file provided by the service governance platform is incorrect, the client cannot run normally, resulting in low robustness and the application may experience functional abnormalities or security risks.

Method used

By determining the error type of the initial configuration file, especially the hierarchical error, the target application's business code corrects the hierarchical information of the configuration item, obtains the target configuration file, and ensures that the configuration file is consistent with the hierarchical structure of the application, thereby ensuring the normality of the application. run.

Benefits of technology

Improves the robustness of the configuration process, avoids the problem of the application not running correctly due to incorrect configuration files, and ensures the normal startup and operation of the target application.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119271296A_ABST
    Figure CN119271296A_ABST
Patent Text Reader

Abstract

The embodiment of the invention relates to the technical field of computers, and discloses a configuration file processing method which comprises the following steps: firstly, determining an error type of an initial configuration file, and when the error type is a hierarchical error, determining target hierarchical information corresponding to a first configuration item according to a service code of a target application program; and modifying hierarchical information of a first configuration item in the initial configuration file into target hierarchical information, obtaining a target configuration file, and configuring the target application program according to the target configuration file. Wherein the initial configuration file is a configuration file corresponding to a target application program obtained from the service governance platform, and the first configuration item is a configuration item with a hierarchical error in the initial configuration file. By means of the technical scheme, normal operation of the target application program can be guaranteed, and robustness of the configuration process is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of computer technology, and in particular to a method for processing a configuration file. Background Art

[0002] Currently, the service governance platform provides the function of a configuration center, which allows environmental information to be configured on the server side, and the application service can obtain the configuration information in real time after integrating the client.

[0003] However, when the client receives an incorrect configuration from the server, it throws an exception and returns an empty map, which causes the application to fail to run normally and has low robustness. Summary of the invention

[0004] In view of the above problems, an embodiment of the present invention provides a method for processing a configuration file, which is used to solve the problem of low robustness in the prior art.

[0005] According to one aspect of an embodiment of the present invention, a method for processing a configuration file is provided, the method comprising:

[0006] Determine an error type of an initial configuration file, where the initial configuration file is a configuration file corresponding to a target application program obtained from a service governance platform;

[0007] If the error type is a level error, determining target level information corresponding to a first configuration item according to a business code of the target application, the first configuration item being a configuration item in the initial configuration file having the level error;

[0008] Modify the hierarchical information of the first configuration item in the initial configuration file to the target hierarchical information, and obtain the target configuration file;

[0009] The target application is configured according to the target configuration file.

[0010] According to another aspect of an embodiment of the present invention, a configuration file processing device is provided, including:

[0011] A first determination module is used to determine an error type of an initial configuration file, where the initial configuration file is a configuration file corresponding to a target application program obtained from a service governance platform;

[0012] A second determination module is configured to determine, if the error type is a level error, target level information corresponding to a first configuration item according to a business code of the target application program, where the first configuration item is a configuration item in the initial configuration file that has the level error;

[0013] A modification module, configured to modify the hierarchical information of the first configuration item in the initial configuration file to the target hierarchical information, and obtain a target configuration file;

[0014] A configuration module is used to configure the target application according to the target configuration file.

[0015] According to another aspect of an embodiment of the present invention, there is provided an electronic device, including:

[0016] A processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus;

[0017] The memory is used to store at least one executable instruction, and the executable instruction enables the processor to execute the operation of the configuration file processing method as described above.

[0018] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided, wherein the storage medium stores at least one executable instruction, and the executable instruction enables a processing device of an electronic device / configuration file to perform the following operations:

[0019] Determine an error type of an initial configuration file, where the initial configuration file is a configuration file corresponding to a target application program obtained from a service governance platform;

[0020] If the error type is a level error, determining target level information corresponding to a first configuration item according to a business code of the target application, the first configuration item being a configuration item in the initial configuration file having the level error;

[0021] Modify the hierarchical information of the first configuration item in the initial configuration file to the target hierarchical information, and obtain the target configuration file;

[0022] The target application is configured according to the target configuration file.

[0023] The embodiment of the present invention utilizes the characteristic that the hierarchical structure of each configuration item in the initial configuration file should be the same as the hierarchical structure of each configuration item in the business code of the target application. When a hierarchical error occurs in the initial configuration file, the initial configuration file is corrected using the business code of the target application, so that the target application can be subsequently configured based on the correct target configuration file, thereby ensuring the normal operation of the target application and improving the robustness of the configuration process.

[0024] The above description is only an overview of the technical solution of the embodiment of the present invention. In order to more clearly understand the technical means of the embodiment of the present invention, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the embodiment of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] The accompanying drawings are only used to illustrate the embodiments and are not to be considered as limiting the present invention. In addition, the same reference symbols are used to represent the same components throughout the accompanying drawings. In the accompanying drawings:

[0026] Figure 1 A flowchart showing a process of processing a configuration file provided by the prior art is shown;

[0027] Figure 2 A flowchart of a first embodiment of a method for processing a configuration file provided by the present invention is shown;

[0028] Figure 3 A flowchart of a second embodiment of the method for processing a configuration file provided by the present invention is shown;

[0029] Figure 4 A flowchart of a third embodiment of the method for processing a configuration file provided by the present invention is shown;

[0030] Figure 5 A flowchart of a fourth embodiment of the method for processing a configuration file provided by the present invention is shown;

[0031] Figure 6 A flowchart of a fifth embodiment of the method for processing a configuration file provided by the present invention is shown;

[0032] Figure 7 A schematic diagram showing the structure of an embodiment of a device for processing a configuration file provided by the present invention;

[0033] Figure 8 A schematic structural diagram of an embodiment of an electronic device provided by the present invention is shown. DETAILED DESCRIPTION

[0034] Exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present invention are shown in the drawings, it should be understood that the present invention can be implemented in various forms and should not be limited to the embodiments set forth herein.

[0035] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in the present invention are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards, and corresponding operation entrances shall be provided for users to choose to authorize or refuse.

[0036] In modern distributed system architecture, service governance platform plays a vital role. Service governance platform greatly improves the maintainability and scalability of the system by providing centralized configuration management, service registration and discovery mechanism, and real-time service health monitoring. Among them, Nacos is an open source platform designed for dynamic configuration, service release and service governance. As a leader in service governance platform, it provides important infrastructure for microservice architecture and helps developers easily build and manage native applications.

[0037] In addition to service governance, Nacos also provides the function of a configuration center, allowing environment information to be configured on the server side, and the application service can obtain configuration information in real time after integrating the client. For example, in the following specific scenarios, the client can obtain configuration information from Nacos:

[0038] Scenario 1, application initialization phase: When the application starts, the client needs to obtain the configuration file from Nacos to ensure that the application can be initialized based on the latest configuration parameters. This process is crucial to ensure the correct startup and operation of the application, because the configuration file contains environmental information such as database connection, cache settings, log level, etc.

[0039] Scenario 2, Configuration update notification response: When the configuration file is updated in Nacos, Nacos will notify the client through a push mechanism. After receiving the update notification, the client will actively download the latest configuration file from Nacos and dynamically load these configurations to implement hot updates of the configuration. This mechanism enables the application to adapt to the new configuration without restarting.

[0040] Scenario 3, periodic configuration synchronization: To ensure the consistency and real-time nature of the configuration, the client may set a scheduled task to periodically synchronize configuration files from Nacos. This periodic synchronization mechanism helps capture configuration changes that occur when configuration update notifications are not delivered in a timely manner, ensuring that the client always uses the latest configuration information.

[0041] However, since most configuration files are written by developers, they may contain errors. Alternatively, a correct configuration file may be changed by mistake during transmission, resulting in an error in the configuration file obtained by the client.

[0042] Figure 1 FIG. 1 shows a flow chart of the processing process of the configuration file provided by the prior art. Figure 1 As shown in the figure, the processing of the configuration file includes:

[0043] Step 110: Application service starts.

[0044] Step 120: The application service sends a request to Nacos to request to pull and parse the corresponding configuration file from Nacos.

[0045] If the request is successfully executed, step 130 is executed; if the request fails to be executed, it is determined that the application service startup fails.

[0046] Step 130: Confirm that the application service is started successfully and wait for Nacos to send the configuration file.

[0047] Step 140: Determine whether the configuration file is correct.

[0048] If it is correct, re-execute step 130; if it fails, an exception will be thrown and an empty map will be returned, which will cause all configurations obtained from Nacos to be rewritten as null values ​​(English: NULL) in the application. Since the configuration file contains a lot of environmental information, once an error occurs, all applications that reference this configuration file will crash directly, causing an avalanche effect in the production environment, which will take a long time to recover and affect the normal operation of the application.

[0049] In summary, when there are errors in the configuration file, the application may not start normally, or may have functional abnormalities during operation, and may even cause security risks. That is, when the client receives an incorrect configuration file, the prior art will have the technical problem that the application cannot run normally and has low robustness.

[0050] Based on the above technical problems, the technical concept of the present invention is as follows: Since the configuration file is manually written by developers, and the hierarchical structure between the configuration items in the configuration file is complex, the configuration file often has hierarchical errors. Considering that the hierarchical structure of each configuration item in the configuration file is the same as the hierarchical structure of each configuration item in the business code of the target application, when there is a hierarchical error in the configuration file, the configuration file can be modified based on the business code of the target business program, so that the hierarchical structure of each configuration item in the target configuration file obtained after the modification is the same as the hierarchical structure of each configuration item in the business code of the target application. In this way, the target application can be configured later through the correct configuration file (target configuration file), and the problem of the application failing to run correctly due to the wrong configuration file will not occur, which effectively improves the robustness of the configuration process.

[0051] The technical solution of the present invention is described in detail below through specific embodiments.

[0052] It should be noted that the following specific embodiments may be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.

[0053] Figure 2 FIG. 1 is a flow chart showing a first embodiment of a method for processing a configuration file provided by the present invention, wherein the method is executed by an electronic device. Figure 2 As shown, the method comprises the following steps:

[0054] Step 210: Determine the error type of the initial configuration file.

[0055] The execution subject of the embodiment of the present invention is an electronic device, which can be a terminal device, such as a laptop computer, a desktop computer, a tablet computer, etc., and can also be a server. In practical applications, whether the electronic device is a terminal device or a server can be determined according to actual conditions, and no specific limitation is imposed on this.

[0056] In this embodiment, the target application is pre-installed in the electronic device. In order to ensure the normal operation and timely update of the target application, the initial configuration file corresponding to the target application needs to be obtained from the service governance platform during the initialization phase and configuration update phase of the application. After obtaining the initial configuration file corresponding to the target application, the electronic device can first determine whether there is a problem with the initial configuration file, and correct it if it is determined that there is a problem with the initial configuration file, so that the target application can be configured based on the correct configuration file later to avoid the problem that the target application cannot run.

[0057] Among them, the configuration update stage can be that the electronic device obtains the updated configuration file (initial configuration file) from the service governance platform after the configuration file is updated, or it can be that the electronic device obtains the current configuration file (initial configuration file) from the service governance platform at a certain periodic interval.

[0058] Exemplarily, the service governance platform may be Nacos.

[0059] The configuration file contains environmental information related to the target application's operating environment, which is used to determine how the target application interacts with external systems and services and how to adjust itself in a specific hardware and software environment.

[0060] In actual applications, the environment information contained in the configuration file usually exists in the form of key-value pairs, where the "key" in the key-value pair is the configuration item in the configuration file, and the "value" is the configuration parameter.

[0061] Exemplarily, the configuration item may include at least one of the following:

[0062] Database connection configuration items: including the database's uniform resource locator (URL), user name, password, driver class name, etc., which are used to connect the application to the database.

[0063] Cache configuration items: involving the cache server address, port, cache policy, expiration time, etc., used to improve data access efficiency.

[0064] Log configuration items: including log level, log output format, log file path, log rotation strategy, etc., used to control log generation and storage.

[0065] Service discovery and load balancing configuration items: involving the address of the service registration center, service name, load balancing algorithm, etc., used for communication and load distribution between microservices.

[0066] Security configuration items: including encryption algorithms, keys, certificate paths, security protocols, etc., used to protect the security of data transmission and storage.

[0067] External service configuration items: Application Programming Interface (API) address, authentication information, call frequency limit, etc. involving third-party services, used for integration with external systems.

[0068] System parameter configuration items: including thread pool size, memory allocation, timeout settings, etc., used to optimize the performance and resource utilization of the target application.

[0069] Step 220: If the error type is a level error, determine the target level information corresponding to the first configuration item according to the business code of the target application.

[0070] The first configuration item is a configuration item having a hierarchical error in the initial configuration file.

[0071] In this step, when the error is determined to be a level error, a first configuration item with a level error may be determined in the initial configuration file. Then, according to the name of the first configuration item, the target level information corresponding to the first configuration item is determined from the business code of the target application.

[0072] Optionally, the target hierarchy information includes the hierarchy of the first configuration item in the business code of the target application, the parent configuration items included in the parent hierarchy of the configuration item, and the child configuration items included in the child hierarchy of the configuration item.

[0073] Exemplarily, assuming that the first configuration item with a hierarchical error in the initial configuration file is configuration item C, configuration item C is located in the business code of the target application. Afterwards, it is determined that the configuration item C is located at level 1 in the business code, the parent configuration items included in the parent level of level 1, and the child configuration items included in the child level of level 1.

[0074] Step 230: Modify the hierarchical information of the first configuration item in the initial configuration file to the target hierarchical information, and obtain the target configuration file.

[0075] In this step, the hierarchical information of the first configuration item may be modified according to the expression of the hierarchical relationship between the configuration items in the initial configuration file.

[0076] For example, assuming that the hierarchical relationship between configuration items in the initial configuration file is represented by the number of spaces, that is, the number of leading spaces of each configuration item determines its position in the hierarchical structure, then the hierarchical information of the first configuration item can be modified by adjusting its position and the number of leading spaces in the initial configuration file.

[0077] Based on the above example, assume that the initial configuration file is:

[0078] Configuration item 1

[0079] Configuration Item 2

[0080] Configuration item 3

[0081] Configuration item 4

[0082] If configuration item 4 is the first configuration item, its target level information is the second level, its parent level is configuration item 1, and there is no child level, then the target configuration file obtained after modifying the initial configuration file according to the target level information is:

[0083] Configuration item 1

[0084] Configuration Item 2

[0085] Configuration item 3

[0086] Configuration item 4

[0087] Step 240: Configure the target application according to the target configuration file.

[0088] In this step, the target configuration file can be read and the first configuration can be loaded into the memory. After that, the key-value pairs of the target configuration file are converted into an internal representation that can be understood by the target application using a parser to obtain the converted target configuration file. After that, according to the hierarchical relationship of the configuration items, the configuration parameters corresponding to each configuration item in the converted target configuration file are recursively assigned to the target application.

[0089] Optionally, after the target application is configured according to the target configuration file, the target configuration file may be cached.

[0090] The target configuration file may be stored in a local storage space of the electronic device, or in a data device independent of the electronic device, such as a database, a cache system, etc. It may be determined according to actual conditions, and the embodiment of the present invention does not specifically limit it.

[0091] When a target profile is to be cached, the target profile may also be bound to a target application.

[0092] The target configuration file is cached so that when there is a problem with the configuration file used next time and it cannot be corrected, the target configuration file can be called to configure the target application to achieve version rollback and ensure the normal operation of the target application, further improving the robustness of the configuration process.

[0093] The configuration file processing method provided in the embodiment of the present invention first determines the error type of the initial configuration file. When the error type is a hierarchical error, the target hierarchical information corresponding to the first configuration item is determined according to the business code of the target application. Then, the hierarchical information of the first configuration item in the initial configuration file is modified to the target hierarchical information, the target configuration file is obtained, and the target application is configured according to the target configuration file. Among them, the initial configuration file is a configuration file corresponding to the target application obtained from the service governance platform, and the first configuration item is a configuration item with a hierarchical error in the initial configuration file. In this technical solution, the characteristic that the hierarchical structure of each configuration item in the initial configuration file should be the same as the hierarchical structure of each configuration item in the business code of the target application is utilized. When a hierarchical error occurs in the initial configuration file, the business code of the target application is used to correct the initial configuration file, so that the target application can be configured based on the correct target configuration file later, which ensures the normal operation of the target application and improves the robustness of the configuration process.

[0094] Figure 3 FIG. 1 is a flow chart showing a second embodiment of a method for processing a configuration file provided by the present invention, wherein the method is executed by an electronic device. Figure 3 As shown, the method comprises the following steps:

[0095] Step 210: Determine the error type of the initial configuration file.

[0096] In a possible implementation, the format consistency verification can be performed on the initial configuration file according to a preset format to obtain a verification result. Then, the error type of the configuration file is determined according to the verification result.

[0097] Among them, format consistency verification refers to checking whether the content of the initial configuration file conforms to the predefined structure and format specifications, that is, whether it conforms to the preset format.

[0098] Exemplarily, the preset format may include at least one of the following:

[0099] The representation of key-value pairs (for example, the separator between the key and the value), data types (for example, the parameter value corresponding to a configuration item should be an integer), nested structures, required configuration items, and naming conventions for configuration items.

[0100] It should be understood that the preset formats corresponding to different application programs may be the same or different, which may be determined based on actual conditions.

[0101] In a possible implementation, format consistency verification of the initial configuration file not only verifies whether the initial configuration file meets the preset format, but also needs to verify whether the initial configuration file contains configuration items that do not exist in the business code of the target application. For example, assuming that the initial configuration file contains configuration item A, but the business code of the target application does not contain configuration item A, it is considered that the initial configuration file has failed the format consistency verification.

[0102] Optionally, the error types of the initial configuration file include level error, configuration item duplication error, and format error. Next, the level error, configuration item duplication error, and format error are explained in detail:

[0103] Format error: If the verification result indicates that the initial configuration file fails the format consistency verification, it is determined that the error type of the initial configuration file is a format error.

[0104] Configuration item duplication error: If the verification result indicates that the initial configuration file passes the format consistency verification and there is a duplicate second configuration item in the initial configuration file, it is determined that the error type of the initial configuration file is a configuration item duplication error.

[0105] Exemplarily, assuming that there are two identical second configuration items in the initial configuration file, namely configuration item 1 and configuration item 2, the error type of the initial configuration file is determined to be a configuration item duplication error.

[0106] It should be understood that two identical second configuration items refer to that the names of the two second configuration items are consistent and the level information of the two second configuration items is also the same.

[0107] Hierarchy error: If the verification result indicates that the initial configuration file passes the format consistency verification, and the hierarchy information of the first configuration item in the initial configuration file is inconsistent with the hierarchy information in the business code, it is determined that the error type of the initial configuration file is a hierarchy error.

[0108] Among them, the hierarchy of configuration items in the configuration file and the hierarchy of configuration items in the business code refer to the nesting depth of the configuration item in the text structure. Specifically, the hierarchy includes the top level (first level) and sub-levels (second level, third level, fourth level, etc.). The top-level configuration items are the outermost elements in the text structure. They are not nested in any other configuration items or data structures. Each sub-level configuration item is located inside its parent level configuration item, forming a hierarchical structure. It should be understood that this nested structure helps to further refine complex configuration items.

[0109] In the process of configuring the application, it is necessary to locate the corresponding configuration item from the business code according to the configuration item in the configuration file. In order to improve the accuracy and speed of the positioning process, the hierarchical information of the configuration item in the configuration file can be determined first, and the configuration item can be found in the business code based on the hierarchical information, and then the configuration parameter corresponding to the configuration item in the configuration file is assigned to the configuration item determined in the business code.

[0110] However, since most configuration files are written manually and the nested relationship between configuration items is relatively complex, it is difficult to ensure the rigor of the manual writing process, which may cause problems with the hierarchy of configuration items in the configuration file. According to the above process of configuring the application, the accuracy of the hierarchical information of each configuration item in the configuration file determines whether the target application can be successfully configured. Therefore, when determining the error type of the initial configuration file, it is also necessary to determine whether there is a hierarchical error in the initial configuration file.

[0111] When there is an error in the initial configuration file, the error type of the initial configuration file is determined so that the initial configuration file can be corrected based on the determined error type, or the version of the target application can be reviewed to ensure that the target application can apply the correct configuration file to avoid affecting the normal operation of the target application.

[0112] It should be understood that determining whether there are errors in the initial configuration file and the types of errors that exist can be achieved by parsing the initial configuration file. Specifically, if there is an error in parsing the initial configuration file, the error type of the initial file is determined to be a format error or a hierarchy error based on the cause of the parsing error; if duplicate configuration items are encountered when parsing the initial configuration file, the error type of the initial configuration file is determined to be a configuration item duplication error.

[0113] It should be understood that other concepts and principles of this step can be parameterized Figure 2 The relevant contents of step 210 are not repeated here.

[0114] Step 320: If the error type is a configuration item duplication error, the target application is configured according to the second configuration item with the latest modification time in the initial configuration file.

[0115] In this step, considering that when developers are writing the initial configuration file, if they want to add configuration parameters of a configuration item, they need to first determine whether the configuration item already exists in the current initial configuration file. If the configuration item already exists in the current initial configuration file, the configuration parameters of the configuration item can be modified. If the configuration item does not exist in the current initial configuration file, it is necessary to add the configuration item and the corresponding configuration parameters in the current initial configuration file. However, since the entire process is implemented manually, the accuracy of the processing cannot be guaranteed, that is, when the configuration item exists in the current initial configuration file, due to human error, it is judged that the configuration item does not exist in the current initial configuration file, and therefore the same configuration item is mistakenly written repeatedly in the current initial configuration file. Based on this consideration, if the error type is a configuration item duplication error, that is, there is a duplicate second configuration item in the initial configuration file, the configuration item with a later modification time is the configuration item that the developer wants to take effect in the target application, that is, the configuration item required by the target application, so it is necessary to configure the target application according to the second configuration item with the latest modification time in the initial configuration file.

[0116] In a possible implementation, the second configuration item with the latest modification time in the initial configuration file may be retained, and other second configuration items may be deleted, thereby obtaining a configuration file after deletion. Thereafter, the target application is configured based on the configuration file after deletion.

[0117] Optionally, after obtaining the deleted configuration file, the deleted configuration file may also be cached.

[0118] In another possible manner, during the process of configuring the target application according to the initial configuration file, if the second configuration item in the initial configuration file is read and the configuration parameters of the second configuration item in the target application have been configured, the first modification time of the second configuration item being read and the second modification time of the second configuration item that has been applied are determined. If the first modification time is later than the second modification time, the configuration parameters in the target application are overwritten according to the configuration parameters of the second configuration item being read; if the first modification time is earlier than the second modification time, the configuration parameters of the second configuration item in the target application are maintained.

[0119] Exemplarily, it is assumed that there are two identical second configuration items in the initial configuration file, namely configuration item 1 and configuration item 2, the modification time of configuration item 1 is time 1, the modification time of configuration item 2 is time 2, and time 1 is earlier than time 2. When configuring the target application according to the initial configuration file, it is assumed that configuration item 1 is read first, and the target application is configured according to configuration item 1. After that, configuration item 2 is read continuously, and since time 2 is later than time 1, the configuration parameters of configuration item 2 are used to reconfigure the target application, overwriting the configuration of configuration item 1 for the target application.

[0120] In the above embodiment, when it is determined that the error type of the initial configuration file is a configuration item duplication error, the modification time of the repeated second configuration item can be used to determine based on which second configuration item the target application is to be configured, thereby avoiding erroneous overwriting of configuration parameters, ensuring the normal operation of subsequent target applications, and improving the robustness of the configuration process.

[0121] Figure 4 FIG. 4 is a flow chart showing a third embodiment of a method for processing a configuration file provided by the present invention, wherein the method is executed by an electronic device. Figure 4 As shown, the method comprises the following steps:

[0122] Step 210: Determine the error type of the initial configuration file.

[0123] It should be understood that the specific implementation process and principle of this step can be parameterized. Figure 2 and Figure 3 The relevant contents of step 210 are not repeated here.

[0124] Step 420: If the error type is a format error, the target application is configured according to the configuration file in the cache.

[0125] In this step, it is difficult to modify the initial configuration file because its format requirements are relatively complex. Considering that the target application will be configured according to the parsed configuration items while the initial configuration file is being parsed, it is necessary to roll back the target application to restore it to the version before configuration to prevent configuration conflicts.

[0126] In a possible implementation, the target application may be configured using the configuration file of the target application in the cache, thereby implementing version rollback.

[0127] Optionally, the cached configuration file can be obtained from the local storage space of the electronic device, or from a data device independent of the electronic device. It should be understood that the method of obtaining the cached configuration file can be determined based on the cache address of the pre-configured target application, which will not be repeated here.

[0128] In the above embodiment, for error types that are more difficult to correct, the target application can be configured according to the pre-cached configuration file corresponding to the target application to achieve version rollback, avoid the problem of the target application not being able to run normally due to the application of an erroneous configuration file, and further improve the robustness of the configuration process.

[0129] Optionally, in some embodiments, when it is determined that the initial configuration file has an error, an error message may also be output.

[0130] The error information is used to describe the error existing in the initial configuration file and the error type.

[0131] Optionally, the error information may be outputted by sending the error information to a service governance platform, or by sending the error information to a terminal device used by a developer so that the developer can view the error information.

[0132] By outputting error information, the developer is reminded that there is a problem with the initial configuration file, thereby reminding the developer to correct it.

[0133] Furthermore, after viewing the error message, the developer can modify the initial configuration file based on the error type indicated in the error message to generate a modified configuration file, and publish the modified configuration file through the service governance platform. Correspondingly, for electronic devices, it is necessary to configure and update the target application according to the modified configuration file published by the service governance platform.

[0134] Next, through Figure 5 Explain the configuration update process.

[0135] Figure 5 FIG. 4 is a flowchart of a fourth embodiment of a method for processing a configuration file provided by the present invention, wherein the method is executed by an electronic device. Figure 5 As shown, the method comprises the following steps:

[0136] Step 510: Obtain the modified configuration file.

[0137] In this step, after the relevant staff publishes the modified configuration file in the service management platform, the service management platform will send the modified configuration file to the electronic device. Correspondingly, for the electronic device, the modified configuration file is obtained from the service management platform.

[0138] Optionally, after detecting the modified configuration file, the service governance platform can directly send the modified configuration file to the electronic device, and can also send an update reminder to the electronic device, and after receiving a confirmation update message returned by the electronic device, send the modified configuration file to the electronic device.

[0139] Step 520: If the modified configuration file is different from the cached configuration file, reconfigure the target application based on the modified configuration file.

[0140] In this step, if the modified configuration file is the same as the cached configuration file, it means that the target application does not need to be updated. If the modified configuration file is different from the cached configuration file, the target application needs to be updated according to the modified configuration file.

[0141] In actual applications, the target application is updated according to the modified configuration file, mainly by determining the modified configuration file as the new initial configuration file, and then Figures 2 to 4 The embodiment shown implements.

[0142] Specifically, the modified configuration file can be determined as a new initial configuration file, and if the new initial configuration file has no errors, the target application is directly configured based on the new initial configuration file. If the new initial configuration file has errors, the error type of the new initial configuration file is determined.

[0143] If the error type is a layer error, the new initial configuration file is modified according to the business code of the target application to obtain a new target configuration file, and then the target application is configured according to the new target configuration file.

[0144] If the error type is a configuration item duplication error, the target application is configured according to the configuration item with the latest modification time among the duplicate configuration items.

[0145] If the error type is format error, the target application is configured according to the configuration file in the cache.

[0146] In the above embodiment, after the developer has modified the initial configuration file, the target application can be updated based on the modified configuration file, so that the target application can use the updated and more accurate configuration, provide users with more accurate and more services, and thus improve the user's experience of using the target application. In addition, since the modified configuration file used in the configuration update is more accurate, the normal operation of the target application is further guaranteed, and the robustness of the configuration process is improved.

[0147] Next, a specific example is used to describe the method for processing the configuration files shown in the above embodiments.

[0148] Figure 6 FIG. 5 is a flowchart of a fifth embodiment of a method for processing a configuration file provided by the present invention, wherein the method is executed by an electronic device. Figure 6 As shown, the method comprises the following steps:

[0149] Step 601: Application starts.

[0150] When the application is successfully started for the first time, the configuration file is cached in memory as a copy.

[0151] Step 602: Pull the initial configuration file from the service governance platform.

[0152] If the initial configuration file can be pulled, step 603 is executed; if the initial configuration file cannot be pulled, the startup fails.

[0153] Step 603: Parse the initial configuration file.

[0154] If the initial configuration file cannot be parsed, step 604 is executed; if duplicate configuration items are encountered when parsing the initial configuration file, step 610 is executed; if the initial configuration file is parsed successfully, step 611 is executed.

[0155] Step 604: Determine the error type of the initial configuration file according to the preset format and the service code of the target application.

[0156] If the initial configuration file does not meet the preset format, or the initial configuration file contains configuration items that do not exist in the business code of the target application, the error type is determined to be a format error, and step 605 is executed.

[0157] Further, if the level information of the configuration item in the initial configuration file is inconsistent with the level information of the configuration item in the business code of the target application, the error type is determined to be a level error, and step 607 is executed.

[0158] Step 605: Obtain a copy from the cache, and configure the target application according to the copy.

[0159] Step 606: Throw out an error message.

[0160] Step 607: According to the hierarchical relationship of each configuration item in the business code of the target application, the initial configuration file is modified to generate target configuration information.

[0161] Step 608: Configure the target application based on the target configuration information.

[0162] Step 609: Cache the target configuration information in the memory as a copy.

[0163] Step 610: Use the configuration item with a later modification time among the repeated configuration items to configure the target application.

[0164] That is, during the configuration process of the target application, for the same configuration items, the old configuration parameters are overwritten with the new configuration parameters.

[0165] Step 611: Configure the target application based on the initial configuration file.

[0166] Step 612: Cache the initial application in memory as a copy.

[0167] Compared with the prior art, when an error occurs in the initial configuration file, the target application will directly crash and the service will be unavailable. However, in the present invention, an attempt is made to correct the erroneous configuration file and issue an alarm. If the modification fails, the last cached configuration file is used. The service is still available during the whole process and will not cause a service avalanche.

[0168] Figure 7 FIG. 2 is a schematic diagram showing a structure of an embodiment of a device for processing a configuration file provided by the present invention. Figure 7 As shown, the configuration file processing device 700 includes: a first determination module 710, a second determination module 720, a modification module 730 and a configuration module 740.

[0169] The first determination module 710 is used to determine the error type of the initial configuration file, where the initial configuration file is a configuration file corresponding to the target application program obtained from the service governance platform.

[0170] The second determination module 720 is used to determine the target level information corresponding to the first configuration item according to the business code of the target application program if the error type is a level error, where the first configuration item is a configuration item with a level error in the initial configuration file.

[0171] The modification module 730 is used to modify the level information of the first configuration item in the initial configuration file to the target level information, and obtain the target configuration file.

[0172] The configuration module 740 is used to configure the target application according to the target configuration file.

[0173] In an optional manner, the first determining module 710 is specifically configured to:

[0174] According to the preset format, the format consistency of the initial configuration file is verified to obtain the verification result;

[0175] Based on the verification result, determine the error type of the configuration file.

[0176] In an optional manner, the first determining module 710 is specifically configured to:

[0177] If the verification result indicates that the initial configuration file passes the format consistency verification, and the hierarchy information of the first configuration item in the initial configuration file is inconsistent with the hierarchy information in the business code, it is determined that the error type of the initial configuration file is a hierarchy error.

[0178] In an optional manner, the first determining module 710 is specifically configured to:

[0179] If the verification result indicates that the initial configuration file fails the format consistency verification, it is determined that the error type of the initial configuration file is a format error.

[0180] In an optional manner, the first determining module 710 is specifically configured to:

[0181] If the verification result indicates that the initial configuration file passes the format consistency verification and there is a duplicate second configuration item in the initial configuration file, it is determined that the error type of the initial configuration file is a configuration item duplication error.

[0182] In an optional manner, the configuration module 740 is further configured to:

[0183] If the error type is a configuration item duplication error, the target application is configured according to the second configuration item with the latest modification time in the initial configuration file.

[0184] In an optional manner, the configuration file processing device 700 further includes:

[0185] The cache module is used to cache the target configuration file.

[0186] In an optional manner, the configuration module 740 is further configured to:

[0187] If the error type is format error, the target application is configured according to the configuration file in the cache.

[0188] In an optional manner, the configuration file processing device 700 further includes:

[0189] The output module is used to output error information, which is used to explain the errors and error types in the initial configuration file.

[0190] In an optional manner, the configuration module 740 is further configured to:

[0191] Get the modified configuration file.

[0192] If the modified configuration file is different from the cached configuration file, the target application is reconfigured based on the modified configuration file.

[0193] The configuration file processing device determines the error type of the initial configuration file and modifies the initial configuration file according to different error types. Specifically, for hierarchical errors, the hierarchical structure of each configuration item in the initial configuration file should be the same as the hierarchical structure of each configuration item in the business code of the target application. When a hierarchical error occurs in the initial configuration file, the business code of the target application is used to modify the initial configuration file. When the initial configuration file cannot be modified, the target application is rolled back to the previous version of the configuration, which ensures the normal operation of the target application and improves the robustness of the configuration process.

[0194] Figure 8 The schematic diagram of the structure of an embodiment of the electronic device provided by the present invention is shown, and the specific embodiment of the present invention does not limit the specific implementation of the electronic device.

[0195] like Figure 8 As shown, the electronic device may include: a processor (processor) 802 , a communication interface (Communications Interface) 804 , a memory (memory) 806 , and a communication bus 808 .

[0196] The processor 802, the communication interface 804, and the memory 806 communicate with each other via a communication bus 808. The communication interface 804 is used to communicate with other devices such as a client or other server network elements. The processor 802 is used to execute a program 810, which can specifically execute the relevant steps in the above-mentioned embodiment of the method for processing a configuration file.

[0197] Specifically, the execution program 810 may include program code, which includes computer executable instructions.

[0198] The processor 802 may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention. The one or more processors included in the electronic device may be processors of the same type, such as one or more CPUs; or processors of different types, such as one or more CPUs and one or more ASICs.

[0199] The memory 806 is used to store the program 810. The memory 806 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.

[0200] Program 810 may be specifically called by processor 802 to enable the electronic device to perform the following operations:

[0201] Determine the error type of the initial configuration file, which is the configuration file corresponding to the target application obtained from the service governance platform;

[0202] If the error type is a level error, determining the target level information corresponding to the first configuration item according to the business code of the target application, the first configuration item being the configuration item with a level error in the initial configuration file;

[0203] Modify the hierarchical information of the first configuration item in the initial configuration file to the target hierarchical information, and obtain the target configuration file;

[0204] The target application is configured according to the target configuration file.

[0205] In an optional manner, determining the error type of the initial configuration file includes:

[0206] Verify the format consistency of the initial configuration file according to the preset format;

[0207] If the initial configuration file fails the format consistency verification, then the error type of the initial configuration file is determined to be a format error;

[0208] If the initial configuration file passes the format consistency verification and there is a duplicate second configuration item in the initial configuration file, determining that the error type of the initial configuration file is a configuration item duplication error;

[0209] If the initial configuration file passes the format consistency verification, and the hierarchy information of the first configuration item in the initial configuration file is inconsistent with the hierarchy information in the business code, it is determined that the error type of the initial configuration file is a hierarchy error.

[0210] In an optional manner, the program 810 is called by the processor 802 to enable the electronic device to perform the following operations:

[0211] If the error type is a configuration item duplication error, the target application is configured according to the second configuration item with the latest modification time in the initial configuration file.

[0212] In an optional manner, the program 810 is called by the processor 802 to enable the electronic device to perform the following operations:

[0213] Cache the target configuration file.

[0214] In an optional manner, the program 810 is called by the processor 802 to enable the electronic device to perform the following operations:

[0215] If the error type is format error, the target application is configured according to the configuration file in the cache.

[0216] In an optional manner, the program 810 is called by the processor 802 to enable the electronic device to perform the following operations:

[0217] Output error information, which is used to explain the errors and error types in the initial configuration file.

[0218] Get the modified configuration file;

[0219] If the modified configuration file is different from the cached configuration file, the target application is reconfigured based on the modified configuration file.

[0220] In an optional manner, the program 810 is called by the processor 802 to enable the electronic device to perform the following operations:

[0221] The electronic device corrects the initial configuration file according to different error types, or rolls back the target application to the previous version of the configuration when the initial configuration file cannot be corrected, thereby ensuring the normal operation of the target application and improving the robustness of the configuration process.

[0222] An embodiment of the present invention provides a computer-readable storage medium storing at least one executable instruction. When the executable instruction is executed on a processing device of an electronic device / configuration file, the processing device of the electronic device / configuration file executes the configuration file processing method in any of the above method embodiments.

[0223] The executable instructions may be specifically used to enable the processing device of the electronic device / configuration file to perform the following operations:

[0224] If the error type is a level error, determining the target level information corresponding to the first configuration item according to the business code of the target application, the first configuration item being the configuration item with a level error in the initial configuration file;

[0225] Modify the hierarchical information of the first configuration item in the initial configuration file to the target hierarchical information, and obtain the target configuration file;

[0226] The target application is configured according to the target configuration file.

[0227] In an optional manner, determining the error type of the initial configuration file includes:

[0228] Verify the format consistency of the initial configuration file according to the preset format;

[0229] If the initial configuration file fails the format consistency verification, then the error type of the initial configuration file is determined to be a format error;

[0230] If the initial configuration file passes the format consistency verification and there is a duplicate second configuration item in the initial configuration file, determining that the error type of the initial configuration file is a configuration item duplication error;

[0231] If the initial configuration file passes the format consistency verification, and the hierarchy information of the first configuration item in the initial configuration file is inconsistent with the hierarchy information in the business code, it is determined that the error type of the initial configuration file is a hierarchy error.

[0232] In an optional manner, the executable instruction may be specifically used to enable the processing device of the electronic device / configuration file to perform the following operations:

[0233] If the error type is a configuration item duplication error, the target application is configured according to the second configuration item with the latest modification time in the initial configuration file.

[0234] In an optional manner, the executable instruction may be specifically used to enable the processing device of the electronic device / configuration file to perform the following operations:

[0235] Cache the target configuration file.

[0236] In an optional manner, the executable instruction may be specifically used to enable the processing device of the electronic device / configuration file to perform the following operations:

[0237] If the error type is format error, the target application is configured according to the configuration file in the cache.

[0238] In an optional manner, the executable instruction may be specifically used to enable the processing device of the electronic device / configuration file to perform the following operations:

[0239] Output error information, which is used to explain the errors and error types in the initial configuration file.

[0240] Get the modified configuration file;

[0241] If the modified configuration file is different from the cached configuration file, the target application is reconfigured based on the modified configuration file.

[0242] In an optional manner, the executable instruction may be specifically used to enable the processing device of the electronic device / configuration file to perform the following operations:

[0243] The computer-readable storage medium modifies the initial configuration file according to different error types, or rolls back the target application to the previous version of the configuration when the initial configuration file cannot be modified, thereby ensuring the normal operation of the target application and improving the robustness of the configuration process.

[0244] The algorithms or displays provided herein are not inherently related to any particular computer, virtual system or other device. In addition, the embodiments of the present invention are not directed to any particular programming language.

[0245] In the description provided herein, a large number of specific details are described. However, it is understood that embodiments of the present invention can be practiced without these specific details. Similarly, in order to simplify the present invention and help understand one or more of the various inventive aspects, in the above description of exemplary embodiments of the present invention, the various features of the embodiments of the present invention are sometimes grouped together into a single embodiment, figure, or description thereof. Wherein, the claims that follow the specific embodiment are hereby expressly incorporated into the specific embodiment, wherein each claim itself is a separate embodiment of the present invention.

[0246] Those skilled in the art will appreciate that the modules in the devices in the embodiments may be adaptively changed and arranged in one or more devices different from the embodiments. The modules or units or components in the embodiments may be combined into one module or unit or component, and further may be divided into a plurality of submodules or subunits or subcomponents. Except that at least some of such features and / or processes or units are mutually exclusive.

[0247] It should be noted that the above embodiments illustrate the present invention rather than limit it, and that those skilled in the art may devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference symbol between brackets shall not be construed as a limitation on the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "one" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present invention may be implemented by means of hardware comprising a number of different elements and by means of a suitably programmed computer. In a unit claim enumerating a number of devices, several of these devices may be embodied by the same hardware item. The use of the words first, second, and third, etc. does not indicate any order. These words may be interpreted as names. The steps in the above embodiments, unless otherwise specified, should not be understood as limitations on the order of execution.

Claims

1. A method for processing a configuration file, characterized in that: The method comprises: Determine an error type of an initial configuration file, where the initial configuration file is a configuration file corresponding to a target application program obtained from a service governance platform; If the error type is a level error, determining target level information corresponding to a first configuration item according to a business code of the target application, the first configuration item being a configuration item in the initial configuration file having the level error; Modify the hierarchical information of the first configuration item in the initial configuration file to the target hierarchical information, and obtain the target configuration file; The target application is configured according to the target configuration file.

2. The method according to claim 1, characterized in that The determining of the error type of the initial configuration file includes: According to a preset format, format consistency verification is performed on the initial configuration file to obtain a verification result; According to the verification result, an error type of the configuration file is determined.

3. The method according to claim 2, characterized in that Determining the error type of the configuration file according to the verification result includes: If the verification result indicates that the initial configuration file passes the format consistency verification, and the hierarchy information of the first configuration item in the initial configuration file is inconsistent with the hierarchy information in the business code, it is determined that the error type of the initial configuration file is a hierarchy error.

4. The method according to claim 2, characterized in that: Determining the error type of the configuration file according to the verification result includes: If the verification result indicates that the initial configuration file fails the format consistency verification, it is determined that the error type of the initial configuration file is a format error.

5. The method according to claim 2, characterized in that: Determining the error type of the configuration file according to the verification result includes: If the verification result indicates that the initial configuration file passes the format consistency verification and there is a repeated second configuration item in the initial configuration file, it is determined that the error type of the initial configuration file is a configuration item duplication error.

6. The method according to claim 5, characterized in that The method further comprises: If the error type is a configuration item duplication error, the target application is configured according to the second configuration item with the latest modification time in the initial configuration file.

7. The method according to claim 3, characterized in that The method further comprises: The target configuration file is cached.

8. The method according to claim 4, characterized in that The method further comprises: If the error type is a format error, the target application is configured according to the configuration file in the cache.

9. The method according to any one of claims 1 to 8, characterized in that: The method further comprises: Output error information, where the error information is used to describe the error existing in the initial configuration file and the error type.

10. The method according to any one of claims 1 to 8, characterized in that: The method further comprises: Get the modified configuration file; If the modified configuration file is different from the cached configuration file, the target application is reconfigured based on the modified configuration file.