Request processing method and device, electronic equipment, storage medium and program product
By maintaining the processing logic difference code segments between different versions in the service code and using version identification to determine the execution code segment, the code redundancy and maintenance difficulty problems caused by the processing logic differences of multiple versions are solved, and processing requests and resource consumption are reduced compatible with different versions.
Patent Information
- Application Number
- CN202411570568.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-05
- Publication Date
- 2025-03-25
AI Technical Summary
During the development of application software, the processing logic differences between multiple versions lead to code redundancy and maintenance difficulty. The existing technology requires the maintenance of processing links for different versions, and rely on the database to store different versions of processing links, which limits usage scenarios and resource consumption.
By maintaining code segments with logical differences between different versions in the service code, instead of maintaining a processing link separately from different versions, the version identification is used to determine the code segments allowed to be executed in the service code, thereby achieving compatible processing requests for different versions.
Reduces code redundancy, reduces resource consumption, expands usage scenarios, implements processing requests compatible with different versions, and simplifies the maintenance process.
Smart Images

Figure CN119690496A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a request processing method, device, electronic device, storage medium, and program product. Background Art
[0002] At present, in the process of application software development, the software can be gradually improved through multiple cycles. Each cycle is called an iteration. One iteration corresponds to a version of the code. There are differences between different versions of the code. For different requests of multiple versions, there may be processing logic conflicts. In related technologies, it is usually necessary to maintain a processing link for different versions, and different processing links process requests of different versions. In this way, in order to be compatible with different versions, code redundancy will occur, and more resources will be required for maintenance. Summary of the invention
[0003] The present disclosure provides a request processing method, device, electronic device, storage medium and program product.
[0004] In a first aspect, the present disclosure provides a request processing method, the request processing method comprising:
[0005] receiving a processing request for an application, the processing request including a first version identifier of the application;
[0006] Determine a service code corresponding to the processing request, wherein the service code includes a plurality of code segments, and a code segment is composed of codes having processing logic differences between any two versions of the application program;
[0007] Determining, according to the first version identifier, a first code segment in the service code that is allowed to be executed;
[0008] By executing the first code segment, a processing result of the processing request is obtained.
[0009] In a second aspect, the present disclosure provides a request processing device, the request processing device comprising:
[0010] A receiving module, configured to receive a processing request for an application, wherein the processing request includes a first version identifier of the application;
[0011] A first determination module is used to determine a service code corresponding to the processing request, wherein the service code includes a plurality of code segments, and a code segment is composed of codes having processing logic differences between any two versions of the application;
[0012] A second determining module, configured to determine a first code segment in the service code that is allowed to be executed according to the first version identifier;
[0013] The obtaining module is used to obtain the processing result of the processing request by executing the first code segment.
[0014] In a third aspect, the present disclosure provides an electronic device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores one or more computer programs executable by the at least one processor, and one or more of the computer programs are executed by the at least one processor so that the at least one processor can execute the above-mentioned request processing method.
[0015] In a fourth aspect, the present disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the above-mentioned request processing method when executed by a processor / processing core.
[0016] In a fifth aspect, the present disclosure provides a computer program or a computer program product, wherein the computer program product comprises a computer program, the computer program is stored in a computer-readable storage medium, and the computer program implements the above-mentioned request processing method when executed by a processor.
[0017] The request processing method provided by the present invention is based on the code with processing logic differences between any two versions, and is composed of multiple code segments included in the service code. Since the code segments with processing logic differences between different versions are included, compatibility with processing logics corresponding to different versions is achieved, and only the code segments composed of the codes with processing logic differences need to be maintained, without the need to include complete codes of different versions, and redundant code can also be reduced. Therefore, when a processing request for an application is received, the first code segment allowed to be executed in the service code corresponding to the processing request can be determined according to the first version identifier of the application included in the processing request, that is, the processing result of the processing request can be obtained by executing the first code segment. In this way, through the version identifier, the code segment for the version identifier can be determined from the service code, that is, the processing request can be processed without the need to maintain a processing link corresponding to different versions, and there is no need to rely on a database to store processing links of different versions. The usage scenarios are more extensive, and there is no need to add additional processing links, which reduces redundant code and reduces resource consumption.
[0018] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The accompanying drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the embodiments of the present disclosure, they are used to explain the present disclosure and do not constitute a limitation of the present disclosure. The above and other features and advantages will become more apparent to those skilled in the art by describing detailed example embodiments with reference to the accompanying drawings, in which:
[0020] Figure 1 An application scenario architecture diagram provided for an embodiment of the present disclosure;
[0021] Figure 2 A flowchart of a request processing method provided by an embodiment of the present disclosure;
[0022] Figure 3 It is an overall logic diagram of the request processing method in the embodiment of the present disclosure;
[0023] Figure 4 A block diagram of a request processing device provided by an embodiment of the present disclosure;
[0024] Figure 5 A block diagram of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0025] In order to enable those skilled in the art to better understand the technical solutions of the present disclosure, the exemplary embodiments of the present disclosure are described below in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0026] In the absence of conflict, the various embodiments of the present disclosure and the various features therein may be combined with each other.
[0027] As used herein, the term "and / or" includes any and all combinations of one or more of the associated listed items.
[0028] The terms used herein are only used to describe specific embodiments and are not intended to limit the present disclosure. As used herein, the singular forms "a" and "the" are also intended to include plural forms, unless the context clearly indicates otherwise. It will also be understood that when the terms "including" and / or "made of" are used in this specification, the presence of the features, wholes, steps, operations, elements and / or components is specified, but the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or groups thereof is not excluded. "Connected" or "connected" and similar words are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect.
[0029] Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by those of ordinary skill in the art. It will also be understood that terms such as those defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant art and the present disclosure, and will not be interpreted as having an idealized or overly formal meaning unless explicitly defined as such herein.
[0030] In the technical solution disclosed in this disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals. The use of user data in this technical solution complies with relevant national laws and regulations (for example, the "Information Security Technology Personal Information Security Specification", etc.). For example: corresponding prescribed measures are taken for personal information access control; prescribed restrictions are imposed on the display of personal information; the purpose of using personal information does not exceed the scope of direct or reasonable association; when using personal information, clear identity orientation is eliminated to avoid precise positioning of specific individuals.
[0031] In the related art, maintaining processing links corresponding to different versions requires additional processing nodes, and relies on storage media such as databases to record processing links of different versions. However, some application scenarios may not have databases or other storage systems as support, which makes it difficult to achieve compatibility with multiple versions. In addition, compatibility with different versions will lead to code redundancy, which requires more resources to maintain.
[0032] Therefore, a request processing method is provided in the embodiment of the present disclosure, in which code segments with processing logic differences between different versions are maintained in the service code, without the need to maintain a processing link corresponding to each version, and there is no need to rely on a database to store processing links of different versions. The usage scenarios are more extensive, and because the service code includes code segments with processing logic differences between different versions, compatibility with processing requests of different versions can be achieved based on the service code. After the application is released and deployed, a processing request including a first version identifier of the application is received, the service code for the processing request can be determined, and the first code segment allowed to be executed in the service code is determined according to the first version identifier. By executing the first code segment, the processing result of the processing request is obtained. In this way, only the code segments of the different version parts need to be retained in the service code, and the corresponding code segments are determined through the version identifier, so that the processing requests of the version identifier can be processed, thereby achieving compatibility with processing requests of different versions, which is simpler and more convenient, and reduces resource consumption.
[0033] Figure 1 The application scenario architecture diagram of the request processing method and device provided by the embodiments of the present disclosure is schematically shown.
[0034] like Figure 1 As shown, the application scenario of the embodiment of the present disclosure may include a terminal device 101, a network 103 and a server 102. The network 103 is used to provide a medium for a communication link between the terminal device 101 and the server 102. The network 103 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0035] The user can use the terminal device 101 to interact with the server 102 through the network 103 to receive or send messages, etc. Various communication client applications can be installed on the terminal device 101, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples), and the application can also have multiple versions, and can also perform iterative version updates.
[0036] The terminal device 101 may be any electronic device having a display screen and supporting web browsing, including but not limited to a smart phone, a tablet computer, a laptop computer, a desktop computer, and the like.
[0037] The server 102 may be a server that provides various services, such as a background management server (only as an example) that provides support for websites browsed by users using the terminal device 101. The background management server may analyze and process received data such as user requests, and feed back processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal device.
[0038] It should be noted that the request processing method and apparatus provided in the embodiments of the present disclosure may be executed by the server 102. Accordingly, the request processing method and apparatus provided in the embodiments of the present disclosure may be arranged in the server 102. The request processing method and apparatus provided in the embodiments of the present disclosure may also be executed by a server or server cluster that is different from the server 102 and that can communicate with the terminal device 101 and / or the server 102. Accordingly, the request processing method and apparatus provided in the embodiments of the present disclosure may also be arranged in a server or server cluster that is different from the server 102 and that can communicate with the terminal device 101 and / or the server 102.
[0039] It should be understood that Figure 1 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 implementation requirements.
[0040] Figure 2 A flowchart of a request processing method provided by an embodiment of the present disclosure. Figure 2 , the method comprising:
[0041] S201: Receive a processing request for an application, where the processing request includes a first version identifier of the application.
[0042] For example, when iteratively updating an application, in order to meet different needs, multiple versions can be released online at the same time, such as the official version and the trial version. After the user starts the application on the terminal device, he can choose which version to log in. If the user chooses the trial version, he will enter the trial version of the application, and then initiate a processing request carrying the first version identifier of the trial version.
[0043] S202: Determine a service code corresponding to the processing request, wherein the service code includes multiple code segments, and a code segment is composed of codes with processing logic differences between any two versions of the application.
[0044] In the embodiments of the present disclosure, in order to be compatible with different versions of an application, the processing logic differences of different versions are divided into different code segments. It can be understood that a code segment represents the code with code logic differences between different versions. For example, the V1 code segment in a service code of an application requires adjustment of business rules due to the new iteration requirement V2. The adjusted service code includes the V1 code segment and the V2 code segment. The codes of the V1 code segment and the V2 code segment allow requests of different versions to access. If multiple clients initiate requests of different versions at the same time in a certain time period, a code processing logic conflict will occur. Therefore, in the embodiments of the present disclosure, the code segments are divided and the code segments can be identified to distinguish and process requests of different versions.
[0045] In addition, when iteratively updating the service code, it is usually not necessary to modify all the code of the service code. The common code between different versions may be retained. Therefore, the code in the service code that does not distinguish between versions can also be called common code, which can allow all versions of requests to access it.
[0046] Regarding the above-mentioned step S202, in the embodiment of the present disclosure, after receiving the processing request, the server can determine which service codes are used to process the processing request. There is no restriction on the processing request, and it can be any business service request of the application. For example, the processing request is a login request. The login request includes not only the first version identifier, but also the user name and password. The server can verify whether the user name and password are correct based on the service code used for identity verification. If the identity verification passes, the application interface after successful login can be returned to the client.
[0047] S203: Determine, according to the first version identifier, a first code segment in the service code that is allowed to be executed.
[0048] In the disclosed embodiment, a version manager can be used to uniformly manage all versions, and can be used to determine the first code segment in the service code that is allowed to be executed. For example, to improve efficiency, the version manager object can be loaded and created after the application is started. Upon receiving a processing request, the first version identifier can be verified to be legal based on the version manager. If the version with the first version identifier is included in all current versions, it is determined to be legal. If it is determined to be legal, the service code of the processing request is called and executed. When the general code of the service code is executed, there is no need to make a version compatibility judgment, and the general code can be executed. When the code segment of the service code is executed, it is necessary to determine whether execution is allowed. Specifically, the version manager is called to perform permission verification. If access to the code segment is allowed, the processing logic of the code segment is executed.
[0049] S204: Obtain a processing result of the processing request by executing the first code segment.
[0050] In the disclosed embodiment, for a processing request of an application, a first code segment that is allowed to be executed in a service code corresponding to the processing request is determined based on a first version identifier in the processing request, and a processing result of the processing request is obtained by executing the first code segment. In this way, there is no need to add an additional processing link, and there is no need to rely on a database to store different versions of processing links. The usage scenarios are more extensive, and by dividing different versions of code segments in the service code, compatibility of requests of different versions is achieved. There is no other redundant code, which makes the implementation simpler and more efficient, and reduces resource consumption.
[0051] The request processing method of the embodiment of the present disclosure is described below.
[0052] With respect to the above step S203, the present disclosure further provides a possible implementation mode. Specifically, according to the first version identifier, determining the first code segment in the service code that is allowed to be executed includes:
[0053] 1) Obtain the version identifier and compatible rule identifier corresponding to each code segment in the service code.
[0054] The version identifier is used to indicate the version corresponding to the code segment, and the compatibility rule identifier is used to represent the compatibility rule. The compatibility rule can indicate the method for determining whether execution is allowed.
[0055] In the disclosed embodiments, multiple different versions of code segments and compatibility rules can be defined according to actual needs, and the code segment information of the code segment can be recorded. In addition, the file path where the code segment is located, the code location, etc. can also be recorded without limitation, wherein the code segment information includes a version identifier, a compatibility rule identifier, etc.
[0056] 2) Determine the first code segment in the service code that is allowed to be executed according to the first version identifier, the version identifier of each code segment, and the compatibility rule identifier.
[0057] In the embodiment of the present disclosure, a compatibility rule may be preset, and a compatibility rule identifier corresponding to the compatibility rule may be defined. The compatibility rule may also be understood as a logical judgment strategy for whether to allow access to or execution of a certain code segment for a processing request for the first version identifier. In addition, several possible compatibility rules are provided in the embodiment of the present disclosure. Based on different compatibility rules, specific implementation methods are also provided accordingly:
[0058] In one possible implementation, the first code segment allowed to be executed in the service code is determined based on the first version identifier, the version identifier of each code segment, and the compatibility rule identifier, including: for each code segment in the service code, when the version compatibility rule corresponding to the compatibility rule identifier is mutually exclusive for different versions, if the first version identifier and the version identifier are the same, then the code segment is determined to be the first code segment allowed to be executed.
[0059] Among them, the compatibility rule is that different versions are mutually exclusive, which means that the request is only allowed to access the code segment of the same version as the request, otherwise the access is not allowed.
[0060] For the convenience of management and judgment of compatible rules, the version identifier is taken as an example that the version identifier shows an increasing trend according to the iteration time. In this way, the higher the version identifier is, the higher the corresponding version is. For example, the V2 version is higher than the V1 version. For example, the first version identifier in the processing request is V1, and the service code corresponding to the processing request is M1. M1 includes a V1 code segment and a V2 code segment. When executing the service code M1, the general code of M1 can be directly executed, and the code segment in M1 needs to be compatible. For example, each code segment in M1 corresponds to a compatible judgment statement. When the compatible judgment statement of the V1 code segment is executed, according to the compatible rule identifier of the V1 code segment, the corresponding compatible rule is obtained that different versions are mutually exclusive. It is judged that the first version identifier V1 is the same as the version identifier V1, then the V1 code segment is the first code segment allowed to be executed. The V1 code segment is executed, and when the compatible judgment statement of the V2 code segment is continued to be executed, according to the compatible rule identifier of the V2 code segment, the corresponding compatible rule is obtained that different versions are mutually exclusive. It is judged that the first version identifier V1 is the same as the version identifier V2, and the V2 code segment is not executed.
[0061] In one possible implementation, the first code segment allowed to be executed in the service code is determined based on the first version identifier, the version identifier of each code segment, and the compatibility rule identifier, including: for each code segment in the service code, when the version compatibility rule corresponding to the compatibility rule identifier is version backward compatibility, if the version corresponding to the first version identifier is equal to or higher than the version corresponding to the version identifier, then the code segment is determined to be the first code segment allowed to be executed.
[0062] The version backward compatibility rule may indicate that when the requested version is a higher version, access to a code segment of the same or lower version relative to the requested version is allowed; otherwise, access is not allowed.
[0063] For example, when the first version identifier in the processing request initiated by client 1 is V1, the service code M1 for processing the processing request is called, and when the V1 code segment in M1 is executed, the version manager is called, and according to the compatibility rule identifier of the V1 code segment, the corresponding version compatibility rule is obtained as downward compatibility, and it is determined that the first version identifier V1 is the same as the version identifier V1, then the execution of the V1 code segment is allowed, and when the execution continues to the V2 code segment, the version manager is called, and according to the compatibility rule identifier of the V2 code segment, the corresponding compatibility rule is obtained as downward compatibility, and it is determined that the version identifier V2 is higher than the first version identifier V1, then the execution of the V2 code segment is not allowed.
[0064] In one possible implementation, the first code segment allowed to be executed in the service code is determined based on the first version identifier, the version identifier of each code segment, and the compatibility rule identifier, including: for each code segment in the service code, when the version compatibility rule corresponding to the compatibility rule identifier is upward compatibility, if the version corresponding to the first version identifier is equal to or lower than the version corresponding to the version identifier, then the code segment is determined to be the first code segment allowed to be executed.
[0065] Among them, upward compatibility of versions may mean that when the requested version is a lower version, access to a code segment of the same or higher version relative to the requested version is allowed, otherwise access is not allowed.
[0066] For example, when the first version identifier in the processing request initiated by client 1 is V1, the service code M1 for processing the processing request is called. When the V1 code segment in M1 is executed, the version manager is called. According to the compatibility rule identifier of the V1 code segment, the corresponding version compatibility rule is obtained as upward compatibility. If the first version identifier V1 is judged to be the same as the version identifier V1, the execution of the V1 code segment is allowed. When the execution continues to the V2 code segment, the version manager is called. According to the compatibility rule identifier of the V2 code segment, the corresponding version compatibility rule is obtained as upward compatibility. If the version identifier V2 is higher than the first version identifier V1, and the version upward compatibility rule allows access to the higher version code segment, the execution of the V2 code segment is also allowed.
[0067] In this way, in the embodiment of the present disclosure, the first code segment allowed to be executed in the service code is judged based on the first version identifier in the processing request, as well as the version identifier and compatibility rule identifier of the code segment, so that processing requests of different versions can be distinguished and compatible with processing requests of different versions can be achieved.
[0068] In some possible embodiments of the present disclosure, in order to distinguish code segments of different versions in the service code, during the source code writing and compiling stage of the application, line comments of code segment information can be added to the code segment, and the description format of the line comments can be defined, so that for the executable code generated after compilation, version compatibility judgment can be automatically performed when the code segment is executed. Specifically for the source code writing and compiling stage, the present disclosure also provides possible implementation methods, including:
[0069] S1. Obtain source code of an application, wherein the source code includes a service code in a first language, and each code segment in the service code corresponds to a first start description format comment and a first end description format comment.
[0070] Among them, the first start description format comment may include a first start mark, a version identifier, a compatibility rule identifier, and a whether to ignore comment parsing identifier; the first end description format comment may include a first end mark, a version identifier, a compatibility rule identifier, and a whether to ignore comment parsing identifier.
[0071] In the disclosed embodiment, the description format of the code segment information can be pre-defined, and each code segment is separated by a start description format comment and an end description format comment. In order for a subsequent code rewriter to identify whether a code segment has been rewritten, it is also possible to distinguish between the first start description format comment and the first end description format comment before rewriting, and the second start description format comment and the second end description format comment after rewriting.
[0072] For example, taking the version identifier as V1, the compatibility rule identifier as R1, and the i in [i] indicating ignoring comment parsing, [] indicating optional, if i is not included, the identifier does not ignore comment parsing, the first start description format comment that has not been rewritten is: / / TOVER-S V1 R1[i], the first end description format comment that has not been rewritten is: / / TOVER-E V1 R1[i]; the second start description format comment that has been rewritten is: / / TOVER-SED V1 R1[i], and the second end description format comment that has been rewritten is: / / TOVER-EED V1 R1[i].
[0073] Among them, TOVER-S represents the first start mark, TOVER-E represents the first end mark, TOVER-SED represents the second start mark, and TOVER-EED represents the second end mark. The present disclosure does not limit this and can be set in advance. In addition, the first start description format comment and the first end description format comment are a pair of descriptions that have not been rewritten, the second start description format comment and the second end description format comment are a pair of descriptions that have been rewritten, and the same code segment can only use a pair of format descriptions.
[0074] S2. Based on a preset annotation parser, the code segment is identified according to the first description format annotation and the first end description format annotation, and the identified first description format annotation and the first end description format annotation are parsed to obtain a version identifier and a compatibility rule identifier of the identified code segment.
[0075] In the disclosed embodiment, an annotation parser may be provided, which may be packaged into a tool or plug-in and integrated into the application development software, and may be used in the source code writing stage. In a possible embodiment, the annotation parser is specifically used in the following aspects: 1) reading all or part of the source code files under the specified path, and parsing to obtain the code segment information of the code segment in the source code file; 2) checking the format of the annotation corresponding to the code segment according to the predefined first start description format, the first end description format, the second start description format, and the second end description format, and reporting an error if it does not meet the preset format or does not belong to a pair of formats, so that relevant personnel can check and modify it; 3) maintaining a general register description file, which is used to record the code segment information obtained by parsing and the file path, code location, etc., which can be loaded into the memory when the application is started later, and generate a corresponding register object to provide it to the version manager for use, and provide the version manager with code segment information; 4) calling the code rewriter to rewrite the code segment.
[0076] S3. For each identified code segment, based on a preset code rewriter, rewrite the first start description format comment into the second start description format comment, rewrite the first end description format comment into the second end description format comment, and add a compatible judgment statement corresponding to the code segment to obtain the executable code of the application, wherein the executable code includes the service code in the second language.
[0077] The compatibility judgment statement is used to indicate whether the execution of the code segment is allowed.
[0078] Specifically, the present disclosure also provides possible implementations, including:
[0079] 1) Based on a preset code rewriter, the source code is read, and when the first starting description format comment is matched, it is determined whether an ignore comment parsing flag is included.
[0080] In the disclosed embodiment, a code rewriter can be provided, which can be encapsulated into a general text generation tool in a specific implementation, and is mainly used to rewrite the unrewritten first start description format comment and the first end description format comment into the second start description format comment and the second end description format comment, and rewrite the code in the code segment according to the if judgment structure.
[0081] After the code rewriter obtains the source code file, it can read the source code line by line, and can match and rewrite it according to the description format comments. It can define temporary variables or memory to temporarily store the rewritten code. After the entire source code is rewritten, it can return the rewritten executable code as a whole.
[0082] 2) When the ignore comment parsing identifier is not included, the first start description format comment is rewritten as the second start description format comment, and a compatibility judgment statement corresponding to the code segment is added according to the version identifier and the compatibility rule identifier in the first start description format comment.
[0083] For example, when a comment line containing the first start mark is matched, it is determined whether it contains an ignore comment parsing identifier. If the ignore comment parsing identifier is included, no rewriting is performed and the code is directly output. If the ignore comment parsing identifier is not included, the first start mark "TOVER-S" is rewritten as "TOVER-SED", that is, the first start description format comment " / / TOVER-SV1 R1[]" is rewritten as the second start description format comment " / / TOVER-SED V1 R1[]", and the version identifier and the compatible rule identifier are extracted to generate a compatible judgment statement, and an if judgment structure is constructed for output. For example, the compatible judgment statement is "if(VersionManger.permit(VersionEnum.V1, R1))", where VersionManger is the version manager, permit is the compatible application programming interface (API) method in the version manager, and VersionEnum represents the version identifier. In order to finally encapsulate the code of the code segment into the if structure, the example after the first start description format comment is rewritten is: " / / TOVER-S V1 R1[]", after rewriting, two lines are output: the first line is " / / TOVER-SED V1 R1[]", and the second line is "if(VersionManger.permit(VersionEnum.V1,R1)){".
[0084] 3) When the first end description format comment is matched, the first end description format comment is rewritten into the second end description format comment to obtain the executable code of the application.
[0085] The second end description format comment may include a second end mark, a version identifier, a compatibility rule identifier, and an identifier of whether to ignore comment parsing.
[0086] For example, when a line comment containing the first end mark is matched, it is determined whether it contains an ignore comment parsing marker. If it includes an ignore comment parsing marker, no rewriting is performed and the code is directly output. If it does not include an ignore comment parsing marker, the first start mark "TOVER-E" is rewritten as "TOVER-EED", corresponding to the rewriting of the first start description format comment. The final example of the rewritten first end description format comment is: " / / TOVER-E V1 R1[]". After rewriting, two lines are output: the first line content is "}", and the second line content is " / / TOVER-EED V1 R1[]".
[0087] Furthermore, in the embodiments of the present disclosure, in order to further improve the flexibility of version management, rewrite recovery and code segment information deletion functions may also be supported, and possible implementation methods are specifically provided:
[0088] In a possible embodiment, in response to the rewrite recovery instruction, the rewritten code segment is restored to be the code segment before the rewrite.
[0089] That is, in the embodiment of the present disclosure, according to actual needs, the previous rewrite operation on the code segment can also be undone, and the specified source code or a code segment therein can be restored. The restoration can be performed according to the code segment information recorded in the register description file, and the corresponding content in the register description file can be updated after successful recovery.
[0090] In a possible embodiment, in response to a code segment information deletion instruction, the comments and compatibility judgment statements corresponding to the code segment are deleted, and only the code in the code segment is retained, so that the code in the code segment is transformed into a universal code without the need to distinguish versions. In addition, after the deletion is successful, the corresponding content in the register file is synchronously updated.
[0091] In the disclosed embodiment, the source code can be parsed based on the annotation parser to obtain the code segment information of the code segment so as to judge whether the code segment is allowed to be executed when the application is started and run. In addition, the code segment can be automatically rewritten based on the code rewriter to generate new executable code to make the code segment effective, which is simple to implement and improves efficiency.
[0092] The following uses a specific application scenario to illustrate the request processing method in the embodiment of the present disclosure. For example, two versions V1 and V2 are included, and the V2 version is higher than the V1 version. The processing chain corresponding to the processing request initiated by the client includes multiple service codes executed in sequence, such as service code M1, service code M2, service code M3, etc. Figure 3 As shown, it is an overall logic diagram of the request processing method in the embodiment of the present disclosure, which can be divided into the following two aspects for explanation:
[0093] The first aspect: during the source code writing and compilation phase of the application.
[0094] like Figure 3 As shown, based on the annotation parser, the source code is read and parsed to obtain the code segment information of the code segment, and the parsed code segment information is recorded in the register description file.
[0095] Based on the code rewriter, the code segment is rewritten, specifically, the first start description format comment and the first end description format comment of the code segment are rewritten, and a compatible judgment statement is added to encapsulate the code in the code segment into the judgment structure of the compatible judgment statement.
[0096] For example, before rewriting: / / TOVER-S V1 R1[]
[0097] V1 Code Snippet
[0098] / / TOVER-E V1 R1[]
[0099] After rewriting: / / TOVER-SED V1 R1[]
[0100] if(VersionManger.permit(VersionEnum.V1,R1))
[0101] {
[0102] V1 Code Snippet
[0103] / / TOVER-EED V1 R1[]
[0104] The second aspect: during the application deployment and startup phase.
[0105] like Figure 3 As shown, in the embodiment of the present disclosure, when triggering the start of an application, the registrar description file can be loaded and read, a registrar object can be created, the executable code of the application can be loaded and run, the version compatibility rules can be loaded and the corresponding version compatibility rule objects can be created, the version manager object can be loaded and created, the version information, code segment information, etc. can be initialized from the registrar, and the related compatible API judgment method in the version manager can be initialized. The compatible API judgment method is used to determine whether the code segment is the first code segment allowed to be executed. In this way, by creating corresponding objects for subsequent request processing, the processing efficiency in memory can be improved.
[0106] Among them, the version manager in the embodiment of the present disclosure can be mainly used to implement the following functions: version manager lifecycle control, which can create a version manager when the application starts, and destroy the version manager when the application exits or ends; the version manager can obtain all version identifiers of the application from the registrar to verify whether the first version identifier in the processing request is legal; the version manager can provide a compatible API judgment method, which supports parameters such as the version identifier and compatible rule identifier of the incoming code segment to judge whether the execution of the code segment is allowed.
[0107] For example, Figure 3 As shown, client 1 initiates a V1 processing request, that is, the first version identifier included in the processing request is V1. The server receives the V1 processing request, verifies that the V1 version is legal through the version manager, and then calls the service code M1. When executing the V1 code segment in M1, the compatible API judgment method of the version manager is called. Taking the version compatibility rule of the V1 code segment as version backward compatibility as an example, by judging that the first version identifier V1 and version V1 are the same, it is determined that the V1 code segment is allowed to be executed; then the M1 code continues to be executed. When executing the V2 code segment, still taking the version compatibility rule of the V2 code segment as version backward compatibility as an example, it is judged that the first version identifier V1 is lower than version V2, and the V2 code segment is not allowed to be executed; then after executing the service code M1, the subsequent service codes M2 and M3 are continued to be called. Similarly, the code segments in the service code can be judged to determine the first code segment allowed to be executed in the service code. Finally, after all the service codes of the V1 processing request are executed, the processing result of the V1 processing request is obtained.
[0108] For example, Figure 3 As shown, the client 2 initiates a V2 processing request, that is, the first version identifier included in the processing request is V2. The server receives the V2 processing request, verifies through the version manager that the V2 version is legal, and then calls the service code M1. When the V1 code segment in M1 is executed, the compatible API judgment method of the version manager is called. Taking the version compatibility rule of the V1 code segment as version backward compatibility as an example, by judging that the first version identifier V2 is higher than version V1, it is determined that the execution of the V1 code segment is allowed; then the M1 code continues to be executed. When the V2 code segment is executed, still taking the version compatibility rule of the V2 code segment as version backward compatibility as an example, it is judged that the first version identifier V2 is the same as version V2, and the execution of the V2 code segment is allowed; then after the service code M1 is executed, the subsequent service codes M2 and M3 are similarly called. Finally, after all the service codes of the V2 processing request are executed, the processing result of the V2 processing request is obtained.
[0109] In the disclosed embodiment, based on the annotation parser and the code rewriter, the code segment information is parsed and recorded, and the code segment is rewritten to generate executable code. In this way, if the application is iterated in version and a new version of the code segment is added, the new version can be immediately effective after parsing and rewriting, which is more efficient and simple. A code registrar is also provided, which can automatically register the code segment information to the version manager. When a processing request is received, the version manager can make a compatibility judgment based on the code segment information, determine the first code segment allowed to be executed in the service code corresponding to the processing request, avoid processing conflicts between requests of different versions, and achieve compatibility with requests of different versions.
[0110] It can be understood that the above-mentioned various method embodiments mentioned in the present disclosure can be combined with each other to form a combined embodiment without violating the principle logic. Due to space limitations, the present disclosure will not repeat them. It can be understood by those skilled in the art that in the above-mentioned method of the specific implementation method, the specific execution order of each step should be determined according to its function and possible internal logic.
[0111] In addition, the present disclosure also provides a request processing device, an electronic device, and a computer-readable storage medium, all of which can be used to implement any request processing method provided by the present disclosure. The corresponding technical solutions and descriptions are referred to in the corresponding records of the method part and will not be repeated here.
[0112] Figure 4 A block diagram of a request processing device provided in an embodiment of the present disclosure.
[0113] Reference Figure 4 The present disclosure provides a request processing device, the request processing device comprising:
[0114] A receiving module 41, configured to receive a processing request for an application, wherein the processing request includes a first version identifier of the application;
[0115] A first determining module 42 is used to determine a service code corresponding to the processing request, wherein the service code includes a plurality of code segments, and a code segment is composed of codes having processing logic differences between any two versions of the application program;
[0116] A second determining module 43, configured to determine a first code segment in the service code that is allowed to be executed according to the first version identifier;
[0117] The obtaining module 44 is used to obtain the processing result of the processing request by executing the first code segment.
[0118] In a possible embodiment, when determining the first code segment allowed to be executed in the service code according to the first version identifier, the second determining module 43 is used to:
[0119] Obtaining a version identifier and a compatibility rule identifier corresponding to each code segment in the service code;
[0120] A first code segment that is allowed to be executed in the service code is determined according to the first version identifier, the version identifier of each code segment, and the compatibility rule identifier.
[0121] In a possible embodiment, when determining the first code segment allowed to be executed in the service code according to the first version identifier, the version identifier of each code segment, and the compatibility rule identifier, the second determining module 43 is used to:
[0122] For each code segment in the service code, when the version compatibility rule corresponding to the compatibility rule identifier is mutually exclusive for different versions, if the first version identifier and the version identifier are the same, the code segment is determined to be the first code segment allowed to be executed.
[0123] In a possible embodiment, when determining the first code segment allowed to be executed in the service code according to the first version identifier, the version identifier of each code segment, and the compatibility rule identifier, the second determining module 43 is used to:
[0124] For each code segment in the service code, when the version compatibility rule corresponding to the compatibility rule identifier is version backward compatibility, if the version corresponding to the first version identifier is equal to or higher than the version corresponding to the version identifier, the code segment is determined to be the first code segment allowed to be executed.
[0125] In a possible embodiment, when determining the first code segment allowed to be executed in the service code according to the first version identifier, the version identifier of each code segment, and the compatibility rule identifier, the second determining module 43 is used to:
[0126] For each code segment in the service code, when the version compatibility rule corresponding to the compatibility rule identifier is upward compatibility, if the version corresponding to the first version identifier is equal to or lower than the version corresponding to the version identifier, the code segment is determined to be the first code segment allowed to be executed.
[0127] A possible embodiment further includes a parsing and rewriting module, which is used to:
[0128] Obtaining source code of the application, wherein the source code includes a service code in a first language, and each code segment in the service code corresponds to a first start description format comment and a first end description format comment;
[0129] Based on a preset annotation parser, according to the first description format annotation and the first end description format annotation, the code segment is identified, and the identified first description format annotation and the first end description format annotation are parsed to obtain a version identifier and a compatibility rule identifier of the identified code segment;
[0130] For each identified code segment, based on a preset code rewriter, the first start description format comment is rewritten into a second start description format comment, the first end description format comment is rewritten into a second end description format comment, and a compatibility judgment statement corresponding to the code segment is added to obtain the executable code of the application, wherein the executable code includes service code in a second language.
[0131] Figure 5 A block diagram of an electronic device provided in an embodiment of the present disclosure.
[0132] Reference Figure 5 An embodiment of the present disclosure provides an electronic device, which includes: at least one processor 501; at least one memory 502, and one or more I / O interfaces 503, connected between the processor 501 and the memory 502; wherein the memory 502 stores one or more computer programs that can be executed by the at least one processor 501, and the one or more computer programs are executed by the at least one processor 501 so that the at least one processor 501 can execute the above-mentioned request processing method.
[0133] Each module in the above electronic device can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0134] The embodiment of the present disclosure also provides a computer-readable storage medium, which may be a volatile or non-volatile computer-readable storage medium on which a computer program is stored, wherein the computer program implements the above-mentioned request processing method when executed by a processor.
[0135] The embodiment of the present disclosure also provides a computer program product, including a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the above-mentioned request processing method.
[0136] It will be appreciated by those skilled in the art that all or some of the steps, systems, and functional modules / units in the methods disclosed above may be implemented as software, firmware, hardware, and appropriate combinations thereof. In a hardware implementation, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or may be implemented as hardware, or may be implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable storage medium, which may include a computer storage medium (or a non-transitory medium) and a communication medium (or a temporary medium).
[0137] As is known to those of ordinary skill in the art, the term computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable program instructions, data structures, program modules or other data). Computer storage media include, but are not limited to, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), static random access memory (SRAM), flash memory or other memory technology, portable compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and can be accessed by a computer. In addition, it is known to those of ordinary skill in the art that communication media typically contain computer-readable program instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transmission mechanism, and may include any information delivery medium.
[0138] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.
[0139] The computer program instructions for performing the operation of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages, such as Smalltalk, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. Computer-readable program instructions may be executed completely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be customized by utilizing the state information of the computer-readable program instructions, and the electronic circuit may execute the computer-readable program instructions, thereby realizing various aspects of the present disclosure.
[0140] The computer program product described herein may be implemented in hardware, software, or a combination thereof. In one optional embodiment, the computer program product is embodied as a computer storage medium, and in another optional embodiment, the computer program product is embodied as a software product, such as a software development kit (SDK), etc.
[0141] Various aspects of the present disclosure are described herein with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer-readable program instructions.
[0142] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0143] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operating steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0144] The flow chart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system, method and computer program product according to multiple embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a part of a module, program segment or instruction, and a part of the module, program segment or instruction includes one or more executable instructions for realizing the specified logical function. In some alternative implementations, the function marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two continuous square boxes can actually be executed substantially in parallel, and they can sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or action, or can be implemented with a combination of special hardware and computer instructions.
[0145] Example embodiments have been disclosed herein, and although specific terms are employed, they are used and should be interpreted only in a general illustrative sense and not for limiting purposes. In some instances, it will be apparent to those skilled in the art that, unless otherwise expressly noted, features, characteristics, and / or elements described in conjunction with a particular embodiment may be used alone or in combination with features, characteristics, and / or elements described in conjunction with other embodiments. Therefore, those skilled in the art will appreciate that various changes in form and detail may be made without departing from the scope of the present disclosure as set forth in the appended claims.
Claims
1. A request processing method, characterized in that: include: receiving a processing request for an application, the processing request including a first version identifier of the application; Determine a service code corresponding to the processing request, wherein the service code includes a plurality of code segments, and a code segment is composed of codes having processing logic differences between any two versions of the application program; Determining, according to the first version identifier, a first code segment in the service code that is allowed to be executed; By executing the first code segment, a processing result of the processing request is obtained.
2. The request processing method according to claim 1, characterized in that: The determining, according to the first version identifier, a first code segment in the service code that is allowed to be executed includes: Obtaining a version identifier and a compatibility rule identifier corresponding to each code segment in the service code; A first code segment that is allowed to be executed in the service code is determined according to the first version identifier, the version identifier of each code segment, and the compatibility rule identifier.
3. The request processing method according to claim 2, characterized in that: The determining, according to the first version identifier, the version identifier of each code segment, and the compatibility rule identifier, the first code segment that is allowed to be executed in the service code includes: For each code segment in the service code, when the version compatibility rule corresponding to the compatibility rule identifier is mutually exclusive for different versions, if the first version identifier and the version identifier are the same, the code segment is determined to be the first code segment allowed to be executed.
4. The request processing method according to claim 2, characterized in that: The determining, according to the first version identifier, the version identifier of each code segment, and the compatibility rule identifier, the first code segment that is allowed to be executed in the service code includes: For each code segment in the service code, when the version compatibility rule corresponding to the compatibility rule identifier is version backward compatibility, if the version corresponding to the first version identifier is equal to or higher than the version corresponding to the version identifier, the code segment is determined to be the first code segment allowed to be executed.
5. The request processing method according to claim 2, characterized in that: The determining, according to the first version identifier, the version identifier of each code segment, and the compatibility rule identifier, the first code segment that is allowed to be executed in the service code includes: For each code segment in the service code, when the version compatibility rule corresponding to the compatibility rule identifier is upward compatibility, if the version corresponding to the first version identifier is equal to or lower than the version corresponding to the version identifier, the code segment is determined to be the first code segment allowed to be executed.
6. The request processing method according to any one of claims 2 to 5, characterized in that: The method further comprises: Obtaining source code of the application, wherein the source code includes a service code in a first language, and each code segment in the service code corresponds to a first start description format comment and a first end description format comment; Based on a preset annotation parser, according to the first description format annotation and the first end description format annotation, the code segment is identified, and the identified first description format annotation and the first end description format annotation are parsed to obtain a version identifier and a compatibility rule identifier of the identified code segment; For each identified code segment, based on a preset code rewriter, the first start description format comment is rewritten into a second start description format comment, the first end description format comment is rewritten into a second end description format comment, and a compatibility judgment statement corresponding to the code segment is added to obtain the executable code of the application, wherein the executable code includes service code in a second language.
7. A request processing device, characterized in that: include: A receiving module, configured to receive a processing request for an application, wherein the processing request includes a first version identifier of the application; A first determination module is used to determine a service code corresponding to the processing request, wherein the service code includes a plurality of code segments, and a code segment is composed of codes having processing logic differences between any two versions of the application; A second determining module, configured to determine a first code segment in the service code that is allowed to be executed according to the first version identifier; The obtaining module is used to obtain the processing result of the processing request by executing the first code segment.
8. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores one or more computer programs executable by the at least one processor, and the one or more computer programs are executed by the at least one processor to enable the at least one processor to perform the request processing method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the computer program implements the request processing method according to any one of claims 1 to 6.
10. A computer program product, characterized in that The invention comprises a computer-readable code or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the request processing method as described in any one of claims 1 to 6.