Configuration item operation method and device, configuration file operation method and device
By obtaining and processing the paths and requests of configuration files, determining configuration items and operating according to orchestration rules, using the general operation interface to match the sub-operation interface, the development complexity problems caused by different configuration file formats are solved, and development efficiency and operation accuracy are improved. .
Patent Information
- Application Number
- CN202410384635.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-01
- Publication Date
- 2024-12-27
- Estimated Expiration
- 2044-04-01
AI Technical Summary
In large-scale software development projects, due to the different API interface parameters of different configuration file formats, the development complexity and low development efficiency are difficult to achieve unified code maintenance.
By obtaining the path and operation request of the configuration file, determining the configuration items and configuration information, processing and storing according to specific orchestration rules, achieving unified operation of different configuration files, and using the sub-operation interface in the general operation interface to operate according to the configuration type matching .
It realizes compatibility and accuracy of configuration item operations for multiple configuration files, improves development efficiency, and reduces the burden on developers to find different API interfaces.
Smart Images

Figure CN118363651B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and to a method and device for operating a configuration item, a method and device for operating a configuration file, an electronic device, and a computer-readable storage medium. Background Art
[0002] For large-scale software development projects, there are usually different configuration file formats. Commonly used configuration operations require the use of different configuration file development interface APIs (Application Programming Interfaces). Due to the lack of a unified configuration file API interface system, the parameters of different development interface APIs are different. When writing code to perform configuration item operations, it is necessary to write calls corresponding to the read and write API names and set different parameters according to the API requirements.
[0003] When configuration files of various formats need to be used in a software development project, different APIs need to be used, which leads to development complexity, low development efficiency, and inconvenience in code update and maintenance. Summary of the invention
[0004] The present disclosure provides a configuration item operation method and device, a configuration file operation method and device, an electronic device, and a computer-readable storage medium.
[0005] According to a first aspect, a method for operating configuration items is provided, the method comprising: obtaining a configuration path of a configuration file to be processed and an operation request for the configuration file to be processed; determining, based on the configuration path, configuration items of the configuration file to be processed and configuration information of the configuration items; processing the configuration items according to specific arrangement rules to obtain sorting items, and storing the configuration information accordingly; and operating the configuration items and the configuration information based on the operation request and the sorting items.
[0006] According to a second aspect, a configuration file operation method is provided, the operation method comprising: obtaining a configuration type and a configuration path of a loaded configuration file to be processed; detecting whether the type of a sub-operation interface in a general operation interface matches the configuration type, the sub-operation interface in the general operation interface being obtained based on a method as described in any implementation of the first aspect; in response to detecting that the type of the sub-operation interface in the general operation interface matches the configuration type, determining in real time whether there is an operation request to operate the configuration file to be processed; in response to an operation request to operate the configuration file to be processed, sending the configuration path and the operation request to the sub-operation interface, and calling the sub-operation interface to operate the configuration file to be processed.
[0007] According to a third aspect, a configuration item operation device is provided, which includes: an item acquisition unit, configured to acquire a configuration path of a configuration file to be processed and an operation request for the configuration file to be processed; an item determination unit, configured to determine the configuration items and configuration information of the configuration items of the configuration file to be processed based on the configuration path; an operation unit, configured to process the configuration items according to specific arrangement rules to obtain sorting items, and store the configuration information accordingly; and a configuration unit, configured to operate the configuration items and the configuration information based on the operation request and the sorting items.
[0008] According to a fourth aspect, a configuration file operation device is provided, the operation device comprising: a file acquisition unit, configured to acquire a configuration type and a configuration path of a loaded configuration file to be processed; a detection unit, configured to detect whether the type of a sub-operation interface in a universal operation interface matches the configuration type, the sub-operation interface in the universal operation interface being obtained based on a device as described in any implementation method of the third aspect; a judgment unit, configured to, in response to detecting that the type of the sub-operation interface in the universal operation interface matches the configuration type, determine in real time whether there is an operation request to operate the configuration file to be processed; and a calling unit, configured to, in response to an operation request to operate the configuration file to be processed, send the configuration path and the operation request to the sub-operation interface, and call the sub-operation interface to operate the configuration file to be processed.
[0009] According to the fifth aspect, an electronic device is provided, which includes: at least one processor; and a memory communicatively connected to the at least one processor, wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method described in any implementation of the first aspect or the second aspect.
[0010] According to a sixth aspect, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause a computer to execute the method described in any implementation of the first aspect or the second aspect.
[0011] The configuration item operation method and device provided by the embodiment of the present disclosure first obtain the configuration path of the configuration file to be processed and the operation request for the configuration file to be processed; secondly, based on the configuration path, determine the configuration items of the configuration file to be processed and the configuration information of the configuration items; thirdly, process the configuration items according to specific arrangement rules to obtain sorting items, and store the configuration information accordingly; finally, based on the operation request and the sorting items, operate the configuration items and the configuration information. Therefore, by processing the configuration items according to specific arrangement rules, the operations on the configuration items in the same type of configuration files can be compatible, the operations on the configuration items are unified, and the accuracy and reliability of locating the configuration items of multiple different configuration files are improved.
[0012] The configuration file operation method and device provided by the embodiment of the present disclosure first obtain the configuration type and configuration path of the loaded configuration file to be processed; secondly, detect whether the type of the sub-operation interface in the general operation interface matches the configuration type, and the sub-operation interface in the general operation interface is obtained based on the operation method or device of the above configuration item; thirdly, in response to detecting that the type of the sub-operation interface in the general operation interface matches the configuration type, it is judged in real time whether there is an operation request to operate the configuration file to be processed; finally, in response to the operation request to operate the configuration file to be processed, the configuration path and the operation request are sent to the sub-operation interface, and the sub-operation interface is called to operate the configuration file to be processed. Thus, through the pre-configured sub-operation interface corresponding to different configuration types, the configuration items of the configuration files of different configuration types are uniformly operated; after the configuration file to be processed is loaded into the current system, the corresponding sub-operation interface is determined based on the configuration type of the configuration file to be processed, and the operation request and configuration path of the file to be processed are sent to the sub-operation interface, without the need for developers to find the application interface of the configuration type, thereby improving the development efficiency of using different types of configuration files.
[0013] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.
[0015] Figure 1 is a flowchart of an embodiment of an operation method of a configuration item according to the present disclosure;
[0016] Figure 2 is a flow chart of an embodiment of a method for operating a configuration file according to the present disclosure;
[0017] Figure 3 is a flow chart of another embodiment of a method for operating a configuration file according to the present disclosure;
[0018] Figure 4 is a structural schematic diagram of an embodiment of an operating device according to a configuration item of the present disclosure;
[0019] Figure 5 is a schematic structural diagram of an embodiment of an operating device for a configuration file according to the present disclosure;
[0020] Figure 6 The present invention is a block diagram of an electronic device for implementing the configuration file operation method or the configuration item operation method of the embodiment of the present disclosure. DETAILED DESCRIPTION
[0021] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0022] For large software development projects, different types of configuration files usually have different formats. Common configuration operations require the use of different configuration file development interface APIs. Due to the lack of a unified configuration file API interface system, the parameters of different development interface APIs are different. When writing code to operate configuration items, it is necessary to write calls corresponding to the read and write API names and set different parameters according to API requirements. For example, for the operation of INI (Initial) format configuration files, the read operation API is GetPrivateProfileX, where X has two types, Int and String, depending on the type. The parameters include at least: a (configuration section), b (configuration item), and file path. For JSON operations, the write operation API is WritePrivateProfileX, where X and parameters are similar to get operations. For JSON (JavaScript Object Notation), the operation is usually parsed using the API and then the map interface is used. Assuming that the result of parsing the JSON file format is X, the configuration read uses X[a][b].asY to perform recursive read operations on JSON configuration items. Y can be Int, String, etc., and write operations are performed through X[a][b]=Y. For XML (Extensible Markup Language) operations, usually after API parsing, the xpath API is used, usually the API is select(xpath), to obtain node X, and then read through X.getValue() and write through X.SetValue(Y). For YAML (Ain't a Markup Language), usually after API parsing, the operation method is similar to JSON. When the project needs to use configuration files of these formats at the same time, different APIs need to be used, which brings the problem of development complexity. At the same time, when the configuration file is updated by an external program or manually, the program also needs to use different APIs to read and notify after monitoring the changes. The problem caused by inconsistent interfaces is low development efficiency and inconvenience for code update and maintenance.
[0023] For the above-mentioned commonly used configuration file formats such as JSON, INI, XML, and YAML, in order to provide convenient and efficient configuration item operations (configuration items include: reading and writing, hereinafter collectively referred to as configuration item operations), it is necessary to provide unified configuration item operation methods and configuration file operation methods, thereby improving the development efficiency of using different configuration file formats.
[0024] To this end, the present disclosure proposes a configuration item operation method. Figure 1 A process 100 of an embodiment of a method for operating a configuration item according to the present disclosure is shown. The method for operating a configuration item includes the following steps:
[0025] Step 101: Obtain a configuration path of a configuration file to be processed and an operation request for the configuration file to be processed.
[0026] In this embodiment, the configuration path of the configuration file to be processed is the storage location of the file. The configuration path may include a specific disk symbol, and the disk symbol may be used to determine in which partition of the system the file to be processed is located.
[0027] In this embodiment, the operation request for the configuration file to be processed is a request to process the configuration information of the configuration item in the configuration file to be processed, for example, a read request for the configuration information of the configuration item in the configuration file to be processed, or a write request for the configuration information of the configuration item in the configuration file to be processed.
[0028] Step 102: Determine the configuration items and configuration information of the configuration items of the configuration file to be processed based on the configuration path.
[0029] In this embodiment, based on the configuration path, all configuration items and configuration information of the configuration items in the configuration file to be processed can be determined, wherein the configuration item is the key of the configuration file to be processed, and the configuration information of the configuration item belongs to the key value of the configuration item.
[0030] Step 103: Process the configuration items according to specific arrangement rules to obtain sorted items, and store the configuration information accordingly.
[0031] In this embodiment, the arrangement rule is a rule for multi-layer arrangement of configuration items in the configuration file of the current type. The arrangement rule can be a predefined arrangement format of multiple identifiers of the corresponding configuration items. Optionally, the configuration items of different types of configuration files can also use the same arrangement rule. For example, the arrangement rule refers to the control of the configuration items of all types of configuration files to use the sorting positions of different types of nodes indicated by Xpath, where Xpath is XML path language, which is a language used to determine the position of a part in an XML (a subset of the standard generalized markup language) document. Xpath is based on the tree structure of XML, has different types of nodes, including element nodes, attribute nodes and text nodes, and provides the ability to find nodes in the data structure tree.
[0032] In this embodiment, the arrangement rules include: determining the item identifier corresponding to each configuration item in the current type of configuration file, and storing the item identifier and the configuration item correspondence in an identifier configuration table; controlling the item identifiers of all configuration items in the configuration file to be sorted according to a predefined sorting to obtain sorting items, wherein the sorting items are used to represent the sorting relationship of a specific sorting order for the configuration items or the item identifiers corresponding to the configuration items.
[0033] Step 104: Based on the operation request and the sorting item, operate the configuration item and the configuration information.
[0034] In this embodiment, the above step 104 includes: determining the configuration item to be operated based on the operation request; determining the item identifier corresponding to the configuration item to be operated based on the sorting item; querying the configuration item corresponding to the item identifier in the identifier configuration table, and operating the configuration item corresponding to the item identifier and the configuration information of the configuration item.
[0035] The method for operating configuration items provided by the embodiment of the present disclosure first obtains the configuration path of the configuration file to be processed and the operation request for the configuration file to be processed; secondly, based on the configuration path, determines the configuration items of the configuration file to be processed and the configuration information of the configuration items; thirdly, processes the configuration items according to specific arrangement rules to obtain sorting items, and stores the configuration information accordingly; finally, based on the operation request and the sorting items, operates the configuration items and the configuration information. Thus, by processing the configuration items according to specific arrangement rules, the operations on the configuration items in the same type of configuration files can be compatible, the operations on the configuration items are unified, and the accuracy and reliability of locating the configuration items of multiple different configuration files are improved.
[0036] In some optional implementations of the present disclosure, the above-mentioned operation request includes: a request to read configuration items. Based on the operation request and the sorting item, the operation configuration items and configuration information include: based on the read configuration item request, determining the configuration item to be read; based on the sorting item, querying the configuration information corresponding to the configuration item to be read; in response to querying the configuration information corresponding to the configuration item to be read, sending the configuration information.
[0037] In this optional implementation, the above-mentioned read configuration item request is a request sent by an external controller to read the configuration information of the configuration item in the configuration file to be processed, and the read configuration item request at least includes: an identifier of the configuration file to be processed, and an identifier of the configuration item to be read, wherein the identifier of the configuration file to be processed is used to uniquely identify the configuration file to be processed, and the identifier of the configuration item to be read is used to uniquely identify the configuration item in the configuration file to be processed.
[0038] The method for operating configuration items and configuration information provided by this optional implementation method determines the configuration item to be read when the operation request is a request to read the configuration item; based on the sorting item, queries the configuration information corresponding to the configuration item to be read; after the configuration information corresponding to the configuration item to be read is queried, the configuration information is sent, which provides a reliable implementation method for reading the configuration information of the configuration item.
[0039] In some optional implementations of the present disclosure, the operation request includes: a write configuration item request, based on the operation request and the sorting item, the operation configuration item and configuration information include: based on the write configuration item request, obtaining the configuration item to be written and the configuration information to be written; based on the sorting item, querying the configuration item to be written; in response to querying the configuration item to be written, replacing the configuration information of the configuration item to be written with the configuration information to be written.
[0040] In this optional implementation, the above-mentioned write configuration item request is a request sent by an external controller to write configuration information in the configuration file to be processed, and the write configuration item request at least includes: an identifier of the configuration file to be processed, and an identifier of the configuration item of the configuration information to be written, wherein the identifier of the configuration file to be processed is used to uniquely identify the configuration file to be processed, and the identifier of the configuration item of the configuration information to be written is used to uniquely identify the configuration item in the configuration file to be processed.
[0041] The method for operating configuration items and configuration information provided by this optional implementation method determines the configuration items to be written and the configuration information to be written when the operation request is a request to write configuration items; queries the configuration items to be written based on the sorting items; after the configuration items to be written are queried, the configuration information of the configuration items to be written is replaced with the configuration information in the request to write configuration items, thereby providing a reliable implementation method for writing the configuration information of the configuration items.
[0042] Optionally, in some embodiments of the present disclosure, the above configuration item operation method further includes: receiving a query request for the configuration item to be updated; determining the configuration item to be updated based on the query request; and obtaining configuration information of the configuration item to be updated based on the sorting item.
[0043] To this end, the present disclosure proposes a configuration file operation method. Figure 2 A process 200 of an embodiment of a method for operating a configuration file according to the present disclosure is shown. The method for operating a configuration file includes the following steps:
[0044] Step 201, obtaining the configuration type and configuration path of the loaded configuration file to be processed.
[0045] In this embodiment, the execution subject on which the configuration file operation method is running can obtain the configuration type and configuration path of the loaded configuration file to be processed in a variety of ways. For example, the execution subject can obtain the configuration type and configuration path of the configuration file to be processed from the system where the configuration file to be processed is loaded through a wired connection. For another example, the user can communicate with the execution subject on which the configuration file operation method is running through the operation interface on the terminal, so that the execution subject obtains the configuration type and configuration path sent by the terminal.
[0046] In this embodiment, the configuration type is a format type of the configuration file to be processed. For example, the configuration type of the configuration file to be processed is any one of JSON, INI, XML, and YAML.
[0047] In this embodiment, the configuration path is a path for accessing the configuration file to be processed, for example, the configuration path is d:\config.xml.
[0048] Step 202: Check whether the type of the sub-operation interface in the general operation interface matches the configuration type.
[0049] In this embodiment, the general operation interface is an interface pre-developed for connecting to configuration files of different configuration types. In order to connect to multiple different types of configuration files, sub-operation interfaces corresponding to configuration files of multiple configuration types are provided in the general operation interface, and each sub-operation interface corresponds to a corresponding configuration type; for example, the general operation interface includes four types of sub-operation interfaces, and the four types of sub-operation interfaces correspond to configuration files of four formats: ini, json, xml, and yaml, respectively.
[0050] In this embodiment, the sub-operation interface in the general operation interface is obtained based on the operation method of the configuration item in the above embodiment, that is, each sub-operation interface can implement the operation method of the above configuration item. By sending the parameters of the configuration file under the corresponding configuration type (for example, the configuration path of the configuration file and the operation request) to the sub-operation interface and calling the sub-operation interface (at this time, running the operation of the configuration item corresponding to the sub-operation interface), the operation of the configuration file to be processed can be implemented.
[0051] In this embodiment, each sub-operation interface is initialized according to the requirements of different native APIs. Different programming languages usually have different code expressions, which can be generally expressed as Config.load (configuration type, configuration path). For example, X = Config.load ("ini", "d:\config.ini"), X = Config.load ("yaml", "d:\config.yaml"), load automatically creates an interface object according to the configuration file type and initializes it, and records the configuration file path "d:\config.yaml" as the internal variable configFilePath. Taking XML as an example, the configuration file operation interface is obtained, and the process of initializing each configuration file interface according to the requirements of different native APIs is as follows: XmlDocument x = new XmlDocument (configFilePath), taking JSON as an example, JSON x = JSON.parse (configFilePath).
[0052] In this embodiment, the above step 102 includes: obtaining the type of each sub-operation interface in the general operation interface according to the configuration type; in response to the configuration type being the same as the type of the sub-operation interface in the general operation interface, determining that the type of the sub-operation interface in the general operation interface matches the configuration type; in response to the configuration type being different from the type of any sub-operation interface in the general operation interface, determining that the type of the sub-operation interface in the general operation interface does not match the configuration type.
[0053] Step 203: In response to detecting that the type of the sub-operation interface in the general operation interface matches the configuration type, it is determined in real time whether there is an operation request for operating the configuration file to be processed.
[0054] In this embodiment, the operation request for operating the configuration file includes: a read configuration item request for reading configuration information of the configuration item in the configuration file to be processed, and a write configuration item request for writing configuration information of the configuration item in the configuration file to be processed.
[0055] Step 204: In response to an operation request for operating the configuration file to be processed, the configuration path and the operation request are sent to the sub-operation interface, and the sub-operation interface is called to operate the configuration file to be processed.
[0056] In this embodiment, calling the sub-operation interface can enable the sub-operation interface to execute the operation method of the configuration item according to its interface logic and input parameters (configuration path and operation request).
[0057] The configuration file operation method provided in this embodiment can use a unified code for all configuration items of the configuration file through a sub-operation interface. When a configuration item is updated, the internal program is notified through the sub-operation interface.
[0058] The configuration file operation method provided by the embodiment of the present disclosure, first, obtains the configuration type and configuration path of the loaded configuration file to be processed; secondly, detects whether the type of the sub-operation interface in the general operation interface matches the configuration type, and the sub-operation interface in the general operation interface is obtained based on the device described in any implementation method of the third aspect; thirdly, in response to detecting that the type of the sub-operation interface in the general operation interface matches the configuration type, it is judged in real time whether there is an operation request to operate the configuration file to be processed; finally, in response to the operation request to operate the configuration file to be processed, the configuration path and the operation request are sent to the sub-operation interface, and the sub-operation interface is called to operate the configuration file to be processed. Thus, through the pre-configured sub-operation interface corresponding to different configuration types, the configuration items of the configuration files of different configuration types are uniformly operated; after the configuration file to be processed is loaded into the current system, the corresponding sub-operation interface is determined based on the configuration type of the configuration file to be processed, and the operation request and configuration path of the file to be processed are sent to the sub-operation interface, without the need for developers to find the application interface of the configuration type, thereby improving the development efficiency of using different types of configuration files.
[0059] In some embodiments of the present disclosure, the above-mentioned configuration file operation method also includes: in response to detecting that the type of the sub-operation interface in the general operation interface does not match the configuration type, and there is an operation request for the configuration file to be processed, calling the file operation interface corresponding to the configuration file to be processed, and operating the configuration file to be processed.
[0060] In this embodiment, the file operation interface is an application programming interface independently constructed by the turnstile for the configuration file, and the parameters of the file operation interface are the same as the parameters of the configuration file. For example, the file operation interface is obtained by constructing an interface using a traditional configuration file access method.
[0061] In this embodiment, the file operation interface is an interface specifically used to read or write data from the configuration file to be processed. When the file operation interface is called, the read or write operation of the configuration file to be processed can be implemented.
[0062] In this embodiment, the operation request for the configuration file to be processed includes: a read request for the configuration file to be processed or a write request for the configuration file to be processed, wherein the read request is a request to read the configuration items and configuration information of the configuration items in the configuration file to be processed; and the write request is a request to write information to the configuration file to be processed.
[0063] The configuration file operation method provided in this embodiment, when it is detected that the type of the sub-operation interface in the general operation interface does not match the configuration type and there is an operation request for the configuration file to be processed, calls the file operation interface corresponding to the configuration file to be processed to operate the configuration file to be processed. Thus, the configuration file to be processed is operated using a specially constructed file operation interface, thereby improving the efficiency of the operation of the configuration file to be processed.
[0064] Configuration items of the same configuration file may be used by different programs. Some programs may change configuration items, which may change the configuration items. It may also be manually modified. In order to monitor the configuration files to be processed, Figure 3 A process 300 of another embodiment of a method for operating a configuration file according to the present disclosure is shown. The method for operating a configuration file includes the following steps:
[0065] Step 301, obtaining the configuration type and configuration path of the loaded configuration file to be processed.
[0066] Step 302: Check whether the type of the sub-operation interface in the general operation interface matches the configuration type.
[0067] In this embodiment, the sub-operation interface in the general operation interface is obtained based on the operation method of the configuration item in the above embodiment.
[0068] Step 303: In response to detecting that the type of the sub-operation interface in the general operation interface matches the configuration type, it is determined in real time whether there is an operation request for operating the configuration file to be processed.
[0069] Step 304: In response to an operation request for operating the configuration file to be processed, the configuration path and the operation request are sent to the sub-operation interface, and the sub-operation interface is called to operate the configuration file to be processed.
[0070] It should be understood that the operations and features in the above steps 301-304 correspond to the operations and features in steps 201-204, respectively. Therefore, the description of the operations and features in the above steps 201-204 is also applicable to steps 301-304 and will not be repeated here.
[0071] Step 305: monitor in real time whether the configuration file to be processed changes.
[0072] In this embodiment, the modification time of the configuration file to be processed recorded in the system can be used to determine whether the current configuration file to be processed has changed, that is, the above real-time monitoring of whether the configuration file to be processed has changed includes: obtaining the modification time of the configuration file to be processed; comparing the modification time with the current time; in response to the modification time being greater than the time threshold than the current time, determining that the configuration file to be processed has changed; otherwise, determining that the configuration file to be processed has not changed. The time threshold is the time interval for the system to read the modification time, for example, the time threshold is 5s.
[0073] Optionally, the above-mentioned real-time monitoring of whether the configuration file to be processed has changed includes: obtaining the modification time of the configuration file to be processed; detecting whether the modification time has changed; in response to detecting that the modification time has changed, obtaining the file size of the configuration file to be processed; detecting whether the file size has changed; in response to detecting that the file size has changed, determining that the configuration file to be processed has changed; otherwise, determining that the configuration file to be processed has not changed.
[0074] Step 306: in response to a change in the configuration file to be processed, obtain the old value of the configuration item in the configuration file to be processed, and obtain the new value of the configuration item in the configuration file to be processed through the sub-operation interface.
[0075] In this embodiment, when each sub-operation interface operates the configuration file to be processed, the identifier and the configuration items corresponding to each identifier will be stored in the identifier configuration table corresponding to each sub-operation interface, and the configuration information corresponding to the configuration item will be queried from the database (the sub-operation interface will store the configuration information of the configuration item in the database when operating the configuration item) based on the configuration item, and the configuration information will be used as the old value.
[0076] In this embodiment, the new value is the configuration information of the latest configuration item obtained by calling the sub-operation interface. The above-mentioned obtaining the new value of the configuration item in the configuration file to be processed through the sub-operation interface includes: sending a read configuration item request and a configuration path to the sub-operation interface, and calling the sub-operation interface, and using the configuration information corresponding to the configuration item in the configuration file to be processed as the new value.
[0077] Step 307, checking whether the old value and the new value are consistent.
[0078] Step 308: In response to detecting that the old value is inconsistent with the new value, the new value is used to replace the old value.
[0079] In this embodiment, the inconsistency between the old value and the new value means that the old value and the new value are completely different. When the old value and the new value are consistent, the new value can be used to replace the old value in the above database. When the old value and the new value are consistent, no change is made to the data in the configuration file to be processed or the database.
[0080] The configuration file operation method provided by the embodiment of the present disclosure monitors in real time whether the configuration file to be processed changes; after the configuration file to be processed changes, obtains the old value of the configuration item; obtains the new value of the configuration item through the sub-operation interface; when it is detected that the old value and the new value are inconsistent, the new value is used to replace the old value. Therefore, after the configuration file to be processed is updated by an external program or manually, the configuration information of the configuration item of the configuration file to be processed recorded externally can be updated in time, thereby improving the comprehensiveness and reliability of the information record of the configuration file to be processed.
[0081] In some optional implementations of the present disclosure, the above-mentioned real-time monitoring of whether the configuration file to be processed has changed includes: obtaining the modification time of the configuration file to be processed; detecting whether the modification time has changed; in response to detecting that the modification time has changed, obtaining encryption information of the configuration file to be processed; detecting whether the encryption information has changed; in response to detecting that the encryption information has changed, determining that the configuration file to be processed has changed.
[0082] In this optional implementation, the modification time of the configuration file to be processed is the time recorded by the system (the system running the configuration file to be processed) after the configuration file to be processed is changed. The modification time can indicate whether the configuration file to be processed has been accessed.
[0083] In this optional implementation, the encryption information is set to ensure the correctness of the configuration file to be processed. The system will record the encryption information in real time and use the corresponding encryption verification algorithm to verify the encrypted information. If the verification passes, it is determined that the encryption information has not changed; otherwise, it is determined that the encryption information has changed and the configuration file to be processed has been changed by other programs.
[0084] In this optional implementation, the encrypted information may be the Md5 value of the configuration file to be processed, wherein Md5 allows large-capacity information to be compressed into a confidential format before signing a private key with digital signature software.
[0085] The method for monitoring the configuration file to be processed provided by the optional implementation of the present disclosure first detects the modification time of the configuration file to be processed; secondly, after the modification time of the configuration file to be processed changes, the encryption information of the configuration file to be processed is detected; finally, after determining that both the modification time and the encryption information of the configuration file to be processed have changed, it is determined that the configuration file to be processed has changed, thereby providing a reliable implementation method for monitoring the changes of the configuration file to be processed.
[0086] Optionally, in response to detecting that the modification time has changed and the encryption information has not changed, it is determined that the configuration file to be processed has not changed.
[0087] Optionally, in response to detecting that the modification time has not changed, it is determined that the configuration file to be processed has not changed.
[0088] In some embodiments of the present disclosure, the operation method of the above-mentioned configuration file also includes: in response to detecting that the type of the sub-operation interface in the general operation interface does not match the configuration type, sending a registration prompt message; receiving registration information of the corresponding configuration file to be processed; based on the registration information, creating a sub-operation interface that matches the configuration file to be processed.
[0089] In this embodiment, the above-mentioned creation of a sub-operation interface matching the configuration file to be processed based on the registration information includes: using the registration interface of the constructed configuration API interface system to register the mapping relationship of the configuration operation interface corresponding to the new configuration file type. The loading interface in the configuration API interface system creates an example of the configuration interface according to the configuration type of the configuration file to be processed, and obtains a sub-operation interface matching the configuration file to be processed.
[0090] This embodiment supports configuration files in more formats through a plug-in interface extension mechanism and is compatible with configuration file reading and updating methods in common formats such as JSON, INI, XML, and YAML, providing a complete operation interface solution for configuration file operations.
[0091] The configuration file operation method provided by the embodiment of the present disclosure operates and updates configuration files of different formats, and is compatible with more configuration file formats through a plug-in extension mechanism, thereby ensuring that developers use the same code to operate all configuration files, avoiding the complexity of the code, and improving the development efficiency of configuration files of different formats in the project.
[0092] Further references Figure 4 As an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of a device for operating a configuration item. Figure 1 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0093] like Figure 4 As shown, the configuration item operation device 400 provided in this embodiment includes: an item acquisition unit 401, an item determination unit 402, an operation unit 403, and a configuration unit 404. Among them, the above-mentioned item acquisition unit 401 can be configured to obtain the configuration path of the configuration file to be processed and the operation request for the configuration file to be processed. The above-mentioned item determination unit 402 can be configured to determine the configuration items and configuration information of the configuration items of the configuration file to be processed based on the configuration path. The above-mentioned operation unit 403 can be configured to process the configuration items according to specific arrangement rules to obtain sorting items, and store the configuration information accordingly. The above-mentioned configuration unit 404 can be configured to operate the configuration items and the configuration information based on the operation request and the sorting items.
[0094] In this embodiment, in the configuration item operation device 400, the specific processing of the item acquisition unit 401, the item determination unit 402, the operation unit 403, and the configuration unit 404 and the technical effects thereof can be referred to respectively. Figure 1 The relevant descriptions of step 101, step 102, step 103, and step 104 in the corresponding embodiment are not repeated here.
[0095] In some optional implementations of this embodiment, the above-mentioned operation request includes: a read configuration item request, and the above-mentioned configuration unit 404 is further configured to: determine the configuration item to be read based on the read configuration item request; query the configuration information corresponding to the configuration item to be read based on the sorting item; and send the configuration information in response to querying the configuration information corresponding to the configuration item to be read.
[0096] In some optional implementations of this embodiment, the above-mentioned operation request includes: a write configuration item request, and the above-mentioned configuration unit 404 is further configured to: based on the write configuration item request, obtain the configuration item to be written and the configuration information to be written; based on the sorting item, query the configuration item to be written; in response to querying the configuration item to be written, replace the configuration information of the configuration item to be written with the configuration information to be written.
[0097] Further references Figure 5 As an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of a configuration file operation device, and the device embodiment is Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0098] like Figure 5As shown, the configuration file operation device 500 provided in this embodiment includes: a file acquisition unit 501, a detection unit 502, a judgment unit 503, and a calling unit 504. Among them, the above-mentioned file acquisition unit 501 can be configured to obtain the configuration type and configuration path of the loaded configuration file to be processed. The above-mentioned detection unit 502 can be configured to detect whether the type of the sub-operation interface in the general operation interface matches the configuration type. The above-mentioned judgment unit 503 can be configured to respond to the detection that the type of the sub-operation interface in the general operation interface matches the configuration type, and judge in real time whether there is an operation request for operating the configuration file to be processed, and the sub-operation interface in the general operation interface is obtained based on the operation device of the configuration item provided in the above embodiment. The above-mentioned calling unit 504 can be configured to respond to the operation request for operating the configuration file to be processed, send the configuration path and the operation request to the sub-operation interface, and call the sub-operation interface to operate the configuration file to be processed.
[0099] In this embodiment, in the configuration file operation device 500, the specific processing of the file acquisition unit 501, the detection unit 502, the judgment unit 503, and the calling unit 504 and the technical effects thereof can be referred to respectively. Figure 2 The relevant descriptions of step 201, step 202, step 203, and step 204 in the corresponding embodiment are not repeated here.
[0100] In some optional implementations of the present embodiment, the above-mentioned device 500 also includes: an interface unit (not shown in the figure), wherein the above-mentioned interface unit is configured to call the file operation interface corresponding to the configuration file to be processed in response to detecting that the type of the sub-operation interface in the general operation interface does not match the configuration type and there is an operation request for the configuration file to be processed, and perform operations on the configuration file to be processed.
[0101] In some optional implementations of this embodiment, the above-mentioned device 500 also includes: a monitoring unit (not shown in the figure), wherein the above-mentioned monitoring unit is configured to: monitor in real time whether the configuration file to be processed changes; in response to the change of the configuration file to be processed, obtain the old value of the configuration item in the configuration file to be processed, and obtain the new value of the configuration item in the configuration file to be processed through the sub-operation interface; detect whether the old value and the new value are consistent; in response to detecting that the old value and the new value are inconsistent, replace the old value with the new value.
[0102] In some optional implementations of this embodiment, the above-mentioned monitoring unit is further configured to: obtain the modification time of the configuration file to be processed; detect whether the modification time has changed; in response to detecting that the modification time has changed, obtain the encryption information of the configuration file to be processed; detect whether the encryption information has changed; in response to detecting that the encryption information has changed, determine that the configuration file to be processed has changed.
[0103] In some optional implementations of the present embodiment, the above-mentioned device 500 also includes: a registration unit (not shown in the figure), wherein the above-mentioned registration unit is configured to: in response to detecting that the type of the sub-operation interface in the general operation interface does not match the configuration type, send a registration prompt message; receive the registration information of the corresponding configuration file to be processed; based on the registration information, create a sub-operation interface that matches the configuration file to be processed.
[0104] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device and a readable storage medium.
[0105] Figure 6 A schematic block diagram of an example electronic device 600 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0106] like Figure 6 As shown, the device 600 includes a computing unit 601, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 602 or a computer program loaded from a storage unit 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the device 600 can also be stored. The computing unit 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0107] A number of components in the device 600 are connected to the I / O interface 605, including: an input unit 606, such as a keyboard, a mouse, etc.; an output unit 607, such as various types of displays, speakers, etc.; a storage unit 608, such as a disk, an optical disk, etc.; and a communication unit 609, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 609 allows the device 600 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0108] The computing unit 601 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 601 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 601 performs the various methods and processes described above, such as the operation method of the configuration item or the operation method of the configuration file. For example, in some embodiments, the operation method of the configuration item or the operation method of the configuration file may be implemented as a computer software program, which is tangibly included in a machine-readable medium, such as a storage unit 608. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 600 via the ROM 602 and / or the communication unit 609. When the computer program is loaded into the RAM 603 and executed by the computing unit 601, one or more steps of the operation method of the configuration item or the operation method of the configuration file described above may be executed. Alternatively, in other embodiments, the computing unit 601 may be configured to execute the operation method of the configuration item or the operation method of the configuration file in any other appropriate manner (for example, by means of firmware).
[0109] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0110] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, an operating device for a configuration item, or an operating device for a configuration file, so that the program code, when executed by the processor or controller, causes the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0111] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0112] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0113] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0114] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0115] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0116] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A method for operating a configuration file, the method comprising: Get the configuration type and configuration path of the loaded configuration file to be processed; Detecting whether the type of the sub-operation interface in the general operation interface matches the configuration type; In response to detecting that the type of the sub-operation interface in the general operation interface matches the configuration type, determining in real time whether there is an operation request for operating the configuration file to be processed; In response to an operation request for operating the configuration file to be processed, sending the configuration path and the operation request to the sub-operation interface, and calling the sub-operation interface to operate the configuration file to be processed; The sub-operation interface in the general operation interface is implemented by the following steps: Obtaining a configuration path of a configuration file to be processed and an operation request for the configuration file to be processed; Based on the configuration path, determining the configuration items of the configuration file to be processed and the configuration information of the configuration items; The configuration items are processed according to specific arrangement rules to obtain sorting items, and the configuration information is stored accordingly, wherein the arrangement rules refer to the arrangement positions of different types of nodes indicated by Xpath for configuration items of all types of configuration files; the sorting items are used to represent the sorting relationship of the configuration items or the item identifiers corresponding to the configuration items in a specific sorting order; Based on the operation request and the sorting item, the configuration item and the configuration information are operated.
2. The method according to claim 1, wherein: The operation request includes: a request to read a configuration item, and the operation of the configuration item and the configuration information based on the operation request and the sorting item includes: Based on the configuration item read request, determine the configuration item to be read; Based on the sorting item, query the configuration information corresponding to the configuration item to be read; In response to querying the configuration information corresponding to the configuration item to be read, the configuration information is sent.
3. The method according to claim 1, wherein: The operation request includes: a write configuration item request, and the operation of the configuration item and the configuration information based on the operation request and the sorting item includes: Based on the configuration item write request, obtaining the configuration item to be written and the configuration information to be written; Based on the sorting items, query the configuration items to be written; In response to finding the configuration item to be written, the configuration information to be written is used to replace the configuration information of the configuration item to be written.
4. The method according to claim 1, further comprising: In response to detecting that the type of the sub-operation interface in the general operation interface does not match the configuration type and there is an operation request for the configuration file to be processed, calling a file operation interface corresponding to the configuration file to be processed to operate the configuration file to be processed.
5. The method according to claim 1 or 4, further comprising: Real-time monitoring of whether the configuration file to be processed changes; In response to a change in the configuration file to be processed, obtaining an old value of a configuration item in the configuration file to be processed, and obtaining a new value of the configuration item in the configuration file to be processed through the sub-operation interface; Detect whether the old value and the new value are consistent; In response to detecting that the old value is inconsistent with the new value, the old value is replaced with the new value.
6. The method according to claim 5, wherein: The real-time monitoring of whether the configuration file to be processed changes includes: Obtaining the modification time of the configuration file to be processed; Detecting whether the modification time has changed; In response to detecting that the modification time has changed, obtaining encryption information of the configuration file to be processed; Detecting whether the encrypted information has changed; In response to detecting that the encryption information has changed, it is determined that the configuration file to be processed has changed.
7. The method according to claim 1, further comprising: In response to detecting that the type of the sub-operation interface in the general operation interface does not match the configuration type, sending a registration prompt message; Receiving the corresponding registration information of the configuration file to be processed; Based on the registration information, a sub-operation interface matching the configuration file to be processed is created.
8. A configuration file operation device, the operation device comprising: A file acquisition unit is configured to acquire a configuration type and a configuration path of a loaded configuration file to be processed; a detection unit configured to detect whether the type of the sub-operation interface in the general operation interface matches the configuration type; A determination unit configured to, in response to detecting that the type of the sub-operation interface in the general operation interface matches the configuration type, determine in real time whether there is an operation request for operating the configuration file to be processed; a calling unit configured to, in response to an operation request for operating the configuration file to be processed, send the configuration path and the operation request to the sub-operation interface, and call the sub-operation interface to operate the configuration file to be processed; The sub-operation interface in the general operation interface is implemented by the following units: An item acquisition unit, configured to acquire a configuration path of a configuration file to be processed and an operation request for the configuration file to be processed; an item determination unit, configured to determine, based on the configuration path, a configuration item of the configuration file to be processed and configuration information of the configuration item; an operating unit configured to process the configuration items according to a specific arrangement rule to obtain a sorting item, and store the configuration information accordingly, wherein the arrangement rule refers to the arrangement position of different types of nodes indicated by Xpath for controlling configuration items of all types of configuration files; the sorting item is used to represent a sorting relationship of a specific sorting order for the configuration items or item identifiers corresponding to the configuration items; A configuration unit is configured to operate the configuration item and the configuration information based on the operation request and the sorting item.
9. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to enable the computer to execute the method according to any one of claims 1 to 7.
