A method, system and server for variable configuration

By using a delayed assignment method in the proxy server to generate and parse the configuration information of custom variables, the problem of not being able to obtain accurate data values ​​for custom variables in the existing technology is solved, thus realizing the personalized needs of customers.

CN114816501BActive Publication Date: 2026-03-31CHINANETCENT TECH
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-01-18
Publication Date
2026-03-31

AI Technical Summary

Technical Problem

Existing proxy servers cannot obtain accurate data values ​​when creating and assigning custom variables during the rewriting phase, thus failing to meet customers' personalized needs.

Method used

By adopting a delayed assignment method, configuration information for custom variables is generated by receiving user data customization requirements. Custom variables are created when parsing the configuration information, and assigned values ​​through variable functions when used, ensuring that custom variables obtain accurate data values.

Benefits of technology

This allows custom variables to obtain accurate data values ​​during use, thereby meeting customers' personalized needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114816501B_ABST
    Figure CN114816501B_ABST
Patent Text Reader

Abstract

The application discloses a variable configuration method, system and server, wherein the method comprises the following steps: receiving a data customization requirement of a user, and generating configuration information of a self-defined variable according to the data customization requirement, wherein the configuration information at least comprises a function name of a variable function used for realizing the data customization requirement; analyzing the configuration information, so as to create the self-defined variable, and when the self-defined variable is used, a variable calculation function in the variable function is called, so as to assign a value to the self-defined variable through the variable calculation function. The technical scheme provided in the application can accurately obtain a data value, thereby meeting the individualized requirement of a customer.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of Internet technology, and in particular to a method, system, and server for variable configuration. Background Technology

[0002] In a CDN (Content Delivery Network), proxy servers can provide acceleration services for domain names.

[0003] When providing domain name acceleration services to clients, we may receive customized data retrieval requests. For example, clients might want to know the duration of the first data packet in each request. Different variables may be needed in the proxy server to handle different customized data retrieval requests. Therefore, the existing variables are far from sufficient for client needs, and in practical applications, it is necessary to be able to flexibly configure custom variables.

[0004] In existing proxy servers, custom variables are typically created and assigned values ​​during the rewriting phase. However, the actual data values ​​of a request are usually generated during the response phase (which is later than the rewriting phase). This means that custom variables created and assigned values ​​during the rewriting phase often cannot obtain accurate data values, thus preventing clients from meeting their personalized needs. Summary of the Invention

[0005] The purpose of this application is to provide a method, system, and server for variable configuration that can accurately obtain data values ​​to meet customers' personalized needs.

[0006] To achieve the above objectives, this application provides a variable configuration method, the method comprising: receiving a user's data customization requirements, and generating configuration information for a custom variable based on the data customization requirements, wherein the configuration information includes at least the function name of a variable function used to implement the data customization requirements; parsing the configuration information to create the custom variable, and when the custom variable is used, calling a variable calculation function in the variable function to assign a value to the custom variable through the variable calculation function.

[0007] To achieve the above objectives, this application also provides a variable configuration system, the system comprising: a configuration information generation unit, configured to receive a user's data customization requirements and generate configuration information for a custom variable based on the data customization requirements, wherein the configuration information includes at least the function name of a variable function used to implement the data customization requirements; and a parsing unit, configured to parse the configuration information to create the custom variable, and, when the custom variable is used, to call a variable calculation function in the variable function to assign a value to the custom variable through the variable calculation function.

[0008] To achieve the above objectives, this application also provides a server, which includes a memory and a processor. The memory is used to store a computer program, which, when executed by the processor, implements the variable configuration method described above.

[0009] As can be seen from the above, the technical solutions provided by one or more embodiments of this application can use a delayed assignment method to allow custom variables to obtain accurate data values. Specifically, when a user's data customization request is received, a variable function can be constructed to implement the data customization request, and then configuration information of the custom variable containing the function name of the variable function can be generated. When parsing the configuration information, the corresponding custom variable can be created. However, when parsing the configuration information, it is not necessary to assign a value to the custom variable. Instead, when using the custom variable, the variable calculation function in the aforementioned variable function can be called to assign a value to the custom variable. In this way, the custom variable can obtain an accurate data value, thereby fulfilling the user's data customization request. Attached Figure Description

[0010] To more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0011] Figure 1 This is a schematic diagram of the method steps for variable configuration in an embodiment of the present invention;

[0012] Figure 2 This is a flowchart of parsing configuration information in an embodiment of the present invention;

[0013] Figure 3 This is a schematic diagram of the functional modules of the variable configuration system in an embodiment of the present invention;

[0014] Figure 4 This is a schematic diagram of the server structure in an embodiment of the present invention. Detailed Implementation

[0015] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0016] This application provides a variable configuration method that can be applied to a CDN proxy server. This proxy server typically deploys business systems that implement services, and these business systems can be implemented based on a specific architecture. For example, in current CDNs, the Nginx architecture is widely used in proxy servers due to its high performance and stability. This application uses the Nginx architecture as an example to illustrate this variable configuration method.

[0017] Specifically, please refer to Figure 1 This method may include the following steps.

[0018] S1: Receive the user's data customization request, and generate configuration information for custom variables based on the data customization request. The configuration information includes at least the function name of the variable function used to implement the data customization request.

[0019] When providing domain acceleration services to users, different users may have different customized needs for the same data. Therefore, it is usually necessary to create corresponding variable functions based on users' data customization requirements. For example, different users may want to obtain the creation time of the acceleration request, but the required format may differ. Some users prefer to use a format like "year / month / day," while others prefer a format like "year-month-day." Thus, a variable function can be created for time formatting, which supports outputting the creation time in the specified format.

[0020] In this implementation, a new configuration item can be added to the nginx framework to enable deferred assignment of variables. This configuration item allows the creation of custom variables, and the specification of corresponding variable functions and parameters for these variables. For example, the new configuration item could be `func_var`, and the pseudocode for creating a custom variable using this item is shown below:

[0021] func_var$my_new_var copy "hello world"

[0022] Here, my_new_var can be the name of a user-defined variable, copy can be the corresponding variable function, and hello world are the variable parameters.

[0023] In this implementation, upon receiving a user's data customization request, a corresponding variable function can be created based on that request. This variable function is then used to process the data, and the custom variable is copied, thus fulfilling the user's data customization needs. Therefore, the nginx framework needs to provide a registration interface for registering variable functions. Whenever a variable function is developed, this registration interface can be called to register the developed variable function in nginx, allowing subsequent direct calls to the registered variable function.

[0024] In one implementation, when registering a variable function, it typically needs to pass several specified pieces of information to the registration interface. Specifically, the information passed may include the function name, the parameter parsing function, and the variable evaluation function. The function name is a global attribute and cannot be the same as an already registered function name. The parameter parsing function is a callback function used to parse the variable parameters. For example, in the above example, the variable parameter "hello world" will be passed to the parameter parsing function for parsing. The variable evaluation function is used to assign values ​​to the custom variable; in this application, this function is called only when the custom variable is used.

[0025] For example, the pseudocode for registering a variable function can be shown below:

[0026] func_var_register(func_var_name,func_var_parse,func_var_get_hand ler)

[0027] Among them, func_var_name, func_var_parse, and func_var_get_handler correspond to the function name, parameter parsing function, and variable calculation function of the variable function mentioned above, respectively.

[0028] In practical applications, the pseudocode for the func_var_parse function format is as follows:

[0029] func_var_parse(ngx_conf,args)

[0030] The parameter `ngx_conf` is the Nginx configuration parsing object, which contains a memory pool that the parameter parsing function can allocate memory for. `args` represents variable arguments, which can be one or more. The return value of the parameter parsing function can be used by the variable evaluation function.

[0031] The pseudocode for the func_var_get_handler function is as follows:

[0032] func_var_get_handler(request,out,data)

[0033] The parameter request is the HTTP request, out is the output value of the variable, and data is the return value of func_var_parse.

[0034] In this implementation, to quickly locate the corresponding variable function by its name, a hash table can be used to store all registered variable functions. After registering the variable function in the nginx framework as described above, configuration information for the custom variable can be generated. This configuration information can include several components. Specifically, it can include the variable name of the custom variable, the function name of the variable function used to implement the user's data customization needs, and the variable parameters to be processed. For example, the pseudocode for this configuration information can be as follows:

[0035] func_var$my_var func_var_name func_var_args

[0036] Where my_var is the name of the user-defined variable, func_var_name is the name of the variable function, and func_var_args are the variable parameters, which can be one or more.

[0037] For example, suppose a user's data customization requirement is to output the requested time in the format of "year-month-day". The corresponding variable function could be named `date_format`, and the configuration information generated based on this variable function could be as follows:

[0038] func_var$v2 date_format"%Y-%m-%d"$timestamp

[0039] Where v2 is the name of the user-defined variable, date_format is the name of the variable function, "%Y-%m-%d" is the variable parameter, and $timestamp is the current time.

[0040] S3: Parse the configuration information to create the custom variable, and when the custom variable is used, the variable calculation function in the variable function is called to assign a value to the custom variable through the variable calculation function.

[0041] In this embodiment, after the configuration information is generated, it can be parsed, thereby completing the creation and initialization of custom variables during the parsing process. Please refer to [link / reference]. Figure 2 The process of parsing configuration information can be described as follows:

[0042] 1. The nginx framework searches the hash table using the variable function name `func_var_name`. If the variable function is not registered, no corresponding result will be found in the hash table, resulting in a resolution failure, and the process can be exited with an error. If the variable function has been registered, its information (variable function name, parameter resolution function, variable calculation function) can be retrieved from the hash table, and subsequent steps can be executed.

[0043] 2. After retrieving the information for the registered variable function from the hash table, the variable parameter `func_var_args` can be passed to the parameter parsing function `func_var_parse` for parsing. If the parameter parsing function call fails, it can exit with an error. If the call succeeds, the returned parameters obtained by the parameter parsing function can be recorded, and subsequent steps can continue.

[0044] 3. Call the ngx_http_add_variable interface in the nginx framework to add variables. This interface can create the variable my_var. If creation fails, you can exit with an error message. If creation is successful, this custom variable can have the following data structures:

[0045] get_handler: The processing function. In this application, the variable calculation function in the variable function can be directly set as the processing function in the custom variable. Therefore, the processing function is consistent with the variable calculation function in the variable function.

[0046] data: Custom data for custom variables.

[0047] In this application, the return parameters obtained from the parameter parsing function can be written into this custom data.

[0048] At this point, the configuration information parsing process is complete. As can be seen above, parsing configuration information involves the following steps:

[0049] 1) Based on the function name parsed from the configuration information, check if there is a registered variable function corresponding to the function name. If not, issue an error message; if it exists, obtain the parameter parsing function and variable calculation function of the variable function.

[0050] 2) Process the variable parameters parsed from the configuration information using the obtained parameter parsing function to generate return parameters;

[0051] 3) Call the nginx new variable interface to create the custom variable, wherein the data structure of the created custom variable includes a processing function and custom data;

[0052] 4) Set the processing function of the custom variable as the variable calculation function of the variable function, and write the return parameter into the custom data.

[0053] After the configuration information is parsed, the initialization process of the custom variable is complete. Subsequently, the custom variable can be used normally by various related functions. When using the custom variable, the nginx framework calls the `get_handler` function within the custom variable to process the return parameters in the custom data, obtain the corresponding return value, and assign the returned value to the custom variable. This ensures that the custom variable is assigned a value when used, thus guaranteeing an accurate return value.

[0054] It should be noted that variables in nginx use variable names as unique identifiers, and different acceleration requests are isolated from each other. Therefore, custom variables created in the nginx framework inherit this characteristic. That is, for the same server, the same variable name represents the same variable. And because different servers are isolated from each other, even if the same variable name appears on different servers, it can represent different independent custom variables.

[0055] In a specific application scenario, if a user's data customization requirement is to output the request time in a specified format, then the following configuration information can be generated (assuming that the variable functions have already been registered):

[0056] func_var$v2 date_format"%Y-%m-%d"$timestamp

[0057] Here, v2 is the name of the custom variable, date_format is the name of the variable function, which is used to implement the time formatting function, "%Y-%m-%d" is the variable parameter, which should be one or two. Under this configuration information, there is one variable parameter, which means that the requested time is output in the format of "year-month-day", and $timestamp is the current time.

[0058] In this application scenario, when parsing configuration information, the parameter parsing function can identify the number of variable parameters. If the number of variable parameters meets a preset limit, a string array of a specified length can be created in the memory pool. Specifically, if the number of variable parameters is not one or two, a parsing failure message can be returned. If the number of variable parameters meets the preset limit of one or two, a string array of length 2 can be created using the ngx_conf memory pool. Then, the string array can be initialized according to the variable parameters, and the initialized string array can be returned as a parameter.

[0059] Specifically, when initializing the string array, the first variable parameter can be copied to the first string of the string array, and then it can be determined whether a second variable parameter exists. If a second variable parameter exists, it can be copied to the second string of the string array; otherwise, if a second variable parameter does not exist, the second string of the string array can be initialized according to the variable value in the configuration information.

[0060] For the configuration information in this scenario, the first string of the array can copy the value of the first variable parameter, i.e., "%Y-%m-%d" in the example. The value of the second string of the array can be initialized to "$timestamp", i.e., the current time. Then, the initialized array can be returned, and this initialized array can be used as the return parameter.

[0061] In this application scenario, after parsing the configuration information, the `get_handler` function within the custom variable is invoked when the custom variable is used. Since the `get_handler` function is set as the variable calculation function within the variable function, it's equivalent to the variable calculation function within the variable function being called. At this point, it can be determined whether the second string in the returned parameters begins with a specified character; if so, the variable value retrieval interface can be called to obtain the variable value corresponding to the second string, and the obtained variable value can be used as the time parameter to be formatted; otherwise, the current variable value of the second string in the returned parameters can be used as the time parameter to be formatted.

[0062] Specifically, we can check if the second parameter of the array starts with a '$'. A '$' indicates an nginx variable, and its value, denoted as 'time', can be retrieved by calling the ngx_http_get_variable interface in nginx. Then, 'time' can be converted to an integer timestamp. In C, the atoi interface can be used directly for integer timestamp conversion. Based on the format of the first string in the array, the locatime and strftime interfaces in C can be used to format the integer timestamp, generating a timestamp in "year-month-day" format, which is then assigned to a custom variable. This ensures that the custom variable is assigned a value only when it is used, guaranteeing it receives an accurate data value.

[0063] Please see Figure 3 This application also provides a variable configuration system, the system comprising:

[0064] A configuration information generation unit is used to receive a user's data customization requirements and generate configuration information for custom variables based on the data customization requirements. The configuration information includes at least the function name of the variable function used to implement the data customization requirements.

[0065] The parsing unit is used to parse the configuration information to create the custom variable, and when the custom variable is used, the variable calculation function in the variable function is called to assign a value to the custom variable through the variable calculation function.

[0066] Please see Figure 4 This application also provides a server, which includes a memory and a processor. The memory is used to store a computer program, which, when executed by the processor, implements the variable configuration method described above.

[0067] As can be seen from the above, the technical solutions provided by one or more embodiments of this application can use a delayed assignment method to allow custom variables to obtain accurate data values. Specifically, when a user's data customization request is received, a variable function can be constructed to implement the data customization request, and then configuration information of the custom variable containing the function name of the variable function can be generated. When parsing the configuration information, the corresponding custom variable can be created. However, when parsing the configuration information, it is not necessary to assign a value to the custom variable. Instead, when using the custom variable, the variable calculation function in the aforementioned variable function can be called to assign a value to the custom variable. In this way, the custom variable can obtain an accurate data value, thereby fulfilling the user's data customization request.

[0068] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to interchangeably. Each embodiment focuses on its differences from other embodiments. In particular, the embodiments for systems and servers can be explained by referring to the descriptions of the aforementioned method embodiments.

[0069] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware implementation, a completely software implementation, or an implementation combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0070] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0071] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0072] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0073] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0074] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0075] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0076] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0077] The above description is merely an embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principle of this application should be included within the scope of the claims of this application.

Claims

1. A variable configuration method, characterized by, The method comprises: receiving a data customization requirement of a user, and generating configuration information of a custom variable according to the data customization requirement, the configuration information at least including a function name of a variable function for implementing the data customization requirement; adding a configuration item capable of delaying assignment of a variable, creating the custom variable through the configuration item, and specifying a corresponding variable function and a variable parameter for the custom variable; parsing the configuration information to create the custom variable, and when the custom variable is used, a variable calculation function in the variable function is called to assign the custom variable through the variable calculation function.

2. The method of claim 1, wherein, The variable function is registered in the following manner: calling a registration interface and inputting a function name of the variable function, a parameter parsing function of the variable function, and a variable calculation function of the variable function into the registration interface; wherein the parameter parsing function is used to parse a variable parameter, and the variable calculation function is called when the custom variable is used.

3. The method of claim 1, wherein, Parsing the configuration information comprises: querying whether there is a registered variable function corresponding to the function name according to the function name parsed from the configuration information, issuing an error prompt if there is not, and obtaining a parameter parsing function and a variable calculation function of the variable function if there is; processing the variable parameter parsed from the configuration information by using the obtained parameter parsing function to generate a return parameter.

4. The method of claim 3, wherein, Creating the custom variable comprises: calling an added variable interface to create the custom variable, wherein the data structure of the created custom variable includes a processing function and custom data; setting the processing function of the custom variable as the variable calculation function of the variable function, and writing the return parameter into the custom data.

5. The method of claim 4, wherein, When the custom variable is used, the processing function of the custom variable is called to process the return parameter in the custom data through the processing function to obtain a return value, and the return value is assigned to the custom variable.

6. The method of claim 3, wherein, Processing the variable parameter parsed from the configuration information by using the obtained parameter parsing function comprises: the parameter parsing function identifies the number of variable parameters, and in the case that the number of variable parameters meets a preset number limit condition, a string array of a specified length is created in a memory pool; the string array is initialized according to the variable parameters, and the initialized string array is taken as a return parameter.

7. The method of claim 6, wherein, Initializing the string array according to the variable parameters comprises: copying a first variable parameter into a first string of the string array; if there is a second variable parameter, copying the second variable parameter into a second string of the string array; if there is no second variable parameter, initializing the second string of the string array according to a variable value in the configuration information.

8. The method of claim 6, wherein, When the variable calculation function in the variable function is invoked, it is determined whether the second string in the return parameter starts with a specified character; if yes, a variable value corresponding to the second string is obtained by invoking a variable value obtaining interface, and the obtained variable value is taken as a time parameter to be formatted; if no, the current variable value of the second string in the return parameter is taken as the time parameter to be formatted.

9. The method of claim 8, wherein, The method further comprises: According to the format of the first string in the return parameter, the time parameter is formatted into a corresponding time stamp, and the time stamp is assigned to the custom variable.

10. A variable configuration system, characterized by The system comprises: A configuration information generation unit is configured to receive a data customization requirement of a user, and generate configuration information of a custom variable according to the data customization requirement, wherein the configuration information at least includes a function name of a variable function used to implement the data customization requirement; a configuration item capable of delaying variable assignment is added, the custom variable is created through the configuration item, and a corresponding variable function and a variable parameter are specified for the custom variable; A parsing unit is configured to parse the configuration information to create the custom variable, and when the custom variable is used, a variable calculation function in the variable function is invoked to assign the custom variable through the variable calculation function.

11. A server, characterized by The server comprises a memory and a processor, the memory is configured to store a computer program, and the computer program is executed by the processor to implement the method in any one of claims 1 to 9.

Citation Information

Patent Citations

  • Method for realizing content delivery by using variables in business intelligence

    CN105511971A