A Python Configuration Monitoring and Response Method, Device, Equipment and Readable Medium

By defining modifier functions and configuring monitoring base classes, the redundancy and controllability problems of configuration item management in Python applications are solved, unified management and standardized response are achieved, and code error probability and maintenance costs are reduced.

CN114489771BActive Publication Date: 2025-07-11INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210108975.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-28
Publication Date
2025-07-11
Estimated Expiration
2042-01-28

AI Technical Summary

Technical Problem

Existing Python applications lack unified management in configuration item management, resulting in redundant code, large modification amount, poor system controllability, high maintenance cost, inconsistent interface implementation between different business modules, and poor code readability.

Method used

Define modifier functions and configuration monitoring base classes, manage configuration items and business modules through mapping relationships, reduce redundant code definitions, realize unified management and standardized responses, reduce the probability of code errors, and enhance system controllability and code readability.

Benefits of technology

By defining modifier functions and configuring monitoring base classes, the amount of redundant code is reduced, the probability of code errors is reduced, unified management and standardized response are achieved, and system controllability and code maintenance efficiency are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114489771B_ABST
    Figure CN114489771B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for Python configuration monitoring and response, including: adding configuration item attributes to multiple decorated functions of a business module by defining a modifier function; defining a configuration monitoring base class, defining a constructor for the configuration monitoring base class to construct a first mapping of configuration items and decorated functions, and defining a response total entry function for the configuration monitoring base class; initializing the business module based on the configuration monitoring base class to generate a business module instance, and maintaining a second mapping of configuration items and business module instances by a registration interface; in response to the user updating a target configuration item through a save interface, the notification interface searches for the target business module instance corresponding to the target configuration item based on the second mapping, and updates the target configuration item in the target business module instance; and calling the response total entry function, searching for the target decorated function corresponding to the target configuration item based on the first mapping, and updating the configuration item attributes of the target decorated function through the modifier function.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of computer software, and in particular, to a method, apparatus, device and readable medium for configuring monitoring and response of Python. Background Art

[0002] With the continuous improvement and development of the functions of the Python programming language, more and more applications are developed based on the Python programming language. For various functions provided by Python applications, corresponding configuration items will be designed. When users modify some configuration items, the application needs to save them in time and make responses according to the established logic. For an application, it is necessary to handle issues such as who monitors the configuration items, which configuration items to monitor, and which monitoring parties need to be notified of changes in which configuration items, such as business modules.

[0003] Existing Python applications generally establish various business modules from the perspective of decoupling. Each business module monitors some configuration items. When the configuration changes, the monitoring party is notified and the response is triggered by sending a message or making a call. However, with the expansion of the functions of the application, the number of configuration items is increasing, and the corresponding number of business modules is also increasing. Every time a business module is added or modified, the configuration trigger logic code needs to be added or modified again. If it is notified by sending a message, the message definition and message binding need to be added. If it is by means of a call, the call code needs to be added. Over time, a large number of messages will be defined and a large number of calls will be added. There are many places to modify and the amount of modification is large. The code is very redundant. The larger the scale of the application, the more likely problems will be introduced. From the perspective of program management, it is impossible to overall control which configuration item changes will affect which business modules, lacking unified management and poor system controllability. Further, different business modules of an application are generally developed by different personnel, and their interface implementations are different. When the interface changes, synchronous modifications need to be made on the triggering side. When triggering the response, different modules and different interfaces need to be distinguished explicitly, resulting in poor code readability and high maintenance costs. Summary of the Invention

[0004] In view of this, the purpose of the embodiments of the present invention is to provide a method, apparatus, device and readable medium for configuring monitoring and response of Python, define corresponding base classes, and manage each business module, avoiding the need to focus on defining redundant messages or adding calls, greatly reducing the redundant processing logic, reducing the probability of code errors, making the processing logics of numerous business modules still clear and the system highly controllable. Moreover, thanks to the definition of the base class and the use of inheritance, each interface is standardized and unified, and no additional distinction is required when triggering the response, greatly enhancing the code readability and reducing the code maintenance cost.

[0005] For the above purposes, an aspect of an embodiment of the present invention provides a method for Python configuration monitoring and response, including the following steps: adding configuration item attributes to multiple decorated functions of a business module by defining a decorator function; defining a configuration monitoring base class, defining a constructor for the configuration monitoring base class to construct a first mapping between configuration items and decorated functions, and defining a response total entry function for the configuration monitoring base class; initializing the business module based on the configuration monitoring base class to generate a business module instance, and maintaining a second mapping between configuration items and business module instances by a registration interface; in response to a user updating a target configuration item through a save interface, the notification interface searches for the target business module instance corresponding to the target configuration item based on the second mapping, and updates the target configuration item in the target business module instance; and calling the response total entry function, searching for the target decorated function corresponding to the target configuration item based on the first mapping, and updating the configuration item attributes of the target decorated function through the decorator function.

[0006] In some embodiments, the method further includes: defining a global configuration management module to provide a registration interface, a save interface, and a notification interface.

[0007] In some embodiments, adding configuration item attributes to multiple decorated functions of a business module by defining a decorator function includes: constructing a decorator function, adding an attribute to the decorated function in the decorator function, and the added attribute value is a configuration item; decorating multiple decorated functions of the business module through the decorator function.

[0008] In some embodiments, defining a constructor for the configuration monitoring base class to construct a first mapping between configuration items and decorated functions includes: defining a constructor, and traversing all functions in the constructor to count the decorated functions with attributes added by the decorator function and the corresponding configuration items, so as to construct a first mapping between configuration items and decorated functions.

[0009] In some embodiments, initializing the business module based on the configuration monitoring base class to generate a business module instance includes: the class of the business module inherits the configuration monitoring base class, and initializes the class of the business module to generate a business module instance.

[0010] In some embodiments, in response to a user updating a target configuration item through a save interface includes: in response to a user modifying a configuration item through an application page, calling the save interface to save the modified target configuration item and the updated configuration item.

[0011] On the other hand, an embodiment of the present invention further provides a Python configuration monitoring and response device, including: a first module configured to add configuration item attributes to multiple decorated functions of a service module by defining a decorator function; a second module configured to define a configuration monitoring base class, define a constructor for the configuration monitoring base class to construct a first mapping between configuration items and decorated functions, and define a response total entry function for the configuration monitoring base class; a third module configured to initialize the service module based on the configuration monitoring base class to generate a service module instance, and maintain a second mapping between configuration items and service module instances by a registration interface; a fourth module configured to, in response to a user updating a target configuration item through a save interface, find a target service module instance corresponding to the target configuration item based on the second mapping by a notification interface, and update the target configuration item in the target service module instance; and a fifth module configured to call the response total entry function, find a target decorated function corresponding to the target configuration item based on the first mapping, and update the configuration item attributes of the target decorated function through the decorator function.

[0012] In some embodiments, the device further includes a sixth module configured to define a global configuration management module to provide a registration interface, a save interface, and a notification interface.

[0013] On yet another aspect of the embodiments of the present invention, a computer device is further provided, including: at least one processor; and a memory storing computer instructions executable on the processor, and when the instructions are executed by the processor, the steps of the above method are implemented.

[0014] On yet another aspect of the embodiments of the present invention, a computer-readable storage medium is further provided, and the computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the above method.

[0015] The present invention has at least the following beneficial technical effects: By defining a modifier function, configuring a monitoring base class, and a global configuration management module, business modules need to follow established constraints when being defined. In this way, when the application expands configuration items, adds or modifies business modules, it only needs to focus on what kind of response to make for which configuration items, that is, which functions are modified by modifiers and what processing is done in the response functions. The work of collecting other configuration items, mapping functions, and configuration items and business module objects is completed in the constructor of the configuration monitoring base class, without the need to define additional code, greatly reducing the amount of redundant code and the implementation difficulty, reducing the probability of code errors. Program maintainers can immediately query all business modules associated with a certain configuration item in the global configuration management module, achieving unified management, enhancing the controllability of the system, and greatly reducing the code maintenance cost. It solves the problems in the prior art that as the number of business modules increases, there are many repeated definitions, a large amount of code redundancy, a large amount of code modification, inability to uniformly manage configuration and business responses, poor system controllability, a high probability of program errors, and poor code maintainability. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other embodiments can be obtained based on these drawings.

[0017] Figure 1 It is a schematic diagram of an embodiment of the method for configuration monitoring and response of Python provided by the present invention;

[0018] Figure 2 It is a schematic diagram of an embodiment of the device for configuration monitoring and response of Python provided by the present invention;

[0019] Figure 3 It is a schematic diagram of an embodiment of the computer device provided by the present invention;

[0020] Figure 4 It is a schematic diagram of an embodiment of the computer-readable storage medium provided by the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0021] To make the objectives, technical solutions, and advantages of the present invention clearer and more understandable, the following further details the embodiments of the present invention in conjunction with specific embodiments and with reference to the accompanying drawings.

[0022] It should be noted that in the embodiments of the present invention, all expressions using "first" and "second" are for distinguishing two entities or parameters with the same name but different identities. It can be seen that "first" and "second" are only for the convenience of expression and should not be construed as a limitation on the embodiments of the present invention. This will not be elaborated in subsequent embodiments one by one.

[0023] Based on the above purposes, in the first aspect of the embodiments of the present invention, an embodiment of a method for configuring monitoring and response of Python is proposed. Figure 1 Shown is a schematic diagram of an embodiment of a method for configuring monitoring and response of Python provided by the present invention. As Figure 1 shown, the method for configuring monitoring and response of Python in the embodiments of the present invention includes the following steps:

[0024] 001. Add configuration item attributes to multiple decorated functions of a service module by defining a decorator function;

[0025] 002. Define a configuration monitoring base class, define a constructor for the configuration monitoring base class to construct a first mapping between configuration items and decorated functions, and define a response total entry function for the configuration monitoring base class;

[0026] 003. Initialize the service module based on the configuration monitoring base class to generate a service module instance, and maintain a second mapping between the configuration item and the service module instance by a registration interface;

[0027] 004. In response to the user updating a target configuration item through a save interface, the notification interface searches for the target service module instance corresponding to the target configuration item based on the second mapping, and updates the target configuration item in the target service module instance; and

[0028] 005. Call the response total entry function, search for the target decorated function corresponding to the target configuration item based on the first mapping, and update the configuration item attribute of the target decorated function through the decorator function.

[0029] In this embodiment, a modifier function is defined. For all business modules that need to respond to configuration item changes, the specific response functions need to be modified using this modifier function, and the configuration items to be monitored are marked in the input parameters of the modifier. A configuration monitoring base class is defined. All business modules need to inherit this class when implemented. When a business module object is initialized and constructed, according to the inheritance principle, the constructor of the parent class, that is, the configuration monitoring base class, will be executed first. In the constructor of this base class, the business response functions modified by the modifier are collected centrally, so as to count the mapping relationship between the configuration items and the business function names. A global configuration management module is defined. This module is responsible for saving and change notification when the user modifies any configuration item, and at the same time provides a registration API to each business module object. Each business module calls this API to register the business module instance and the configuration item to the global configuration management module. In this way, when a certain configuration item changes, the global configuration management module can immediately find which business modules need to be notified for this configuration item. The notified business module then queries the response function corresponding to the configuration item, and thus executes the response function to implement the monitoring and response of the application program to the configuration item. When adding or modifying a business module, only the responses to which configuration items need to be concerned, that is, modifying the response function with the modifier and making corresponding processing in the response function. Other work of collecting configuration items and mapping functions, and configuration items and business module objects is completed in the constructor of the configuration monitoring base class. The business module does not need to define additional code, which greatly reduces the amount of redundant code and the implementation difficulty, reduces the probability of code errors, and the program maintainer can query all business modules associated with a certain configuration item in the global configuration management module, achieving unified management, enhancing the controllability of the system, and greatly reducing the code maintenance cost.

[0030] In some embodiments of the present invention, the method further includes: defining a global configuration management module to provide a registration interface, a saving interface, and a notification interface.

[0031] In this embodiment, a global configuration management module is defined. This module is used to uniformly manage each configuration item and the corresponding business module instance. By providing a registration API, it maintains a second mapping conf_busn_map between the configuration item conf_key and the business module instance busn_obj. By providing a saving API, it processes the user's modification of the configuration item and the corresponding latest value. By providing a notification API, it is used to notify the monitored business module instance busn_obj after the configuration item conf_key changes.

[0032] In some embodiments, adding configuration item attributes to multiple modified functions of a business module by defining a modifier function includes: constructing the modifier function, adding an attribute to the modified function in the modifier function, and the added attribute value is the configuration item; modifying multiple modified functions of the business module with the modifier function.

[0033] In this embodiment, attributes are added to the decorated response function func within the modifier function, and the configuration item name is saved, such as func._conf_listen = conf_key. In this way, as long as a function decorated with the @modifier is imported (loaded) in Python code, the operations defined by the modifier function will be performed on the decorated function. As defined above, the decorated function func will have an added attribute _conf_listen with the value conf_key.

[0034] In some embodiments, defining a constructor for the configuration monitoring base class to construct the first mapping of configuration items and decorated functions includes: defining a constructor, and in the constructor, traversing all functions to count the decorated functions with attributes added by the modifier function and the corresponding configuration items, so as to construct the first mapping of configuration items and decorated functions.

[0035] In this embodiment, the configuration monitoring base class is used to be inherited by other business modules, which will be introduced below. For this configuration monitoring base class, a constructor is defined. In the constructor, all member functions of the class are traversed, and the function names with attributes added by the modifier function (such as _conf_listen) and the corresponding configuration item names conf_key are counted, and then the first mapping conf_func_map of conf_key and func_name is constructed.

[0036] In some embodiments, initializing a business module based on the configuration monitoring base class to generate a business module instance includes: the class of the business module inherits the configuration monitoring base class, and the class of the business module is initialized to generate a business module instance.

[0037] In this embodiment, each business module needs to inherit the configuration monitoring base class when implemented, and use the modifier function to decorate specific response functions. According to the inheritance principle, the attributes of the parent class, that is, the configuration monitoring base class, will also be possessed by the business module instance. When the constructor of the business module instance is executed, the constructor of the parent class, that is, the constructor of the configuration monitoring base class, will be executed first. In this way, the business module instance will also have the first mapping conf_func_map and the response total entry function on_configuration_change.

[0038] In some embodiments, responding to the user's update of the target configuration item through the save interface includes: responding to the user's modification of the configuration item through the application page, and then calling the save interface to save the modified target configuration item and the updated configuration item.

[0039] In this embodiment, after the user modifies the configuration item conf_key through the application program page and changes its value to conf_value, the program will call the save API provided by the global configuration management module to save the latest value.

[0040] The following further elaborates on the specific implementation manner of the present invention according to specific embodiments. Specifically, it includes:

[0041] First, construct a modifier function. Inside the modifier function, add attributes to the decorated response function func and save the configuration item name, such as func._conf_listen = conf_key. In this way, as long as a function decorated by the @ modifier is imported in Python code, the operations defined in the modifier function will be executed on the decorated function. As defined above, the decorated function func will have an additional attribute _conf_listen with the value conf_key.

[0042] Second, construct a configuration monitoring base class. This configuration monitoring base class is used to be inherited by other business modules, which will be introduced below. For this configuration monitoring base class, define a constructor. In the constructor, traverse all member functions of the class, count the function names and corresponding configuration item names conf_key of the functions with attributes added by the modifier function (such as _conf_listen), and then construct the first mapping conf_func_map of conf_key and func_name. At the same time, define a response total entry function, such as on_configuration_change, for receiving notifications.

[0043] Third, construct a global configuration management module. This module is used to uniformly manage each configuration item and the corresponding business module instance, maintain the second mapping conf_busn_map of the configuration item conf_key and the business module instance busn_obj by providing a registration API, process the user's modification of the configuration item and the corresponding latest value by providing a save API, and notify the listening business module instance busn_obj when the configuration item conf_key changes by providing a notification API.

[0044] Next, construct each business module and instance. When implementing each business module, it needs to inherit from the configuration monitoring base class and decorate the specific response function with a modifier function. According to the inheritance principle, the attributes that the parent class, i.e., the configuration monitoring base class, has will also be possessed by the business module instance. When the constructor of the business module instance is executed, the constructor of the parent class, i.e., the constructor of the configuration monitoring base class, will be executed first. In this way, the business module instance will also have the first mapping conf_func_map and the response total entry function on_configuration_change. After the construction of the business module instance is completed, call the registration API provided by the global configuration management module to register the current business module instance busn_obj and all the conf_keys in the first mapping conf_func_map uniformly.

[0045] Finally, the user modifies the configuration item through the application page to trigger the established logic. When the user modifies the configuration item conf_key through the application page and changes its value to conf_value, the program will call the save API provided by the global configuration management module to save the latest value, and then call the notification API provided by the global configuration management module. By retrieving the changed configuration item conf_key in the second mapping conf_busn_map, find the corresponding business module instance busn_obj, and call the response entry function on_configuration_change of the business module instance through busn_obj. In the response entry function defined in the business module, by retrieving the changed configuration item conf_key in the first mapping conf_func_map, find the final target response function, and then execute the function to complete the specific logical processing.

[0046] It should be particularly noted that each step in the above embodiments of the Python configuration monitoring and response method can be crossed, replaced, added, or deleted with each other. Therefore, these reasonable permutation and combination transformations also belong to the protection scope of the present invention for the Python configuration monitoring and response method, and the protection scope of the present invention should not be limited to the embodiments.

[0047] Based on the above purpose, the second aspect of the embodiments of the present invention proposes a Python configuration monitoring and response device. Figure 2 Shown is a schematic diagram of an embodiment of the Python configuration monitoring and response device provided by the present invention. As Figure 2As shown in the figure, the Python configuration monitoring and response device according to the embodiment of the present invention includes the following modules: a first module 011 configured to add configuration item attributes to a plurality of decorated functions of a service module by defining a decorator function; a second module 012 configured to define a configuration monitoring base class, define a constructor for the configuration monitoring base class to construct a first mapping between configuration items and decorated functions, and define a response total entry function for the configuration monitoring base class; a third module 013 configured to initialize the service module based on the configuration monitoring base class to generate a service module instance, and maintain a second mapping between configuration items and the service module instance by a registration interface; a fourth module 014 configured to, in response to a user updating a target configuration item through a save interface, find a target service module instance corresponding to the target configuration item based on the second mapping by a notification interface, and update the target configuration item in the target service module instance; and a fifth module 015 configured to call the response total entry function, find a target decorated function corresponding to the target configuration item based on the first mapping, and update the configuration item attributes of the target decorated function through the decorator function.

[0048] In some embodiments, the device further includes a sixth module configured to define a global configuration management module to provide a registration interface, a save interface, and a notification interface.

[0049] Based on the above objectives, a third aspect of the embodiment of the present invention proposes a computer device. Figure 3 Shown is a schematic diagram of an embodiment of the computer device provided by the present invention. As Figure 3 shown, the computer device according to the embodiment of the present invention includes the following device: at least one processor 021; and a memory 022, where the memory 022 stores computer instructions 023 that can run on the processor, and when the instructions are executed by the processor, the steps of the above method are implemented.

[0050] The present invention also provides a computer-readable storage medium. Figure 4 Shown is a schematic diagram of an embodiment of the computer-readable storage medium provided by the present invention. As Figure 4 shown, the computer-readable storage medium 031 stores a computer program 032 that, when executed by a processor, executes the above method.

[0051] Finally, it should be noted that those of ordinary skill in the art can understand that all or part of the processes in the above-described method embodiments can be completed by instructing relevant hardware through a computer program. The program for the method of Python configuration monitoring and response can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the above-described method embodiments. Among them, the storage medium of the program can be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM), etc. The embodiments of the above computer program can achieve the same or similar effects as the corresponding foregoing method embodiments.

[0052] In addition, the method disclosed according to the embodiments of the present invention can also be implemented as a computer program executed by a processor, and the computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the above functions defined in the method disclosed according to the embodiments of the present invention are executed.

[0053] In addition, the above method steps and system units can also be implemented by using a controller and a computer-readable storage medium for storing a computer program that enables the controller to implement the above steps or unit functions.

[0054] Those skilled in the art will also understand that the various exemplary logical blocks, modules, circuits, and algorithm steps described in connection with the disclosure herein can be implemented as electronic hardware, computer software, or a combination of both. To clearly illustrate this interchangeability of hardware and software, a general description of the functions of various illustrative components, blocks, modules, circuits, and steps has been given. Whether this function is implemented as software or hardware depends on the specific application and the design constraints imposed on the overall system. The functions that those skilled in the art can implement in various ways for each specific application, but this implementation decision should not be construed as causing a departure from the scope of the disclosure of the embodiments of the present invention.

[0055] In one or more exemplary designs, the functions may be implemented in hardware, software, firmware, or any combination thereof. If implemented in software, the functions may be stored on or transmitted via a computer-readable medium as one or more instructions or code. Computer-readable media includes both computer storage media and communication media including any medium that facilitates transfer of a computer program from one location to another. The storage media may be any available media that can be accessed by a general purpose or special purpose computer. By way of example, and not limitation, the computer-readable media may comprise RAM, ROM, EEPROM, CD-ROM or other optical disk storage, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a general purpose or special purpose computer or a general purpose or special purpose processor. Additionally, any connection is properly termed a computer-readable medium. For example, if software is transmitted from a website, server, or other remote source using a coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave, then the coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave are included in the definition of medium. As used herein, disk and disc include compact disc (CD), laser disc, optical disc, digital versatile disc (DVD), floppy disk, and Blu-ray disc where disks usually reproduce data magnetically, while discs reproduce data optically with lasers. Combinations of the above should also be included within the scope of computer-readable media.

[0056] The above are exemplary embodiments disclosed by the present invention. However, it should be noted that various changes and modifications can be made without departing from the scope of the embodiments disclosed by the present invention as defined by the claims. The functions, steps, and / or actions of the method claims according to the disclosed embodiments herein need not be performed in any particular order. In addition, although the elements disclosed by the embodiments of the present invention may be described or claimed in individual form, they may also be understood as plural unless explicitly limited to the singular.

[0057] It should be understood that, as used herein, unless the context clearly supports the contrary, the singular forms "a" are also intended to include the plural forms. It should also be understood that the term "and / or" as used herein refers to and includes any and all possible combinations of one or more of the associated listed items.

[0058] The serial numbers of the disclosed embodiments of the present invention above are merely for description and do not represent the merits of the embodiments.

[0059] Those of ordinary skill in the art can understand that all or part of the steps to implement the above embodiments can be completed by hardware, or can be completed by instructing relevant hardware through a program. The program can be stored in a computer-readable storage medium, and the above-mentioned storage medium can be a read-only memory, a magnetic disk or an optical disc, etc.

[0060] Those of ordinary skill in the art should understand that the discussion of any above embodiment is only exemplary, and is not intended to imply that the scope (including the claims) disclosed by the embodiments of the present invention is limited to these examples; under the idea of the embodiments of the present invention, the technical features in the above embodiments or different embodiments can also be combined, and there are many other variations in different aspects of the embodiments of the present invention as above, and they are not provided in detail for the sake of brevity. Therefore, any omission, modification, equivalent replacement, improvement, etc. made within the spirit and principle of the embodiments of the present invention shall be included in the protection scope of the embodiments of the present invention.

Claims

1. A method for Python configuration monitoring and response, characterized in that, Including the following steps: Adding configuration item attributes to multiple decorated functions of a business module by defining a modifier function; Defining a configuration monitoring base class, defining a constructor for the configuration monitoring base class to construct a first mapping between configuration items and decorated functions, and defining a response total entry function for the configuration monitoring base class; Initializing the business module based on the configuration monitoring base class to generate a business module instance, and maintaining a second mapping between configuration items and the business module instance by a registration interface; In response to a user updating a target configuration item through a save interface, the notification interface searches for the target business module instance corresponding to the target configuration item based on the second mapping, and updates the target configuration item in the target business module instance; And Invoking the response total entry function, searching for the target decorated function corresponding to the target configuration item based on the first mapping, and updating the configuration item attribute of the target decorated function through the modifier function; Adding configuration item attributes to multiple decorated functions of a business module by defining a modifier function includes: Constructing a modifier function, adding an attribute to the decorated function in the modifier function, and the added attribute value is a configuration item; Decorating multiple decorated functions of the business module through the modifier function; Defining a constructor for the configuration monitoring base class to construct a first mapping between configuration items and decorated functions includes: Defining a constructor, and traversing all functions in the constructor to count the decorated functions with attributes added by the modifier function and the corresponding configuration items, so as to construct a first mapping between configuration items and decorated functions; Initializing the business module based on the configuration monitoring base class to generate a business module instance includes: The class of the business module inherits the configuration monitoring base class, and initializes the class of the business module to generate a business module instance.

2. The method according to claim 1, wherein It also includes: Defining a global configuration management module to provide a registration interface, a save interface, and a notification interface.

3. The method according to claim 1, wherein In response to a user updating a target configuration item through a save interface includes: In response to a user modifying a configuration item through an application page, the save interface is called to save the modified target configuration item and the updated configuration item.

4. A Python configuration monitoring and response device, characterized in that, Including: A first module configured to add configuration item attributes to multiple decorated functions of a business module by defining a modifier function; A second module configured to define a configuration monitoring base class, define a constructor for the configuration monitoring base class to construct a first mapping between configuration items and decorated functions, and define a response total entry function for the configuration monitoring base class; A third module configured to initialize the business module based on the configuration monitoring base class to generate a business module instance, and maintaining a second mapping between configuration items and the business module instance by a registration interface; A fourth module configured to, in response to a user updating a target configuration item through a save interface, the notification interface searches for the target business module instance corresponding to the target configuration item based on the second mapping, and updates the target configuration item in the target business module instance; And The fifth module is configured to call the total response entry function, find the target decorated function corresponding to the target configuration item based on the first mapping, and update the configuration item attributes of the target decorated function through the modifier function; The first module is further configured to: Construct a modifier function, and add an attribute to the decorated function in the modifier function, and the added attribute value is a configuration item; Modify multiple decorated functions of the service module through the modifier function; The second module is further configured to: Define a constructor function, and traverse all functions in the constructor function to count the decorated functions with attributes added by the modifier function and the corresponding configuration items, so as to construct the first mapping of the configuration items and the decorated functions; The third module is further configured to: The class of the service module inherits the configuration monitoring base class, and initializes the class of the service module to generate a service module instance.

5. The device according to claim 4, characterized in that It further includes: The sixth module is configured to define a global configuration management module to provide a registration interface, a saving interface, and a notification interface.

6. A computer device, characterized in that, It includes: At least one processor; And A memory that stores computer instructions that can be run on the processor, and when the instructions are executed by the processor, the steps of the method according to any one of claims 1-3 are implemented.

7. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, the steps of the method according to any one of claims 1-3 are implemented.

Citation Information

Patent Citations

  • Configuration processing method and device for open source framework

    CN110990054A