Dynamic configuration method, device, electronic device and storage medium
By using configuration item expressions and configuration value expressions in the configuration file to judge and determine the execution and value of configuration items, the dynamic configuration requirements caused by static configuration are solved, and dynamic configuration adjustment and system flexibility are achieved.
Patent Information
- Application Number
- CN202010641708.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-07-06
- Publication Date
- 2025-01-14
- Estimated Expiration
- 2040-07-06
AI Technical Summary
The configuration items and corresponding values in the existing configuration files are static and cannot meet the dynamic configuration requirements, resulting in the configuration being unable to change according to specific conditions.
By obtaining the configuration file of the target configuration item, using the configuration item expression to determine whether it is used to perform the configuration, and determining the configuration value through the configuration value expression, thereby dynamically configuring the target configuration parameters.
It realizes the dynamic configuration of the target configuration items in the configuration file, meets the dynamic configuration requirements of whether the configuration items in the same system or program are configured or the configuration value according to specific conditions, and improves the flexibility and adaptability of the system or program.
Smart Images

Figure CN113760344B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method, device, electronic device and storage medium for dynamic configuration. Background Art
[0002] In the field of computer science, a configuration file is a computer file that can configure parameters and initialize parameter values for some computer programs or systems when they are running. The configuration file includes many configuration items, each of which includes the name of the configuration item and the corresponding value. The name and corresponding value of the configuration item in the configuration item are usually static, that is, they do not change. Computer programs are configured by reading the configuration items in the configuration file when they are started or running.
[0003] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art:
[0004] In some scenarios, the configuration requirements of each configuration item are different under different conditions. For example, for the same system or program, whether some configuration items are configured or the corresponding values of the configurations may change according to specific conditions. At this time, since the configuration items and corresponding values in the configuration file are static, that is, the values of the configuration items are fixed when the system or program is started, the configuration items in the configuration file cannot be changed, resulting in the problem that the configuration cannot meet the dynamic configuration requirements. Summary of the invention
[0005] In view of this, the embodiments of the present invention provide a method, device, system and storage medium for dynamic configuration, which can solve the problem that the configuration items and corresponding values in the configuration file are static, and the configuration items in the configuration file cannot be changed, resulting in the configuration being unable to meet dynamic configuration requirements.
[0006] To achieve the above objective, according to one aspect of an embodiment of the present invention, a dynamic configuration method is provided.
[0007] A dynamic configuration method according to an embodiment of the present invention includes: obtaining a configuration file including at least one target configuration item, wherein the target configuration item includes a configuration item expression of a target configuration parameter and a configuration value expression of the target configuration parameter; for each of the target configuration items, judging whether the target configuration item is used to execute configuration according to the configuration item expression; if so, determining a configuration value corresponding to the target configuration parameter according to the configuration value expression, and configuring the target configuration parameter according to the configuration value; if not, ignoring the target configuration item.
[0008] In one embodiment, the configuration item expression includes at least one first target variable and a target value;
[0009] The determining, according to the configuration item expression, whether the target configuration item is used for executing configuration includes:
[0010] Obtaining a current value of the at least one first target variable;
[0011] It is determined whether the target configuration item is used for executing configuration according to the current value and the target value.
[0012] In yet another embodiment, the configuration item expression further includes an operation logic corresponding to the first target variable;
[0013] The determining, according to the current value and the target value, whether the target configuration item is used to execute the configuration includes:
[0014] Calculate the operation result corresponding to the first target variable according to the operation logic corresponding to the current value and the first target variable;
[0015] It is determined whether the target configuration item is used for executing configuration according to the calculation result and the target value.
[0016] In yet another embodiment, judging whether the target configuration item is used for executing configuration according to the current value and the target value includes:
[0017] If the current value is within the range of the target value, determining the target configuration item for executing the configuration;
[0018] If the current value is not within the range of the target value, it is determined that the target configuration item is not used for performing configuration.
[0019] In yet another embodiment, the configuration value expression includes a second target variable and an operation logic corresponding to the second target variable;
[0020] The determining the configuration value corresponding to the target configuration parameter according to the configuration value expression includes:
[0021] Obtaining the current value of the second target variable;
[0022] The configuration value corresponding to the target configuration parameter is calculated according to the operation logic corresponding to the current value and the second target variable.
[0023] To achieve the above objective, according to another aspect of the present invention, a dynamic configuration device is provided.
[0024] A dynamic configuration device of the present invention includes: an acquisition unit, used to acquire a configuration file including at least one target configuration item, wherein the target configuration item includes a configuration item expression of a target configuration parameter and a configuration value expression of the target configuration parameter; a configuration unit, used to determine, for each of the target configuration items, whether the target configuration item is used to execute configuration according to the configuration item expression; if so, determine the configuration value corresponding to the target configuration parameter according to the configuration value expression, and configure the target configuration parameter according to the configuration value; if not, ignore the target configuration item.
[0025] In one embodiment, the configuration item expression includes at least one first target variable and a target value;
[0026] The configuration unit is specifically used for:
[0027] Obtaining a current value of the at least one first target variable;
[0028] It is determined whether the target configuration item is used for executing configuration according to the current value and the target value.
[0029] In yet another embodiment, the configuration item expression further includes an operation logic corresponding to the first target variable;
[0030] The configuration unit is specifically used for:
[0031] Calculate the operation result corresponding to the first target variable according to the operation logic corresponding to the current value and the first target variable;
[0032] It is determined whether the target configuration item is used for executing configuration according to the calculation result and the target value.
[0033] In yet another embodiment, the configuration unit is specifically configured to:
[0034] If the current value is within the range of the target value, determining the target configuration item for executing the configuration;
[0035] If the current value is not within the range of the target value, it is determined that the target configuration item is not used for performing configuration.
[0036] In yet another embodiment, the configuration value expression includes a second target variable and an operation logic corresponding to the second target variable;
[0037] The configuration unit is specifically used for:
[0038] Obtaining the current value of the second target variable;
[0039] The configuration value corresponding to the target configuration parameter is calculated according to the operation logic corresponding to the current value and the second target variable.
[0040] To achieve the above objective, according to another aspect of an embodiment of the present invention, an electronic device is provided.
[0041] An electronic device according to an embodiment of the present invention includes: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement the dynamic configuration method provided by the embodiment of the present invention.
[0042] To achieve the above objective, according to another aspect of an embodiment of the present invention, a computer readable medium is provided.
[0043] A computer-readable medium according to an embodiment of the present invention stores a computer program, and when the program is executed by a processor, the dynamic configuration method provided by the embodiment of the present invention is implemented.
[0044] One embodiment of the above invention has the following advantages or beneficial effects: In the embodiment of the present invention, the configuration file includes at least one target configuration item, and the target configuration item includes a configuration item expression of a target configuration parameter and a configuration value expression corresponding to the target configuration parameter. Therefore, for the target configuration item, the embodiment of the present invention can determine whether the user performs configuration of this target configuration item according to the configuration item expression, and after determining that this target configuration item is used for configuration, determine the configuration value corresponding to the target configuration parameter through the configuration value expression, thereby realizing dynamic configuration of each target configuration item in the configuration file. In this way, the configuration file in the embodiment of the present invention can realize dynamic configuration of the target configuration item, meet the dynamic configuration requirements of whether the configuration item in the same system or program is configured, or the configuration value according to specific conditions, and solve the problem that the configuration items and corresponding values in the configuration file are static, so the configuration items in the configuration file cannot be changed, resulting in the configuration failing to meet the dynamic configuration requirements.
[0045] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0047] Figure 1 is a schematic diagram of a main process of a dynamic configuration method according to an embodiment of the present invention;
[0048] Figure 2 is a schematic diagram of a structure of a target configuration item according to an embodiment of the present invention;
[0049] Figure 3is a schematic diagram of another main process of the dynamic configuration method according to an embodiment of the present invention;
[0050] Figure 4 is a schematic diagram of main units of a dynamically configured apparatus according to an embodiment of the present invention;
[0051] Figure 5 is another exemplary system architecture diagram to which the embodiments of the present invention can be applied;
[0052] Figure 6 It is a schematic diagram of the structure of a computer system suitable for implementing the embodiment of the present invention. DETAILED DESCRIPTION
[0053] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention 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 invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0054] It should be pointed out that the embodiments of the present invention and the features in the embodiments may be combined with each other if there is no conflict.
[0055] When a program or system is started or running, it can read and execute each configuration item in the configuration file to configure the value corresponding to the name of the configuration item, so that the corresponding configuration state is displayed during the program or system running stage. By configuring the program or system through the configuration file, the program or system operation can be separated from the configuration process. When running the program or system in different scenarios, only the configuration items in the configuration file can be modified without re-adjusting the program or system code for compilation, thereby saving program or system development time and improving development efficiency. The configuration file can include multiple configuration items, each of which can include the name and corresponding value of the configuration item, and the values in the configuration items are static and will not change with changes in the program or system operating environment to be configured.
[0056] However, the values of configuration items in existing configuration files are static, which are determined when the program or system is started, and will not be adjusted with the state of the program or system during operation. It is not possible to dynamically start / close certain configuration items according to the current service environment, and it is not possible to dynamically adjust the values of configuration items according to the current service environment, which will cause the state of program or system operation to be relatively simple and inflexible. For example, a configuration item is usually "a:b" or "a=b", which means that the name of the configuration item is a and the value is b, that is, the values in the configuration items are fixed and unchanged.
[0057] In some scenarios, it is sometimes necessary to determine whether to execute the configuration item based on the actual situation of the system or program, and the value of the configuration item needs to be automatically adjusted as the system or program runs. That is, in actual production scenarios, some systems or programs need to rely on configuration files that can dynamically adjust configuration values to execute configuration. For example, in e-commerce systems, it is a common operation to increase the exposure of high-quality items by adjusting the position of the items, and the position of the items can be adjusted based on the values of its different features or the results of each feature operation. Therefore, when adjusting the position of the items, it is necessary to dynamically calculate the real-time data of the features included in the configuration items. Therefore, when configuring, some configuration items in the configuration file need to be calculated based on the actual feature values, and then decide whether to execute based on the calculation results; some configurations need to be executed but the configuration values need to be determined based on specific feature data.
[0058] Therefore, an embodiment of the present invention provides a dynamic configuration method for dynamically configuring configuration items in a configuration file of a system or program. In the embodiment of the present invention, the system dynamic configuration is used for explanation.
[0059] The embodiment of the present invention provides a method for dynamic configuration, which can be executed by a terminal device, such as Figure 1 As shown, the method includes the following steps.
[0060] S101: Acquire a configuration file including at least one target configuration item.
[0061] Among them, the target configuration item includes a configuration item expression of the target configuration parameter and a configuration value expression of the target configuration parameter. The target configuration item is the configuration item for parameter configuration included in the configuration file. Each target configuration item corresponds to a target configuration parameter. The target configuration parameter represents the parameter corresponding to the configuration value determined by the target configuration item, that is, the configuration value determined by the target configuration item is assigned to the target configuration parameter. The target configuration item may include a configuration item expression and a configuration value expression. The configuration item expression is used to determine the scope of use of the target configuration item, that is, whether the target configuration item is used to execute the configuration in this system operation, and the configuration value expression is used to determine the value of the target configuration parameter for this operation. In the computer field, the configuration process is usually performed during system initialization or operation. The process of executing the configuration is usually to first obtain the configuration file, and then execute each configuration item in the configuration file in sequence to complete the configuration.
[0062] In an embodiment of the present invention, a configuration file may include at least one target configuration item. A target configuration item in the configuration file is represented by a key-value pair, wherein the key is used to represent the configuration item expression, and the value is used to represent the configuration value expression. The configuration item expression and the configuration value expression included in the target configuration item may include one or more combinations of variables, constants, operation logic composed of operators (including arithmetic operators, logical operators, bitwise operators, etc.), etc.
[0063] Specifically, the structure of the target configuration item can be as follows Figure 2 As shown. Both key and Value support expression parsing. Figure 2 In the example, the expression in key is a configuration item expression, and the expression in value is a configuration value expression. In the embodiment of the present invention, since the expression in key is used to determine whether the target configuration item of this operation is used to execute the configuration, the return result after the expression in key is calculated can be set to true or false. When the configuration item expression is true, the return result is true, indicating that the target configuration item can execute the configuration and the configuration item is effective; when the configuration item expression is false, the return result is false, indicating that the target configuration item does not need to be executed and the configuration item is not effective, so the expression of Key returns a Boolean result. For example, the expression of key can be "x||y", "true", "x+y<1", "(a&&b)||(4+x>100)", etc., where x, y, a, and b can all be Boolean variables, and the values of these variables can be obtained during the execution of the configuration file, and then the return result, such as true or false, is determined according to the value of the variable, which is a Boolean result. In the embodiment of the present invention, the expression in Value is the expression of the configuration value, that is, the configuration value corresponding to the target configuration parameter can be determined by calculating the expression in Value. Configuration values are usually numerical values, so the result returned by the Value expression can be set as a floating-point type in the embodiment of the present invention. During the configuration process, a numerical value is obtained by parsing and calculating the Value expression, and the numerical value is loaded into the program running in the system to assign the corresponding target configuration parameters. For example, the expression in value can be: "1+2", "m+n", "m*2+n+1", etc., where m and n are both numerical variables. The value of the variable can be obtained during the execution of the program, and the configuration value can be calculated.
[0064] S102: For each target configuration item, determine whether the target configuration item is used to execute configuration according to the configuration item expression; if so, determine the configuration value corresponding to the target configuration parameter according to the configuration value expression, and configure the target configuration parameter according to the configuration value; if not, ignore the target configuration item.
[0065] Among them, when executing the configuration file, each target configuration item in the configuration file needs to be processed. Since the target configuration item implements dynamic configuration, that is, whether the target configuration item needs to be configured and the configuration value in the target configuration item can be determined according to the specific scenario when the system is running, so in this step, for each target configuration item, you can first judge whether the target configuration item is used for execution configuration according to the expression of the target configuration parameter. The target configuration item is used for execution configuration, which means that the target configuration item needs to be configured during the current system operation. At this time, the configuration value corresponding to the target configuration parameter can be determined according to the configuration value expression, and the determined configuration value is configured to the target configuration parameter; the target configuration item is not used for execution configuration, which means that the target configuration item does not need to be configured during the current system operation, and the target configuration item can be ignored.
[0066] like Figure 2 As shown, in the embodiment of the present invention, the configuration item expression may include variables, constants, operation logic, etc. Specifically, the configuration item expression may include a first target variable and a target value, and judging whether the target configuration item is used to execute the configuration according to the configuration item expression may be specifically performed as follows: obtaining the current value of at least one first target variable; judging whether the target configuration item is used to execute the configuration according to the current value and the target value.
[0067] The first target variable is usually a variable with physical meaning. The target value indicates the condition when the target configuration item is used for configuration. It can be one or more specific values or a value within a range. For example, the configuration item expression can be "a=x||y", where a represents the color of an item, x represents red, and y represents blue. The first target variable is a, and x and y represent the target values.
[0068] When the system is configured, the current value of the first target variable can be obtained, and then the target configuration item is judged whether it is used to execute the configuration according to the current value and the target value, so as to determine whether the target configuration item is used for configuration according to the specific operation scenario of the system, that is, to dynamically determine whether the target configuration item is used for execution, thereby realizing dynamic configuration. Specifically, the judgment process can be performed as follows: if the current value is within the range of the target value, it is determined that the target configuration item is used to execute the configuration; if the current value is not within the range of the target value, it is determined that the target configuration item is not used to execute the configuration.
[0069] The target value can be a specific value or a value range. When the target value is a specific value, the current value in the range of the target value indicates that the current value is a specific value included in the target value. At this time, it can be determined that the target configuration item is used to perform the configuration. The current value is not in the range of the target value, which indicates that the current value is not a specific value included in the target value. At this time, it can be determined that the target configuration item is not used to perform the configuration. For example, the configuration item expression can be "a = x", where a represents the color of an item, x represents red, the first target variable is a, and x represents the target value. At this time, if the current value of a is red, it is determined that the target configuration item is used to perform the configuration. If the current value of a is not red, it is determined that the target configuration item is not used to perform the configuration. When the target value is a value range, the current value in the range of the target value indicates that the current value belongs to the range determined by the target value. At this time, it can be determined that the target configuration item is used to perform the configuration. The current value is not in the range of the target value, which indicates that the current value does not belong to the range determined by the target value. At this time, it can be determined that the target configuration item is not used to perform the configuration. For example, the configuration item expression may be "a=x||y", where a represents the color of an item, x represents red, and y represents blue. The first target variable is a, and x||y represents the target value, and the target value range is x or y. At this time, if the current value of a is red or blue, it is determined that the target configuration item is used to execute the configuration. If the current value of a is neither red nor blue, it is determined that the target configuration item is not used to execute the configuration.
[0070] When the configuration item expression includes multiple first target variables, or includes constants in addition to the first target variable, logical operations are usually performed between the multiple first target variables or the first target variable and the constant, so the configuration item expression may also include the operation logic corresponding to the first target variable. At this time, the process of judging whether the target configuration item is used to execute the configuration according to the current value and the target value can be specifically performed as follows: according to the current value and the operation logic corresponding to the first target variable, the operation result corresponding to the first target variable is calculated; and according to the operation result and the target value, whether the target configuration item is used to execute the configuration.
[0071] That is to say, after obtaining the current value of the first target variable, a logical operation must be performed first to obtain the operation result corresponding to the first target variable, and then the operation result corresponding to the first target variable is compared with the target value judgment target configuration item to determine whether the target configuration item is used to execute the configuration. For example, the configuration item expression can be "e+f<1", where e represents the number of items and f represents the number of comments on an item. The first target variables are e and f, and the operation logic corresponding to the first target variable is +, and a value less than 1 represents the target value. After obtaining the current values of e and f at runtime, an addition operation is performed first, and then compared with the target value to determine whether the target configuration item is used to execute the configuration.
[0072] It should be noted that the process of judging whether the target configuration item is used to execute the configuration according to the operation result and the target value can be performed as follows: if the operation result is within the range of the target value, the target configuration item is determined to be used to execute the configuration; if the operation result is not within the range of the target value, the target configuration item is determined not to be used to execute the configuration. In an embodiment of the present invention, the configuration item expression can also be a constant, and this constant has a fixed meaning. For example, if the configuration item expression return result is set to true and false, the configuration item expression can be true to indicate that the target configuration item is fixedly used to execute the configuration, or the configuration item expression can be false to indicate that the target configuration item is fixedly not used to execute the configuration. At the same time, the target value in the configuration item expression can also include variables. When determining the target value of the configuration item expression, the current value of the variable can be determined first, and then the target value can be determined.
[0073] In an embodiment of the present invention, the configuration value expression may include one or more items such as variables, constants, and operators. Specifically, when the configuration value expression may include only constants, it indicates that the configuration value of the target configuration item is a fixed value, that is, the constant included in the configuration value expression. The configuration value expression may also include only one variable, that is, a second target variable, in which case the current value of the second target variable may be obtained, and the current value of the second target variable obtained is the configuration value corresponding to the target configuration parameter. The configuration value expression may also include the operation logic corresponding to the second target variable, in which case the method for determining the configuration value corresponding to the target configuration parameter may be performed as follows: obtaining the current value of the second target variable; and calculating the configuration value corresponding to the target configuration parameter according to the current value and the operation logic corresponding to the second target variable. That is, when the configuration value expression includes the operation logic corresponding to the second target variable, it indicates that the reverse logical operation is required, so after obtaining the current value of the second target variable, it is necessary to calculate according to the operation logic corresponding to the second target variable, so as to obtain the configuration value corresponding to the target configuration parameter. For example, the configuration item expression can be "m+n-2", where m represents the ranking of the item, and n represents the sales quantity of the item. Then m and n are the second target variables, 2 is a constant, and + and - are the operation logic.
[0074] It should be noted that when the configuration item expression includes operation logic, it can be the operation logic between multiple second target variables, or it can be the operation logic between the second target variable and a constant.
[0075] In an embodiment of the present invention, the configuration file includes at least one target configuration item, and the target configuration item includes a configuration item expression of a target configuration parameter and a configuration value expression corresponding to the target configuration parameter. Therefore, for the target configuration item, the embodiment of the present invention can determine whether the target configuration item is configured by the user according to the configuration item expression, and after determining that the target configuration item is used for configuration, determine the configuration value corresponding to the target configuration parameter through the configuration value expression, thereby realizing dynamic configuration of each target configuration item in the configuration file. In this way, the configuration file in the embodiment of the present invention can realize dynamic configuration of the target configuration item, meet the dynamic configuration requirements of whether the configuration item in the same system or program is configured, or the configuration value according to specific conditions, and solve the problem that the configuration items and corresponding values in the configuration file are static, so the configuration items in the configuration file cannot be changed, resulting in the configuration failing to meet the dynamic configuration requirements.
[0076] It should be noted that the embodiments of the present invention can be used in various scenarios that require configuration.
[0077] Specifically, it can be used in the configuration of system initialization, and whether each target configuration item is used for configuration can be determined according to the system's own situation, as well as the specific configuration value. For example, when the system is initialized, the number of threads can be configured based on the number of CPUs included in the system operation device. At this time, the number of threads can be configured to 3 when the number of CPUs included in the system operation device is 2. The target configuration parameter is the number of threads, and the configuration item expression of the target configuration parameter corresponding to the target configuration item includes a first target variable and a target value, wherein the first target variable is the number of CPUs included in the system operation device, and the target value is 2. The configuration value expression of the target configuration parameter corresponding to the target configuration item is a constant 3. That is to say, for this target configuration item, when the system is initialized and configured, the number of CPUs included in the system operation device will be obtained first. If the number of CPUs included in the system operation device is 2, the configuration will be executed, that is, 3 will be assigned to the target configuration parameter (number of threads); if the number of CPUs included in the system operation device is not 2, the target configuration item will be ignored.
[0078] Specifically, it can be used to configure some parameters during the operation of the system. For example, in the field of e-commerce, the ranking position of items with good sales can be adjusted according to real-time data. For example, if the sales volume reaches 100, the ranking position of the items will be adjusted. The number of digits to be adjusted can be adjusted according to the characteristic data of the items, that is, the ranking position of the items is configured. At this time, the target configuration parameter is the number of digits to be added to the ranking position. The configuration item expression in the target configuration item corresponding to the target configuration parameter can be w>100, that is, the first target variable w is the sales volume of the item, and the target value is 100. The configuration value expression can be a specific value or an expression calculated based on the characteristics of the item.
[0079] Combine the following Figure 1 The embodiment shown in the figure specifically describes the method of dynamic configuration. Figure 3 As shown, the method includes the following steps.
[0080] S301: Acquire a configuration file including at least one target configuration item.
[0081] Among them, the embodiment of the present invention can be used for system initialization configuration and can also be used in the system operation process. The configuration file usually includes multiple target configuration items, and each target configuration item corresponds to a target configuration parameter that is preset. The target configuration item may include a configuration item expression and a configuration value expression. Both the configuration item expression and the configuration value expression may include constants, variables, operators, etc. The target configuration items in the configuration file are usually arranged in a certain order, or the target configuration items are arranged in this step, and the sorting rules are not limited.
[0082] S302: Determine the first target configuration item in the configuration file as the current configuration item.
[0083] After obtaining the configuration file, each target configuration item in the configuration file can be processed in turn. The current configuration item is the target configuration item currently being processed. In this step, the first target configuration item in the configuration file is determined as the current configuration item, indicating that the first target configuration item in the configuration file is processed.
[0084] S303: Parse the configuration item expression of the current configuration item and determine the current result of the configuration item expression.
[0085] Among them, since the configuration item expression in each target configuration item is used to determine whether the target configuration item is used to execute the configuration, the configuration item expression of the current configuration item is parsed in this step. After parsing, the variables, constants and operators included in the configuration item expression can be determined, that is, the specific content of the configuration item expression, and then the current result of the configuration item expression is determined. If the configuration item expression includes a variable, that is, the first target variable, it is necessary to obtain the current value of the variable, and then determine the current result of the configuration item expression in combination with the current value of the variable.
[0086] In the embodiment of the present invention, the return result of the configuration item expression is set to true or false. When the variables, constants, and operators included in the configuration item expression are determined, and the current values of the variables are obtained, the configuration item expression is calculated to be true, and the return result is true, that is, the current result is true; when the variables, constants, and operators included in the configuration item expression are determined, and the current values of the variables are obtained, and the configuration item expression is calculated to be false, the return result is true, that is, the current result is false.
[0087] S304: Determine whether the current configuration item is used to execute the configuration according to the current result of the configuration item expression. If so, execute step S305; if not, execute step 307.
[0088] In the embodiment of the present invention, the return result of the configuration item expression is set to true or false, so the current result of the configuration item expression is true or false. If the current result is true, it means that the current configuration item is used to execute the configuration, and step S305 can be executed; if the current result is false, it means that the current configuration item is not used to execute the configuration, and the current configuration item can be ignored, and then step S307 is executed to process the target configuration items in the configuration file in sequence.
[0089] S305: Parse the configuration value expression of the current configuration item, and determine the configuration value corresponding to the target configuration parameter.
[0090] Among them, in this step, the configuration value expression of the current configuration item is parsed, and after parsing, the variables, constants and operators included in the configuration value expression, that is, the specific content of the configuration item expression, can be determined, and then the calculation result of the configuration item expression can be determined, that is, the configuration value corresponding to the target configuration parameter. If the configuration value expression includes a variable, that is, the second target variable, it is necessary to obtain the current value of the variable, and then determine the result of the configuration value expression in combination with the current value of the variable.
[0091] S306: assigning the configuration value to the target configuration parameter corresponding to the current configuration item.
[0092] After determining the configuration value corresponding to the target configuration parameter, the configuration value can be assigned to the target configuration parameter to achieve normal operation of the target configuration parameter in the system after the assignment.
[0093] S307: Determine whether the current configuration item is the last target configuration item in the configuration file. If so, end the process; if not, execute step S308.
[0094] After the current configuration item is processed, it is determined whether the current configuration item is the last target configuration item in the configuration file in order to determine whether the target configuration items in the configuration file have been processed. If the current configuration item is the last target configuration item in the configuration file, it means that the target configuration item in the configuration file has been processed, and the process can be terminated; if the current configuration item is not the last target configuration item in the configuration file, it means that the target configuration item arranged after the current configuration item has not been processed, and step 308 needs to be executed to complete the processing of the target configuration item in the configuration file.
[0095] S308: Update the next target configuration item of the current configuration item to the target configuration item.
[0096] After determining that there are unprocessed target configuration items in the configuration file, the next target configuration item of the current configuration item is updated as the target configuration item, and then step 303 is executed.
[0097] In an embodiment of the present invention, the configuration file includes at least one target configuration item, and the target configuration item includes a configuration item expression of a target configuration parameter and a configuration value expression corresponding to the target configuration parameter. Therefore, for the target configuration item, the embodiment of the present invention can determine whether the target configuration item is configured by the user according to the configuration item expression, and after determining that the target configuration item is used for configuration, determine the configuration value corresponding to the target configuration parameter through the configuration value expression, thereby realizing dynamic configuration of each target configuration item in the configuration file. In this way, the configuration file in the embodiment of the present invention can realize dynamic configuration of the target configuration item, meet the dynamic configuration requirements of whether the configuration item in the same system or program is configured, or the configuration value according to specific conditions, and solve the problem that the configuration items and corresponding values in the configuration file are static, so the configuration items in the configuration file cannot be changed, resulting in the configuration failing to meet the dynamic configuration requirements.
[0098] In order to solve the problems existing in the prior art, an embodiment of the present invention provides a dynamically configured device 400, such as Figure 4 As shown, the device 400 includes:
[0099] An acquisition unit 401 is configured to acquire a configuration file including at least one target configuration item, wherein the target configuration item includes a configuration item expression of a target configuration parameter and a configuration value expression of the target configuration parameter;
[0100] The configuration unit 402 is used to determine, for each of the target configuration items, whether the target configuration item is used to execute configuration according to the configuration item expression; if so, determine the configuration value corresponding to the target configuration parameter according to the configuration value expression, and configure the target configuration parameter according to the configuration value; if not, ignore the target configuration item.
[0101] It should be understood that the manner of implementing the embodiments of the present invention is different from the Figure 1 The method of the illustrated embodiment is the same and will not be repeated here.
[0102] In an implementation of the embodiment of the present invention, the configuration item expression includes at least one first target variable and a target value;
[0103] The configuration unit 402 is specifically used for:
[0104] Obtaining a current value of the at least one first target variable;
[0105] It is determined whether the target configuration item is used for executing configuration according to the current value and the target value.
[0106] In another implementation of the embodiment of the present invention, the configuration item expression further includes an operation logic corresponding to the first target variable;
[0107] The configuration unit 401 is specifically used for:
[0108] Calculate the operation result corresponding to the first target variable according to the operation logic corresponding to the current value and the first target variable;
[0109] It is determined whether the target configuration item is used for executing configuration according to the calculation result and the target value.
[0110] In another implementation of the embodiment of the present invention, the configuration unit 402 is specifically configured to:
[0111] If the current value is within the range of the target value, determining the target configuration item for executing the configuration;
[0112] If the current value is not within the range of the target value, it is determined that the target configuration item is not used for performing configuration.
[0113] In another implementation of the embodiment of the present invention, the configuration value expression includes a second target variable and an operation logic corresponding to the second target variable;
[0114] The configuration unit 402 is specifically used for:
[0115] Obtaining the current value of the second target variable;
[0116] The configuration value corresponding to the target configuration parameter is calculated according to the operation logic corresponding to the current value and the second target variable.
[0117] It should be understood that the manner of implementing the embodiments of the present invention is different from the Figure 1 or Figure 3 The method of the illustrated embodiment is the same and will not be described again here.
[0118] In an embodiment of the present invention, the configuration file includes at least one target configuration item, and the target configuration item includes a configuration item expression of a target configuration parameter and a configuration value expression corresponding to the target configuration parameter. Therefore, for the target configuration item, the embodiment of the present invention can determine whether the target configuration item is configured by the user according to the configuration item expression, and after determining that the target configuration item is used for configuration, determine the configuration value corresponding to the target configuration parameter through the configuration value expression, thereby realizing dynamic configuration of each target configuration item in the configuration file. In this way, the configuration file in the embodiment of the present invention can realize dynamic configuration of the target configuration item, meet the dynamic configuration requirements of whether the configuration item in the same system or program is configured, or the configuration value according to specific conditions, and solve the problem that the configuration items and corresponding values in the configuration file are static, so the configuration items in the configuration file cannot be changed, resulting in the configuration failing to meet the dynamic configuration requirements.
[0119] According to an embodiment of the present invention, the present invention also provides an electronic device and a readable storage medium.
[0120] The electronic device of the present invention comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the one processor, and the instructions are executed by the at least one processor so that the at least one processor executes the dynamic configuration method provided by an embodiment of the present invention.
[0121] Figure 5 An exemplary system architecture 500 is shown to which the method for dynamic configuration or the apparatus for dynamic configuration according to an embodiment of the present invention can be applied.
[0122] like Figure 5 As shown, system architecture 500 may include terminal devices 501, 502, 503, a network 504 and a server 505. Network 504 is used to provide a medium for communication links between terminal devices 501, 502, 503 and server 505. Network 504 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0123] Users can use terminal devices 501, 502, 503 to interact with server 505 through network 504 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 501, 502, 503, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples).
[0124] The terminal devices 501 , 502 , and 503 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.
[0125] The server 505 may be a server that provides various services, such as a backend management server (only an example) that provides support for shopping websites browsed by users using the terminal devices 501, 502, and 503. The backend management server may analyze and process the received data such as product information query requests, and feed back the processing results (such as product information - only an example) to the terminal device.
[0126] It should be noted that the dynamic configuration method provided in the embodiment of the present invention is generally executed by the server 505 , and accordingly, the dynamic configuration device is generally set in the server 505 .
[0127] It should be understood that Figure 5 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to the implementation requirements.
[0128] Reference below Figure 6 , which shows a schematic diagram of the structure of a computer system 800 suitable for implementing an embodiment of the present invention. Figure 6 The computer system shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0129] like Figure 6 As shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage part 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the system 600 are also stored. The CPU 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.
[0130] The following components are connected to the I / O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage section 608 as needed.
[0131] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609, and / or installed from the removable medium 611. When the computer program is executed by the central processing unit (CPU) 601, the above-mentioned functions defined in the system of the present invention are executed.
[0132] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, 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 above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0133] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a unit, a program segment, or a part of a code, and the above-mentioned unit, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0134] The units involved in the embodiments of the present invention may be implemented by software or hardware. The units described may also be set in a processor, for example, it may be described as: a processor includes an acquisition unit and a configuration unit. The names of these units do not constitute a limitation on the units themselves in some cases, for example, the acquisition unit may also be described as a "unit of the function of the acquisition unit".
[0135] As another aspect, the present invention further provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device executes the dynamic configuration method provided by the present invention.
[0136] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for dynamic configuration, characterized in that: include: Acquire a configuration file including at least one target configuration item, wherein the target configuration item includes a configuration item expression of a target configuration parameter and a configuration value expression of the target configuration parameter, wherein the configuration item expression is used to determine a usage scope of the target configuration item; For each of the target configuration items, judging whether the target configuration item is used for executing configuration according to the configuration item expression; If yes, determine the configuration value corresponding to the target configuration parameter according to the configuration value expression, and configure the target configuration parameter according to the configuration value; if no, ignore the target configuration item; The configuration item expression includes at least one first target variable and a target value, and the configuration item expression also includes an operation logic corresponding to the first target variable and consisting of variables, constants, and operators; The determining, according to the configuration item expression, whether the target configuration item is used for executing configuration includes: Obtaining a current value of the at least one first target variable; Calculate the operation result corresponding to the first target variable according to the operation logic corresponding to the current value and the first target variable; It is determined whether the target configuration item is used for executing configuration according to the calculation result and the target value.
2. The method according to claim 1, characterized in that The determining, according to the current value and the target value, whether the target configuration item is used for executing the configuration includes: If the current value is within the range of the target value, determining the target configuration item for executing the configuration; If the current value is not within the range of the target value, it is determined that the target configuration item is not used for performing configuration.
3. The method according to claim 1, characterized in that The configuration value expression includes a second target variable and an operation logic corresponding to the second target variable; The determining the configuration value corresponding to the target configuration parameter according to the configuration value expression includes: Obtaining the current value of the second target variable; The configuration value corresponding to the target configuration parameter is calculated according to the operation logic corresponding to the current value and the second target variable.
4. A dynamically configured device, characterized in that: include: An acquisition unit, configured to acquire a configuration file including at least one target configuration item, wherein the target configuration item includes a configuration item expression of a target configuration parameter and a configuration value expression of the target configuration parameter, wherein the configuration item expression is used to determine a usage scope of the target configuration item; A configuration unit, configured to determine, for each of the target configuration items, whether the target configuration item is used for execution configuration according to the configuration item expression; If yes, determine the configuration value corresponding to the target configuration parameter according to the configuration value expression, and configure the target configuration parameter according to the configuration value; if no, ignore the target configuration item; The configuration item expression includes at least one first target variable and a target value, and the configuration item expression also includes an operation logic corresponding to the first target variable and consisting of variables, constants, and operators; The configuration unit is specifically used for: Obtaining a current value of the at least one first target variable; Calculate the operation result corresponding to the first target variable according to the operation logic corresponding to the current value and the first target variable; It is determined whether the target configuration item is used for executing configuration according to the calculation result and the target value.
5. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 3.
6. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 3 is implemented.
Citation Information
Patent Citations
A configuration file generation method and device for an application program
CN109032620A
Application configuring methods and devices, storage mediums and electronic equipment
CN109547259A