Configuration information acquisition method and device, computer equipment and storage medium

By identifying and building a syntax tree from the configuration files and dynamically generating configuration information, the problem of difficult configuration files in the existing technology is solved, and flexible and accurate configuration management is realized to adapt to different needs and environments.

CN120276764APending Publication Date: 2025-07-08CHINA TELECOM CLOUD TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510379351.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-28
Publication Date
2025-07-08

AI Technical Summary

Technical Problem

In the prior art, configuration files are difficult to achieve dynamic adjustment, configuration complexity is high, configuration file generation and management are complex, configuration items are difficult to cover all possible situations, and configuration file publishers need to learn DSL.

Method used

By identifying the configuration information identifier from the configuration file, obtaining the corresponding code text for syntax analysis, building an initial syntax tree, and compiling the script execution process to form a target syntax tree, traversing the target syntax tree based on configuration requests, and dynamically generating configuration information.

Benefits of technology

Dynamic configuration management is realized, configuration flexibility and accuracy is improved, manual intervention is reduced, complex scripts are supported, different configuration environments are adapted to the effectiveness and accuracy of configuration information.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120276764A_ABST
    Figure CN120276764A_ABST
Patent Text Reader

Abstract

The invention relates to a configuration information acquisition method and device, computer equipment, a storage medium and a computer program product. The method comprises the following steps: in response to a configuration acquisition request of a target program, identifying a configuration information identifier from a preset configuration file according to the configuration acquisition request; under the condition that the configuration information identifier is a target identifier, obtaining a code text corresponding to the target identifier, and performing syntax analysis on the code text to obtain an initial syntax tree; compiling the code text to obtain a script execution process, and embedding the script execution process into the initial syntax tree to obtain a target syntax tree; and based on the configuration acquisition request, traversing the target syntax tree to obtain target configuration information. By adopting the method, the configuration information can be dynamically generated at the configuration use end according to the running data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer science and technology, and particularly to a method, apparatus, computer device, storage medium, and computer program product for obtaining configuration information. Background Art

[0002] With the development of the field of computer science, configuration files have become increasingly important. A configuration file is a type of file used to define software parameters and behaviors. These parameters may include the software's interface theme, language settings, network configuration, and performance optimization, etc. When the software starts, the system reads these configuration files and runs the program according to the settings therein. During actual use, configuration items are usually described in the form of static key-value pairs. After the configuration file is loaded, the behaviors described by these keys and values are fixed and cannot be changed anymore. Therefore, when designing configuration items, all possible situations that may occur during runtime must be fully considered, and corresponding configuration files must be designed accordingly. However, it is often difficult to estimate all possible situations of configuration items. Therefore, generating configuration files in this way is not only difficult to achieve but also has a high complexity.

[0003] To solve this problem, various dynamic configuration languages (DSLs) are usually used in the prior art. Through DSL, configuration items can be extended into an intermediate language, and syntax that can be dynamically calculated is introduced therein. In this way, configuration items are transformed into logical statements, enabling the configuration items in the configuration file to be dynamically adjusted according to different situations, so that one configuration file can cover all possible situations. However, this method requires the publisher of the configuration file to learn and understand this DSL and design a set of business logics for generating DSL, which undoubtedly increases the complexity of configuration. Summary of the Invention

[0004] Based on this, it is necessary to provide a method, apparatus, computer device, computer-readable storage medium, and computer program product for obtaining configuration information in view of the above technical problems.

[0005] In a first aspect, this application provides a method for obtaining configuration information. The method includes:

[0006] In response to a configuration acquisition request of a target program, identify a configuration information identifier from a preset configuration file according to the configuration acquisition request;

[0007] When the configuration information identifier is a target identifier, obtain the code text corresponding to the target identifier, perform syntax analysis on the code text to obtain an initial syntax tree;

[0008] Compile the code text to obtain a script execution process, and embed the script execution process into the initial syntax tree to obtain a target syntax tree;

[0009] Based on the configuration acquisition request, traverse the target syntax tree to obtain target configuration information.

[0010] In one embodiment, obtaining the code text corresponding to the target identifier, performing syntax analysis on the code text to obtain an initial syntax tree, includes:

[0011] Obtain the code text corresponding to the target identifier;

[0012] Identify the identifiers of the code text to obtain sub-identifiers corresponding to the target identifier;

[0013] Establish an initial syntax tree according to the association relationship between the sub-identifiers.

[0014] In one embodiment, the association relationship between the sub-identifiers includes the priority of the sub-identifiers and the dependency relationship between the sub-identifiers; the establishing an initial syntax tree according to the association relationship between the sub-identifiers includes:

[0015] Respectively establish sub-syntax trees of the initial syntax tree according to the dependency relationships of the sub-identifiers;

[0016] Perform a merging operation on the sub-syntax trees according to the priorities of the sub-identifiers to obtain an initial syntax tree.

[0017] In one embodiment, the target syntax tree includes configuration nodes, and the configuration nodes are used to determine the configuration information corresponding to the configuration nodes as target configuration information when traversing the target syntax tree based on the configuration acquisition request and no target configuration information is obtained.

[0018] In one embodiment, the configuration acquisition request includes the running data of the target program; the running data is associated with the configuration information in the target syntax tree; the traversing the target syntax tree based on the configuration acquisition request to obtain target configuration information includes:

[0019] Sequentially obtain the reference data of the target syntax tree and match it with the running data of the target program;

[0020] In the case that the target program has running data that matches the reference data of the target syntax tree, determine the configuration information corresponding to the matching reference data as the target configuration information.

[0021] In one embodiment, the method further includes:

[0022] Run the target program according to the obtained configuration information;

[0023] In the case where an error occurs in the target program configuration, obtain the historical configuration information of the target program, and based on the historical configuration information, run the target program.

[0024] In a second aspect, the present application also provides a device for obtaining configuration information. The device includes:

[0025] An identification recognition module, configured to, in response to a configuration acquisition request of a target program, recognize a configuration information identifier from a preset configuration file according to the configuration acquisition request;

[0026] A syntax tree building module, configured to, when the configuration information identifier is a target identifier, obtain the code text corresponding to the target identifier, perform syntax analysis on the code text to obtain an initial syntax tree;

[0027] The syntax tree building module is configured to compile the code text to obtain a script execution process, and embed the script execution process into the initial syntax tree to obtain a target syntax tree;

[0028] A syntax tree traversing module, configured to traverse the target syntax tree based on the configuration acquisition request to obtain target configuration information.

[0029] In one embodiment, the syntax tree building module includes:

[0030] A code text acquisition module, configured to obtain the code text corresponding to the target identifier;

[0031] A sub-identifier recognition sub-module, configured to recognize the identifier of the code text to obtain a sub-identifier corresponding to the target identifier;

[0032] A syntax tree building sub-module, configured to establish an initial syntax tree according to the association relationship between the sub-identifiers.

[0033] In one embodiment, the syntax tree building sub-module is further configured to:

[0034] Respectively establish sub-syntax trees of the initial syntax tree according to the dependency relationships of the sub-identifiers;

[0035] Perform a merging operation on the sub-syntax trees according to the priorities of the sub-identifiers to obtain an initial syntax tree.

[0036] In one embodiment, the target syntax tree includes a configuration node, and the configuration node is configured to, in the case where the target syntax tree is traversed based on the configuration acquisition request and the target configuration information is not obtained, determine the configuration information corresponding to the configuration node as the target configuration information.

[0037] In one embodiment, the configuration acquisition request includes the running data of the target program; the running data is associated with the configuration information in the target syntax tree; the syntax tree traversal module includes:

[0038] A data matching sub-module, configured to sequentially obtain the reference data of the target syntax tree and match it with the running data of the target program;

[0039] A configuration information determination sub-module, configured to, when there is running data in the target program that matches the reference data of the target syntax tree, determine the configuration information corresponding to the matching reference data as the target configuration information.

[0040] In one embodiment, the apparatus further includes a target program running module, configured to:

[0041] Run the target program according to the obtained configuration information;

[0042] When an error occurs in the target program configuration, obtain the historical configuration information of the target program and run the target program based on the historical configuration information.

[0043] In a third aspect, the present application further provides a computer device. The computer device includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, it implements the method for acquiring configuration information according to any one of the embodiments of the present disclosure.

[0044] In a fourth aspect, the present application further provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements the method for acquiring configuration information according to any one of the embodiments of the present disclosure.

[0045] In a fifth aspect, the present application further provides a computer program product. The computer program product includes a computer program, and when the computer program is executed by a processor, it implements the method for acquiring configuration information according to any one of the embodiments of the present disclosure.

[0046] The method, apparatus, computer device, storage medium, and computer program product for obtaining the above configuration information identify the configuration information identifier from the configuration file according to the configuration acquisition request, and determine the configuration information identifier required by the target program. When the identified configuration information identifier is the target identifier, the corresponding code text is further obtained and syntax analysis is performed to construct an initial syntax tree including judgment logic and conditions, and the code text is compiled to obtain a script execution process, and the script execution process is embedded into the initial syntax tree to form a target syntax tree, and the target syntax tree is traversed based on the configuration acquisition request to obtain the target configuration information. It realizes dynamic configuration management. By responding to the configuration acquisition request of the target program, the configuration information can be flexibly and dynamically selected, which is convenient for quick adjustment according to different requirements or environments. Automatically identify the configuration information in the configuration file, reduce manual intervention, and improve the processing efficiency and accuracy. The compilation and execution process of the code text can also be extended according to requirements, so as to support complex scripts and adapt to different configuration environments. At the same time, on the basis of not changing the configuration syntax, a set of syntax of logical control flow is introduced through the reserved target identifier. By simply combining with the script language, it is possible to dynamically generate configuration information according to the runtime data at the configuration usage end, further improving the flexibility and dynamics of the configuration. In addition, this method ensures the accuracy and validity of the configuration information by constructing a syntax tree and executing a script, and avoids problems caused by configuration errors. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] Figure 1 It is a schematic flowchart of the method for obtaining configuration information in an embodiment;

[0048] Figure 2 It is a first schematic flowchart of establishing an initial syntax tree in an embodiment;

[0049] Figure 3 It is a second schematic flowchart of establishing an initial syntax tree in an embodiment;

[0050] Figure 4 It is a schematic flowchart of traversing the target syntax tree in an embodiment;

[0051] Figure 5 It is a schematic flowchart of the target program running in an embodiment;

[0052] Figure 6 It is a first schematic flowchart of the implementation of the method for obtaining configuration information in an embodiment;

[0053] Figure 7 It is a second schematic flowchart of the implementation of the method for obtaining configuration information in an embodiment;

[0054] Figure 8The structural block diagram of the configuration information acquisition device in an embodiment;

[0055] Figure 9 The internal structure diagram of a computer device in an embodiment. Detailed implementation manners

[0056] In order to make the objectives, technical solutions, and advantages of the present application clearer, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0057] In one embodiment, as Figure 1 shown, a method for acquiring configuration information is provided. In this embodiment, it is exemplified that the method is applied to a terminal. It can be understood that the method can also be applied to a server and can also be applied to a system including a terminal and a server and implemented through the interaction between the terminal and the server. In this embodiment, the method includes the following steps:

[0058] Step S100, in response to a configuration acquisition request of a target program, identify a configuration information identifier from a preset configuration file according to the configuration acquisition request.

[0059] In an exemplary embodiment, the configuration acquisition request can be used to acquire configuration information, etc.; the configuration information can be stored in a configuration file, and the parameters of the configuration file can include the interface theme, language setting, network setting, performance optimization, etc. of the software. When the target program is started, the target program needs to read the configuration information in the configuration file, that is, a configuration acquisition request, etc., needs to be generated.

[0060] In an exemplary embodiment, the configuration file may include multiple configuration information identifiers, and these configuration information identifiers respectively correspond to different configuration information. By accurately identifying the configuration information identifier specified in the configuration acquisition request, the target configuration information can be quickly located from the configuration file, thereby improving the acquisition efficiency of the configuration information. In addition, the configuration file may also include some preset rules or logics for further processing and parsing the configuration information identifier to ensure that the finally acquired configuration information meets the requirements of the target program.

[0061] In an exemplary embodiment, the configuration information identifier in the configuration file may include a unique identifier of the configuration information, and may also include an identifier of a preset rule or logic, etc.; the preset rule or logic may include that a unique identifier of the configuration information corresponds to multiple configuration information, and it is necessary to select one configuration information correspondingly based on the data or request of the target program, etc.; the identifier of the preset rule or logic may include preset characters for characterizing the multiple configuration information corresponding to the unique identifier of the configuration information; it is necessary to select one of the configuration information based on a configuration acquisition request, etc.

[0062] In an exemplary embodiment, the preset configuration file may include a file preset with configuration information, where the configuration file may be classified according to different configuration information included in the file, etc.; in another exemplary embodiment, the configuration file may be classified according to the target program applicable to the configuration file, and an association relationship between the target program and the configuration file may be established, etc.

[0063] In an exemplary embodiment, the recognition of the configuration information identifier from the configuration file may include recognizing an identifier corresponding to a configuration acquisition request and a target identifier, etc.; among them, when the identifier corresponding to the configuration acquisition request is recognized, the configuration information corresponding to the identifier may be obtained, etc.; when the target identifier is recognized, it may be considered that there are multiple configuration information corresponding to the configuration information identifier of the target identifier, and the target configuration information needs to be selected according to the data of the target program; for example, when the data of the target program is the first data, the target configuration information is determined as the first configuration information, and when the data of the target program is the second data, the target configuration information is determined as the second configuration information, etc. Specifically, the data of the target program may be included in the configuration acquisition request; the data of the target program may also be obtained from the target program when the target identifier is detected, etc.

[0064] Step S200, when the configuration information identifier is the target identifier, obtain the code text corresponding to the target identifier, and perform syntax analysis on the code text to obtain an initial syntax tree.

[0065] In an exemplary embodiment, the target identifier may include a selection identifier recognizable by the configuration file rule language, such as <control_flow> in the YAML language, etc.; when the target identifier is detected, it is considered that the configuration information identifier corresponds to multiple configuration information, and the target configuration information needs to be selected according to the data of the target program, etc.

[0066] In an exemplary embodiment, the code text of the target identifier may include determining the code text based on the position of the target identifier when the target identifier is detected; for example, in some language rules, it may include indenting the target identifier by X characters, and then all the code text corresponding to the target identifier is indented by greater than or equal to X characters, so as to determine the code text corresponding to the target identifier. Specifically, it can start searching downward from the position where the target identifier is located until the indentation of the code text is less than X characters, etc.; in another exemplary embodiment, the code text of the target identifier can be determined according to the range symbols of the target identifier. For example, some inclusion symbols may appear after the target identifier, such as "{" and "}" etc.; then all the characters between the two symbols are the code text, etc.

[0067] In an exemplary embodiment, the syntax analysis of the code text may include obtaining sub-identifiers in the code text and determining the syntax analysis based on these sub-identifiers; specifically, the sub-identifiers may include if, else, elseif, for, etc.; for example, when the detected sub-identifiers are respectively if, then, elseif, then, else, then; it indicates that the target identifier includes three cases, namely if, elseif, and else, etc.; based on the judgment of the three conditions, an initial syntax tree can be established. It can be understood that the initial syntax tree may include multiple nodes, and each node corresponds to a configuration information or condition judgment in the code text. The nodes are interconnected through logical relationships to form a complete syntax structure. In the initial syntax tree, each node contains its corresponding code text segment and the position information of the segment in the code text, so as to facilitate subsequent traversal and modification operations of the syntax tree. In addition, the initial syntax tree can also be extended according to requirements to support more complex logical judgments and conditional branches, etc.

[0068] Step S300, compile the code text to obtain a script execution process, and embed the script execution process into the initial syntax tree to obtain a target syntax tree.

[0069] In an exemplary embodiment, the code text can be compiled to obtain a script execution process, which may include compiling the logical judgments and conditional branches in the code text into executable script code, and generating a corresponding script execution process according to the execution flow of the script code. The script execution process may include the execution order, execution conditions, and execution results of the script code, etc. Subsequently, the generated script execution process is embedded into the initial syntax tree to form a target syntax tree. The target syntax tree not only contains the configuration information and condition judgments in the initial syntax tree, but also contains the script execution process, enabling the target syntax tree to dynamically select and generate configuration information, etc. according to the data or requests of the target program.

[0070] In an exemplary embodiment, the script execution process can be embedded into the initial syntax tree, that is, the judgment process and the process of selecting configuration information are embedded into the initial syntax tree that only contains a tree structure, so that the target syntax tree contains the structure of the initial syntax tree and conditional judgments of code texts, etc.

[0071] In an exemplary embodiment, the code text in the compilation of the code text can include code texts that conform to the syntax rules of the configuration file, that is, it can be directly compiled without the need to be mapped and then compiled and run like an intermediate language, and then mapped to the configuration file again, etc.

[0072] Step S400: Based on the configuration acquisition request, traverse the target syntax tree to obtain target configuration information.

[0073] In an exemplary embodiment, the configuration acquisition request may include data or requests of the target program, etc.; the target syntax tree may include conditional judgments and corresponding target configuration information, etc., and there may be priorities among the conditional judgments; the priority can be used to obtain the judgment condition with the highest priority according to the priority, and determine whether the data or request of the target program in the configuration acquisition request satisfies the judgment condition. If it is satisfied, the configuration information corresponding to the judgment condition is determined as the target configuration information, and the traversal of the target syntax tree is stopped; if it is not satisfied, the judgment condition of the next priority is traversed, and it is determined whether the data or request of the target program in the configuration acquisition request satisfies the judgment condition of the next priority, and so on, until the data or request of the target program in the configuration acquisition request satisfies one of the judgment conditions, and the configuration information corresponding to the judgment condition satisfied by the data or request of the target program in the configuration acquisition request is determined as the target configuration information, etc.

[0074] In the method for obtaining the above configuration information, the configuration information identifier is identified from the configuration file according to the configuration acquisition request, and the configuration information identifier required by the target program is determined. When the identified configuration information identifier is the target identifier, the corresponding code text is further obtained and syntax analysis is performed to construct an initial syntax tree including judgment logic and conditions, and the code text is compiled to obtain a script execution process, and the script execution process is embedded into the initial syntax tree to form a target syntax tree, and the target syntax tree is traversed based on the configuration acquisition request to obtain the target configuration information. Dynamic configuration management is realized. By responding to the configuration acquisition request of the target program, configuration information can be flexibly and dynamically selected, which is convenient for quick adjustment according to different requirements or environments. Automatically identifying the configuration information in the configuration file reduces manual intervention and improves processing efficiency and accuracy. The compilation and execution process of the code text can also be extended according to requirements, so as to support complex scripts and adapt to different configuration environments. At the same time, on the basis of not changing the configuration syntax, a set of syntax of logical control flow is introduced through the reserved target identifier. By simply combining with the script language, configuration items can be dynamically generated according to the runtime data at the configuration usage end, further improving the flexibility and dynamics of the configuration. In addition, this method ensures the accuracy and effectiveness of the configuration information by constructing a syntax tree and executing a script, and avoids problems caused by configuration errors.

[0075] In one embodiment, as Figure 2 shown, obtaining the code text corresponding to the target identifier and performing syntax analysis on the code text to obtain an initial syntax tree includes:

[0076] Step S201, obtaining the code text corresponding to the target identifier.

[0077] Step S202, identifying the identifier of the code text to obtain the sub-identifier corresponding to the target identifier.

[0078] Step S203, establishing an initial syntax tree according to the association relationship between the sub-identifiers.

[0079] In an exemplary embodiment, the identifier of the code text can be identified to obtain the sub-identifier of the target identifier, and the sub-identifier can include if, else, elseif, for, etc.; through these sub-identifiers, conditional judgment and loop use of configuration information can be realized.

[0080] In an exemplary embodiment, the association relationships between the sub-identifiers may include causal relationships and priority relationships between the sub-identifiers; for example, there is a causal relationship between if and then, where if is the judgment condition and then is the configuration information that matches the judgment condition; the priority relationship may include judging the first judgment condition first, then the second judgment condition, and finally the third judgment condition, etc. In another exemplary embodiment, an initial syntax tree can be established based on the process of condition judgment, that is, a syntax tree containing a condition judgment structure, and the initial syntax tree may not have judgment conditions and corresponding configuration information, etc.

[0081] In one embodiment, as Figure 3 shown, the association relationships between the sub-identifiers include the priorities of the sub-identifiers and the dependency relationships between the sub-identifiers; establishing an initial syntax tree according to the association relationships between the sub-identifiers includes:

[0082] Step S211, respectively establish sub-syntax trees of the initial syntax tree according to the dependency relationships of the sub-identifiers.

[0083] Step S212, perform a merging operation on the sub-syntax trees according to the priorities of the sub-identifiers to obtain an initial syntax tree.

[0084] In an exemplary embodiment, the dependency relationship may include that two sub-identifiers need to be used simultaneously; for example, the sub-identifiers are "if" and "then" respectively; then the relationship between them is a dependency relationship, that is, if XX, then XX; behind if is the judgment condition, and behind then is the corresponding configuration information; a sub-syntax tree can be established based on the judgment condition and the configuration information, that is, a syntax tree containing only one case, and then the sub-syntax trees are merged based on the priorities of the sub-identifiers; for example, the priorities may include if in the first case, then XX; if the first case is not satisfied but the second case is satisfied, then XX; if the first and second cases are not satisfied but the third case is satisfied, then XX; this indicates that the priority of the first case is greater than the priority of the second case is greater than the priority of the third case, etc.

[0085] In this embodiment, by identifying the identifiers of the code text one by one and based on the semantics and logical relationships of these identifiers, an initial syntax tree containing all condition judgments and loop structures is constructed. This initial syntax tree clearly shows the associations and hierarchies of various parts in the code text, providing a basis for subsequent processing. During the process of constructing the initial syntax tree, the priorities and causal relationships between the sub-identifiers are also considered to ensure the accuracy and effectiveness of the syntax tree. In this way, the logical control flow in the configuration file can be understood and processed more precisely, providing strong support for subsequent configuration information selection and dynamic generation.

[0086] In one embodiment, the target syntax tree includes a configuration node, which is used to determine the configuration information corresponding to the configuration node as the target configuration information when traversing the target syntax tree based on the configuration acquisition request and no target configuration information is obtained.

[0087] In an exemplary embodiment, the target syntax tree may include a configuration node, etc., and the configuration node may include a default node, etc., that is, the default configuration information is A. If other judgment conditions are met, it is updated to the corresponding configuration information. If all other judgment conditions are not met, the configuration information is determined as A; in another exemplary embodiment, the configuration node may be set at the end, that is, when the above all conditions are not met, the target configuration information is determined as the configuration information corresponding to the configuration node, etc.

[0088] In this embodiment, by setting a configuration node in the target syntax tree, when traversing the target syntax tree, if the target configuration information that meets the condition judgment cannot be found, the configuration information corresponding to the configuration node can be automatically determined as the target configuration information. This method provides a default selection of configuration information, ensuring that even under complex or special configuration requirements, there is a reasonable configuration information as an alternative. The setting of the configuration node increases the flexibility and fault tolerance of the configuration information, making the acquisition process of the configuration information more robust and reliable. At the same time, the introduction of the configuration node also simplifies the complexity of configuration management. Instead of setting clear condition judgments for each possible configuration situation, a general solution is provided through the configuration node. Such a design not only ensures the dynamics and flexibility of the configuration, but also improves the efficiency and usability of the configuration.

[0089] In one embodiment, as Figure 4 shown, the configuration acquisition request includes the running data of the target program; the running data is associated with the configuration information in the target syntax tree; traversing the target syntax tree based on the configuration acquisition request to obtain the target configuration information includes:

[0090] Step S401: Sequentially obtain the reference data of the target syntax tree and match it with the running data of the target program.

[0091] Step S402: When there is running data in the target program that matches the reference data of the target syntax tree, determine the configuration information corresponding to the matching reference data as the target configuration information.

[0092] In an exemplary embodiment, the reference data may include judgment conditions, that is, when the running data of the target program matches the reference data, the configuration information corresponding to the reference data is determined as the target configuration information, etc.

[0093] In an exemplary embodiment, the operation data may include the identification of a request, etc. For example, the operation data of a page may include the request method ("get", "post", etc.); the operation data may also include different reference data. For example, the first reference data is whether the request method is "get"; the second reference data may be whether there is XX data, etc.; that is, the identifications of the first reference data and the second reference data are different, etc.

[0094] In this embodiment, by matching the operation data of the target program with the reference data in the target syntax tree, the configuration information that matches the current running state can be accurately found. This method not only improves the flexibility of the configuration, but also ensures that the configuration information is consistent with the running state of the program, thereby avoiding errors caused by improper configuration. During the matching process, each node in the target syntax tree can be checked in sequence, and the judgment conditions therein are compared with the operation data. Once a matching item is found, the corresponding configuration information is immediately determined as the target configuration information. This improves the efficiency and accuracy of obtaining the configuration information. In addition, by dynamically matching the operation data and the configuration information, the configuration of the program can be adjusted in real time to adapt to different running environments and requirements. Such a design makes the configuration management more flexible and intelligent, and improves the scalability and maintainability of the entire system.

[0095] In one embodiment, as Figure 5 shown, the method further includes:

[0096] Step S501, run the target program according to the obtained configuration information.

[0097] Step S502, in the case where an error occurs in the configuration of the target program, obtain the historical configuration information of the target program, and run the target program based on the historical configuration information.

[0098] In an exemplary embodiment, the occurrence of an error in the target program configuration may include an exception occurring during the running of the target program, or the result output by the target program not matching the expectation, etc. When it is detected that an error occurs in the target program configuration, the operation of obtaining the historical configuration information can be triggered automatically or manually. The historical configuration information may be the configuration information used when the target program was successfully run before, or the verified and stable configuration information. After obtaining the historical configuration information, the target program can be re-run based on this historical configuration information to restore the normal running of the program or for further debugging and analysis. In this way, an effective recovery means can be provided when an error occurs in the target program configuration, reducing the risks and losses caused by configuration errors. At the same time, it also facilitates developers or operators to quickly locate and solve configuration problems, improving the stability and reliability of the system.

[0099] In this embodiment, when running the target program, it not only depends on the currently obtained configuration information, but also considers the backup and recovery mechanism of historical configuration information. In the case of errors in the target program configuration, it can be timely rolled back to the historical configuration information to ensure the continuity and stability of the program. This design not only enhances the robustness of the configuration, but also improves the fault tolerance of the system. In addition, by recording and comparing historical configuration information, the trends and laws of configuration changes can also be analyzed, providing data support for optimizing configuration management. Such a method takes into account the reliability and stability of the configuration while implementing dynamic configuration management, providing strong guarantee for complex and changeable operating environments.

[0100] In one exemplary embodiment, the obtaining of the configuration information can be applied to, for example Figure 6 in the embodiment described above, specifically including:

[0101] Step S601, determining whether the value of the key-value pair contains the target identifier; if so, proceeding to step S602, if not, ending;

[0102] Step S602, performing lexical analysis on the conditional statements in the target identifier code text;

[0103] Step S603, compiling the analysis and the scripting language into an abstract syntax tree;

[0104] Step S604, traversing the abstract syntax tree to generate a rendering result.

[0105] In one exemplary embodiment, the obtaining of the configuration information can be applied to page rendering, specifically can be applied to, for example Figure 7 in the embodiment described above, specifically including:

[0106] Step S701, determining whether method is GET; if so, proceeding to step S702, if not, proceeding to step S703;

[0107] Step S702, setting option to get;

[0108] Step S703, determining whether query contains "option="; if so, proceeding to step S704, if not, proceeding to step S705;

[0109] Step S704, setting option to the value corresponding to option in query;

[0110] Step S705, determining whether the request header contains "Custom-Option"; if so, proceeding to step S706, if not, proceeding to step S707;

[0111] Step S706: Set option to the value corresponding to the request header "Custom-Option".

[0112] Step S707: Set option to nothing.

[0113] It should be understood that although the steps in the flowcharts involved in the above-described embodiments are shown in sequence according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise clearly stated in this article, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-described embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be executed alternately or in turn with at least a part of other steps or steps or stages in other steps.

[0114] Based on the same inventive concept, an embodiment of the present application also provides a configuration information acquisition device for implementing the above-mentioned configuration information acquisition method. The implementation solutions provided by this device to solve problems are similar to the implementation solutions described in the above method. Therefore, the specific limitations in one or more embodiments of the configuration information acquisition device provided below can refer to the limitations on the configuration information acquisition method in the above text, and will not be repeated here.

[0115] In one embodiment, as Figure 8 shown, a configuration information acquisition device 100 is provided, including: an identification recognition module 101, a syntax tree building module 102, and a syntax tree traversal module 103, where:

[0116] The identification recognition module is used to, in response to a configuration acquisition request of a target program, identify a configuration information identifier from a preset configuration file according to the configuration acquisition request;

[0117] The syntax tree building module is used to, when the configuration information identifier is a target identifier, obtain the code text corresponding to the target identifier, perform syntax analysis on the code text, and obtain an initial syntax tree;

[0118] The syntax tree building module is used to compile the code text to obtain a script execution process, and embed the script execution process into the initial syntax tree to obtain a target syntax tree;

[0119] The syntax tree traversal module is used to traverse the target syntax tree based on the configuration acquisition request to obtain target configuration information.

[0120] In one embodiment, the syntax tree building module includes:

[0121] A code text acquisition module, configured to acquire the code text corresponding to the target identifier;

[0122] A sub-identifier recognition sub-module, configured to recognize the identifiers of the code text to obtain the sub-identifiers corresponding to the target identifier;

[0123] A syntax tree building sub-module, configured to build an initial syntax tree according to the association relationship between the sub-identifiers.

[0124] In one embodiment, the syntax tree building sub-module is further configured to:

[0125] Build sub-syntax trees of the initial syntax tree respectively according to the dependency relationships of the sub-identifiers;

[0126] Perform a merging operation on the sub-syntax trees according to the priorities of the sub-identifiers to obtain the initial syntax tree.

[0127] In one embodiment, the target syntax tree includes a configuration node, and the configuration node is configured to determine the configuration information corresponding to the configuration node as the target configuration information when traversing the target syntax tree based on the configuration acquisition request and the target configuration information is not obtained.

[0128] In one embodiment, the configuration acquisition request includes the running data of the target program; the running data is associated with the configuration information in the target syntax tree; the syntax tree traversing module includes:

[0129] A data matching sub-module, configured to sequentially acquire the reference data of the target syntax tree and match it with the running data of the target program;

[0130] A configuration information determination sub-module, configured to determine the configuration information corresponding to the matching reference data as the target configuration information when there is running data in the target program that matches the reference data of the target syntax tree.

[0131] In one embodiment, the apparatus further includes a target program running module, configured to:

[0132] Run the target program according to the acquired configuration information;

[0133] When an error occurs in the target program configuration, acquire the historical configuration information of the target program and run the target program based on the historical configuration information.

[0134] Each module in the above-mentioned apparatus for obtaining configuration information can be implemented in whole or in part by software, hardware, or a combination thereof. Each of the above modules can be embedded in or independent of a processor in a computer device in the form of hardware, or stored in a memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.

[0135] In one embodiment, a computer device is provided. The computer device can be a server, and its internal structure diagram can be as Figure 9 shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, abbreviated as I / O), and a communication interface. Among them, the processor, the memory, and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store reference data. The input / output interface of the computer device is used to exchange information between the processor and external devices. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, it implements a method for obtaining configuration information.

[0136] Those skilled in the art can understand that Figure 9 the structure shown in

[0137] is only a block diagram of some structures related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different component layout.

[0138] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, database, or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memories. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The databases involved in the embodiments provided in the present application can include at least one of relational databases and non-relational databases. Non-relational databases can include distributed databases based on blockchain, etc., without limitation. The processors involved in the embodiments provided in the present application can be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, data processing logics based on quantum computing, etc., without limitation.

[0139] The technical features of the above embodiments can be combined arbitrarily. For the sake of concise description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope recorded in this specification.

[0140] The above-described embodiments only represent several implementation manners of the present application. The description is relatively specific and detailed, but it should not be construed as a limitation on the patent scope of the present application. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the appended claims.

Claims

1. A method for obtaining configuration information, characterized in that The method includes: In response to a configuration acquisition request of a target program, identifying a configuration information identifier from a preset configuration file according to the configuration acquisition request; When the configuration information identifier is a target identifier, acquiring the code text corresponding to the target identifier, performing syntax analysis on the code text to obtain an initial syntax tree; Compiling the code text to obtain a script execution process, and embedding the script execution process into the initial syntax tree to obtain a target syntax tree; Based on the configuration acquisition request, traversing the target syntax tree to obtain target configuration information.

2. The method according to claim 1, wherein The acquiring the code text corresponding to the target identifier, performing syntax analysis on the code text to obtain an initial syntax tree includes: Acquiring the code text corresponding to the target identifier; Identifying the identifier of the code text to obtain a sub-identifier corresponding to the target identifier; Establishing an initial syntax tree according to the association relationship between the sub-identifiers.

3. The method according to claim 2, characterized in that, The association relationship between the sub-identifiers includes the priority of the sub-identifiers and the dependency relationship between the sub-identifiers; the establishing an initial syntax tree according to the association relationship between the sub-identifiers includes: Respectively establishing sub-syntax trees of the initial syntax tree according to the dependency relationship between the sub-identifiers; Performing a merging operation on the sub-syntax trees according to the priority of the sub-identifiers to obtain an initial syntax tree.

4. The method according to claim 1, wherein The target syntax tree includes configuration nodes, and the configuration nodes are used to determine the configuration information corresponding to the configuration nodes as target configuration information when traversing the target syntax tree based on the configuration acquisition request and no target configuration information is obtained.

5. The method according to claim 1, wherein The configuration acquisition request includes the running data of the target program; the running data is associated with the configuration information in the target syntax tree; the traversing the target syntax tree based on the configuration acquisition request to obtain target configuration information includes: Sequentially acquiring the reference data of the target syntax tree and matching it with the running data of the target program; When there is running data of the target program that matches the reference data of the target syntax tree, determining the configuration information corresponding to the matching reference data as the target configuration information.

6. The method according to claim 1, characterized in that, The method further includes: Running the target program according to the acquired configuration information; When an error occurs in the target program configuration, acquiring the historical configuration information of the target program and running the target program based on the historical configuration information.

7. An apparatus for obtaining configuration information, characterized in that The device includes: An identifier recognition module, configured to identify a configuration information identifier from a preset configuration file according to a configuration acquisition request of a target program in response to the configuration acquisition request; A syntax tree establishment module, configured to acquire the code text corresponding to the target identifier, perform syntax analysis on the code text to obtain an initial syntax tree when the configuration information identifier is a target identifier; The syntax tree establishment module is configured to compile the code text to obtain a script execution process, and embed the script execution process into the initial syntax tree to obtain a target syntax tree; The syntax tree traversal module is used to obtain a request based on the configuration, traverse the target syntax tree, and obtain target configuration information.

8. A computer device, comprising a memory and a processor, the memory storing a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method described in any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the method described in any one of claims 1 to 6.

10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the method described in any one of claims 1 to 6.

Citation Information

Cited By

  • Newly-added configuration key identification method, deployment application system, electronic equipment and storage medium

    CN121614199A