Program switching method, device, electronic device and storage medium

By receiving and comparing the return results of the first program and the second program, unsensible program switching is achieved, solving the problems of high cost and high risk of framework switching, and improving the switching efficiency and reliability.

CN115016908BActive Publication Date: 2025-08-22BEIJING QIYI CENTURY SCI & TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210490009.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-06
Publication Date
2025-08-22
Estimated Expiration
2042-05-06

AI Technical Summary

Technical Problem

The existing technology has problems such as high upgrade cost, long switching cycle and high change risks during the framework switching process, especially after the business system is running for a long time, it is difficult to effectively switch the framework.

Method used

By receiving the target request, sending it to the first program to generate the return result, the request is copied and sent to the second program to generate the return result with the same parameters, comparing whether the results of the two match. If it matches, switch the first program to the second program, and verify using the log association storage request identification and return result.

Benefits of technology

The front-end non-aware program switching is realized, reducing or even avoiding the impact of framework switching on the front-end, and improving the efficiency and reliability of switching.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115016908B_ABST
    Figure CN115016908B_ABST
Patent Text Reader

Abstract

The disclosed embodiments relate to a program switching method, device, electronic device and storage medium, the method comprising: receiving a target request; sending the target request to a first program, so that the first program generates a first request return result of the target request; copying the target request, and sending the copied target request to a second program, so that the second program generates a second request return result of the target request, wherein the program parameters of the second program are the same as the program parameters of the first program; determining whether the first request return result and the second request return result match; if the first request return result and the second request return result match, switching the first program to the second program. By this method, program switching can be achieved without front-end perception and within the background project, thereby reducing or even avoiding the impact of program switching on the front-end.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present disclosure relate to the field of computer technology, and more particularly to a program switching method, device, electronic device, and storage medium. Background Art

[0002] As business systems run for a long time, they will inevitably need to evolve due to a large number of changing requirements. For example, a framework switch may be necessary.

[0003] Taking framework switching as an example, the changes brought about by the new framework are not limited to changes in development language, technology stack, components, SDK (Software Development Kit), etc. There are generally two solutions for switching from the old framework to the new framework:

[0004] One is to upgrade the entire business. This solution incorporates the cost of framework upgrades into the cost of business upgrades, using the profits from the business upgrades to cover the costs.

[0005] The second is to upgrade the front-end calling interface and domain name during project iteration. This solution requires a longer switching cycle and also introduces greater change risks. Summary of the Invention

[0006] In view of this, in order to solve some or all of the above technical problems, the embodiments of the present disclosure provide a program switching method, device, electronic device and storage medium.

[0007] In a first aspect, an embodiment of the present disclosure provides a program switching method, the method comprising:

[0008] Receive target request;

[0009] Sending the target request to the first program so that the first program generates a first request return result of the target request;

[0010] Copying the target request, and sending the copied target request to a second program, so that the second program generates a second request return result of the target request, wherein program parameters of the second program are the same as those of the first program;

[0011] Determine whether the result returned by the first request matches the result returned by the second request;

[0012] If the result returned by the first request matches the result returned by the second request, the first program is switched to the second program.

[0013] Optionally, in the method of any embodiment of the present disclosure, a first log is used to associate and store a first request identifier and a request return result generated by the first program, wherein the first request identifier is an identifier of a target request sent to the first program; a second log is used to associate and store a second request identifier and a request return result generated by the second program, wherein the second request identifier is an identifier of a target request sent to the second program; and

[0014] The above method uses the following method to determine whether the result returned by the first request matches the result returned by the second request:

[0015] Parsing the first log to determine a request return result stored in the first log in association with the request identifier of the target request, and using the request return result determined from the first log as the first request return result;

[0016] Parsing the second log to determine the request return result stored in the second log in association with the request identifier of the target request, and using the request return result determined from the second log as the second request return result;

[0017] If the result returned by the first request is the same as the result returned by the second request, then determining that the result returned by the first request matches the result returned by the second request;

[0018] If the result returned by the first request is different from the result returned by the second request, it is determined that the result returned by the first request is not matched with the result returned by the second request.

[0019] Optionally, in the method of any embodiment of the present disclosure, the first request return result includes: a first request result status code, a size of the first return result, and content of the first return result; the second request return result includes: a second request result status code, a size of the second return result, and content of the second return result; and

[0020] The above method uses the following method to determine whether the result returned by the first request matches the result returned by the second request:

[0021] If the first request result status code is the same as the second request result status code, and the size of the first returned result is the same as the size of the second returned result, determining whether the content of the first returned result is the same as the content of the second returned result;

[0022] If the content of the first returned result is the same as the content of the second returned result, then determining that the first request returned result and the second request returned result match;

[0023] If the content of the first returned result is different from the content of the second returned result, it is determined that the first request returned result and the second request returned result do not match.

[0024] Optionally, in the method of any embodiment of the present disclosure, the method further includes:

[0025] If the first request result status code is different from the second request result status code, and / or the size of the first return result is different from the size of the second return result, it is determined that the first request return result and the second request return result do not match.

[0026] Optionally, in the method of any embodiment of the present disclosure, the request identifier includes at least one of the following:

[0027] The address of the device that sends the target request, the user name corresponding to the device that sends the target request, and the request information of the target request.

[0028] Optionally, in the method of any embodiment of the present disclosure, the copying of the target request includes:

[0029] If the number of requests received per unit time is greater than or equal to a preset number threshold, then copy the target request; and / or

[0030] If the program delay duration of the first program is greater than or equal to a preset duration threshold, the target request is copied.

[0031] Optionally, in the method of any embodiment of the present disclosure, the first program is a program framework, and the second program is a program framework different from the first program.

[0032] In a second aspect, an embodiment of the present disclosure provides a program switching device, comprising:

[0033] a receiving unit configured to receive a target request;

[0034] a sending unit configured to send the target request to a first program, so that the first program generates a first request return result of the target request;

[0035] a copying unit configured to copy the target request and send the copied target request to a second program, so that the second program generates a second request return result of the target request, wherein program parameters of the second program are the same as those of the first program;

[0036] A first determining unit is configured to determine whether the result returned by the first request matches the result returned by the second request;

[0037] The switching unit is configured to switch the first program to the second program if the result returned by the first request matches the result returned by the second request.

[0038] Optionally, in the apparatus of any embodiment of the present disclosure, a first log is used to associate and store a first request identifier and a request return result generated by the first program, wherein the first request identifier is an identifier of a target request sent to the first program; a second log is used to associate and store a second request identifier and a request return result generated by the second program, wherein the second request identifier is an identifier of a target request sent to the second program; and

[0039] The above device also includes:

[0040] a first parsing unit configured to parse the first log to determine a request return result stored in the first log in association with the request identifier of the target request, and use the request return result determined from the first log as the first request return result;

[0041] a second parsing unit configured to parse the second log to determine a request return result stored in the second log in association with the request identifier of the target request, and use the request return result determined from the second log as a second request return result;

[0042] a second determining unit configured to determine that the result returned by the first request matches the result returned by the second request if the result returned by the first request is the same as the result returned by the second request;

[0043] The third determining unit is configured to determine that the result returned by the first request and the result returned by the second request do not match if the result returned by the first request and the result returned by the second request are different.

[0044] Optionally, in the device of any embodiment of the present disclosure, the first request return result includes: a first request result status code, a size of the first return result, and content of the first return result; the second request return result includes: a second request result status code, a size of the second return result, and content of the second return result; and

[0045] The above device also includes:

[0046] a fourth determining unit configured to, if the first request result status code is the same as the second request result status code, and the size of the first returned result is the same as the size of the second returned result, determine whether the content of the first returned result is the same as the content of the second returned result;

[0047] a fifth determining unit configured to determine that the first request return result and the second request return result match if the content of the first return result is the same as the content of the second return result;

[0048] The sixth determining unit is configured to determine that the first request return result and the second request return result do not match if the content of the first return result is different from the content of the second return result.

[0049] Optionally, in the device of any embodiment of the present disclosure, the device further includes:

[0050] The seventh determination unit is configured to determine that the first request return result and the second request return result do not match if the first request result status code is different from the second request result status code, and / or the size of the first return result is different from the size of the second return result.

[0051] Optionally, in the device of any embodiment of the present disclosure, the request identifier includes at least one of the following:

[0052] The address of the device that sends the target request, the user name corresponding to the device that sends the target request, and the request information of the target request.

[0053] Optionally, in the apparatus of any embodiment of the present disclosure, the copying unit is further configured to:

[0054] If the number of requests received per unit time is greater than or equal to a preset number threshold, then copy the target request; and / or

[0055] If the program delay duration of the first program is greater than or equal to a preset duration threshold, the target request is copied.

[0056] Optionally, in the device of any embodiment of the present disclosure, the first program is a program framework, and the second program is a program framework different from the first program.

[0057] In a third aspect, an embodiment of the present disclosure provides an electronic device, including:

[0058] memory for storing computer programs;

[0059] The processor is configured to execute the computer program stored in the memory, and when the computer program is executed, implements the method of any embodiment of the program switching method of the first aspect of the present disclosure.

[0060] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium, which, when executed by a processor, implements a method as in any embodiment of the program switching method of the first aspect described above.

[0061] In a fifth aspect, an embodiment of the present disclosure provides a computer program comprising a computer-readable code, which, when executed on a device, enables a processor in the device to execute instructions for implementing the steps of the method of any embodiment of the program switching method of the first aspect described above.

[0062] The program switching method provided by the embodiment of the present disclosure receives a target request, and then sends the target request to a first program so that the first program generates a first request return result of the target request, and then copies the target request and sends the copied target request to a second program so that the second program generates a second request return result of the target request, wherein the program parameters of the second program are the same as the program parameters of the first program, and then determines whether the first request return result and the second request return result match, and if the first request return result and the second request return result match, the first program is switched to the second program. By using this method, when the first request return result returned by the first program matches the second program return result returned by the second program, the first program can be switched to the second program with the same program parameters as the first program, thereby realizing program switching within the background project without the front-end perception, thereby reducing or even avoiding the impact of program switching on the front-end. BRIEF DESCRIPTION OF THE DRAWINGS

[0063] Figure 1 A flowchart of a program switching method provided by an embodiment of the present disclosure;

[0064] Figure 2 A flowchart of another program switching method provided by an embodiment of the present disclosure;

[0065] Figure 3A A flowchart of another program switching method provided in an embodiment of the present disclosure;

[0066] Figure 3B A system block diagram of a program switching method provided by an embodiment of the present disclosure;

[0067] Figure 4 A schematic diagram of the structure of a program switching device provided by an embodiment of the present disclosure;

[0068] Figure 5 A schematic structural diagram of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0069] Various exemplary embodiments of the present disclosure will now be described in detail with reference to the accompanying drawings. It should be noted that unless otherwise specifically stated, the relative arrangement of components and steps, numerical expressions and numerical values ​​set forth in these embodiments do not limit the scope of the present disclosure.

[0070] Those skilled in the art will understand that the terms "first" and "second" in the embodiments of the present disclosure are only used to distinguish objects such as different steps, devices or modules, and neither represent any specific technical meaning nor indicate the logical order between them.

[0071] It should also be understood that in the embodiments of the present disclosure, “a plurality of” may refer to two or more than two, and “at least one” may refer to one, two, or more than two.

[0072] It should also be understood that any component, data or structure mentioned in the embodiments of the present disclosure can generally be understood as one or more, unless explicitly limited or otherwise indicated in the context.

[0073] In addition, the term "and / or" in this disclosure is merely a description of the association relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent three situations: A exists alone, A and B exist simultaneously, and B exists alone. In addition, the character " / " in this disclosure generally indicates that the related objects are in an "or" relationship.

[0074] It should also be understood that the description of the various embodiments in this disclosure focuses on the differences between the various embodiments, and the same or similar aspects thereof can be referenced with each other. For the sake of brevity, they will not be described one by one.

[0075] The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the present disclosure, its application, or uses.

[0076] Technologies, methods, and equipment known to ordinary technicians in the relevant art may not be discussed in detail, but where appropriate, the above-mentioned technologies, methods, and equipment should be considered part of the specification.

[0077] It should be noted that like reference numerals and letters refer to like items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.

[0078] It should be noted that, unless there is a conflict, the embodiments of the present disclosure and the features of the embodiments can be combined with each other. To facilitate understanding of the embodiments of the present disclosure, the present disclosure will be described in detail below with reference to the accompanying drawings and in combination with the embodiments. Obviously, the embodiments described are part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments of the present disclosure, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present disclosure.

[0079] Figure 1 A flowchart of a program switching method provided by an embodiment of the present disclosure is shown as follows: Figure 1 As shown, the method specifically includes:

[0080] 101. Receive a target request.

[0081] In the embodiment of the present disclosure, an execution subject of the program switching method (eg, a server, a program switching device, etc.) may receive a target request.

[0082] The target request may be one or more requests sent by the client. For example, the target request may be an HTTP (Hyper Text Transfer Protocol), HTTPS (Hyper Text Transfer Protocol over Secure Socket Layer, a secure HTTP channel), or other request sent by the client.

[0083] In practice, the client and the above execution entity (such as the server) can interact through target requests.

[0084] 102. Send the target request to a first program, so that the first program generates a first request return result of the target request.

[0085] In an embodiment of the present disclosure, the execution entity may send the target request received in step 102 to the first program, so that the first program generates a first request return result of the target request.

[0086] The first program may be used to process the target request, and by processing the target request, the first program may generate a return result of the target request (i.e., the first request return result). In practice, the first program may be a software function, a software framework, a library, etc., which is used to process the target request and generate a return result of the target request by processing the target request.

[0087] The first request return result may be a return result of the target request generated by the first program. In practice, the first request return result may include response data of the first program to the target request. As an example, the first request return result may include at least one of the following: a request result status code (e.g., 200, 404, etc.), the size of the return result, and the content of the return result.

[0088] 103. Copy the target request, and send the copied target request to a second program, so that the second program generates a second request return result of the target request.

[0089] In an embodiment of the present disclosure, the execution entity may copy the target request and send the copied target request to a second program, so that the second program generates a second request return result of the target request.

[0090] The program parameters of the second program are the same as the program parameters of the first program.

[0091] The second program can be used to process the target request, and by processing the target request, the second program can generate a return result of the target request (i.e., the second request return result). In practice, the second program can be a software function, software framework, program library, etc. that is used to process the target request and generate a return result of the target request by processing the target request.

[0092] It should be noted that program parameters are the overall parameters used to call the program, and generally do not include parameters in the function body of the software function within the program. For example, if the first program and the second program are both software functions, then the program parameters can be the parameters in the parameter list of the software function, rather than the parameters in the function body; if the first program and the second program are both software frameworks, then the program parameters can be the interface parameters of the software framework.

[0093] Typically, the second program is different from the first program.

[0094] The second request return result may be a return result of the target request generated by the second program. In practice, the second request return result may include response data of the second program to the target request. As an example, the second request return result may include at least one of the following: a request result status code (e.g., 200, 404, etc.), the size of the return result, and the content of the return result.

[0095] The difference between the second request result and the first request result lies in the different programs used to process the target request. When the first program is used to process the target request, the result generated is the first request result; when the second program is used to process the target request, the result generated is the second request result.

[0096] In some optional implementations of this embodiment, the first program is a program framework, and the second program is a program framework different from the first program.

[0097] It can be understood that in the above optional implementation method, the switching of the program framework within the backend project can be achieved without the front-end being aware of it, thereby reducing or even avoiding the impact of the framework switching on the front-end.

[0098] In some optional implementations of this embodiment, if the number of requests received by the above-mentioned execution entity within a unit time is greater than or equal to a preset number threshold, then the above-mentioned execution entity may further copy the above-mentioned target request, that is, if the number of requests received within a unit time is less than the preset number threshold, then the above-mentioned execution entity may not copy the above-mentioned target request. In this case, the first program will not be switched.

[0099] The unit time may be a time period with a predetermined duration, for example, 24 hours, 7 days, or the like.

[0100] It can be understood that in the above optional implementation, if the number of requests received per unit time is greater than or equal to the preset number threshold, blocking, system crash, etc. may occur. In this case, the first program can be switched to the second program more promptly through subsequent steps, which helps to avoid blocking, system crash, etc. to a certain extent.

[0101] In some optional implementations of this embodiment, if the program delay duration of the above-mentioned first program is greater than or equal to the preset duration threshold, then the above-mentioned execution entity may further copy the above-mentioned target request, that is, if the program delay duration of the above-mentioned first program is less than the preset duration threshold, then the above-mentioned execution entity may not copy the above-mentioned target request. In this case, the first program will not be switched.

[0102] It can be understood that in the above optional implementation, in the event of a request processing delay, the first program can be switched to the second program more promptly through subsequent steps, thereby helping to increase the speed of request processing.

[0103] 104. Determine whether the result returned by the first request matches the result returned by the second request.

[0104] In the embodiment of the present disclosure, the execution entity may determine whether the result returned by the first request matches the result returned by the second request.

[0105] As an example, if the result returned by the first request is the same as the result returned by the second request, it can be determined that the result returned by the first request matches the result returned by the second request; if the result returned by the first request is different from the result returned by the second request, it can be determined that the result returned by the first request does not match the result returned by the second request.

[0106] As another example, when the target request includes multiple requests, or the processing time of the target request exceeds a preset time threshold, if the similarity between the first request return result and the second request return result is greater than or equal to the preset similarity threshold (for example, among the multiple request return results of multiple requests, the number of the first request return result and the second request return result that are the same is greater than or equal to the preset number), it can be determined that the first request return result and the second request return result match; if the similarity between the first request return result and the second request return result is less than the preset similarity threshold, it can be determined that the first request return result and the second request return result do not match.

[0107] In some optional implementations of this embodiment, a first log may be used to associate and store a first request identifier and a request return result generated by the first program (including the first request return result). The first request identifier is the identifier of the target request sent to the first program. A second log may be used to associate and store a second request identifier and a request return result generated by the second program (including the second request return result). The second request identifier is the identifier of the target request sent to the second program.

[0108] On this basis, the execution entity may also determine whether the result returned by the first request matches the result returned by the second request in the following manner:

[0109] First, the first log is parsed to determine the request return result stored in the first log in association with the request identifier of the target request, and the request return result determined from the first log is used as the first request return result.

[0110] Afterwards, the second log is parsed to determine the request return result stored in the second log in association with the request identifier of the target request, and the request return result determined from the second log is used as the second request return result.

[0111] Therefore, if the result returned by the first request is the same as the result returned by the second request, it can be determined that the result returned by the first request matches the result returned by the second request; if the result returned by the first request is different from the result returned by the second request, it can be determined that the result returned by the first request does not match the result returned by the second request.

[0112] It can be understood that in the above optional implementation method, the first request return result and the second request return result can be monitored by real-time parsing of the first log and the second log, and then by judging whether the first request return result and the second request return result are the same, it can be determined whether the first request return result and the second request return result match. This can improve the timeliness of determining whether the first request return result and the second request return result match.

[0113] In some cases of the above optional implementations, the request identifier includes at least one of the following:

[0114] The address of the device (such as the client) sending the target request, the user name corresponding to the device sending the target request, and the request information of the target request (such as the request line, request header, and request body).

[0115] In some optional implementations of this embodiment, the first request return result includes: a first request result status code, the size of the first return result, and the content of the first return result. The first request result status code is the request result status code included in the first request return result, the size of the first return result is the size of the return result included in the first request return result, and the content of the first return result is the return result included in the first request return result. The size of the first return result can be the storage space occupied by the first request return result or the storage space occupied by the content of the first return result.

[0116] The second request return result includes: a second request result status code, the size of the second return result, and the content of the second return result. The second request result status code is the request result status code included in the second request return result, the size of the second return result is the size of the return result included in the second request return result, and the content of the second return result is the return result included in the second request return result. The size of the second return result can be the storage space occupied by the second request return result or the storage space occupied by the content of the second return result.

[0117] On this basis, the above method uses the following method to determine whether the result returned by the first request matches the result returned by the second request:

[0118] If the first request result status code is the same as the second request result status code, and the size of the first return result is the same as the size of the second return result, it is further determined whether the content of the first return result is the same as the content of the second return result.

[0119] If the content of the first return result is the same as the content of the second return result, it is determined that the first request return result and the second request return result match; if the content of the first return result is different from the content of the second return result, it is determined that the first request return result and the second request return result do not match.

[0120] In some cases of the above-mentioned optional implementation methods, if the above-mentioned first request result status code is different from the above-mentioned second request result status code, and / or the size of the above-mentioned first return result is different from the size of the above-mentioned second return result, it is determined that the above-mentioned first request return result and the above-mentioned second request return result do not match.

[0121] It can be understood that in the above-mentioned optional implementation method, only when the above-mentioned first request result status code is the same as the above-mentioned second request result status code, and the size of the above-mentioned first return result is the same as the size of the above-mentioned second return result, is it further determined whether the first request return result and the above-mentioned second request return result match? When the above-mentioned first request result status code is different from the above-mentioned second request result status code, and / or the size of the above-mentioned first return result is different from the size of the above-mentioned second return result, it is directly determined that the first request return result and the second request return result do not match, thereby improving the speed of determining the mismatch between the first request return result and the second request return result.

[0122] 105. If the result returned by the first request matches the result returned by the second request, switch the first program to the second program.

[0123] In an embodiment of the present disclosure, if the result returned by the first request matches the result returned by the second request, the execution entity may switch the first program to the second program, thereby using the second program to replace the first program to process the target request.

[0124] Typically, the first program may be a program used at an earlier time to process the target request, and the second program may be a program used at a later time to process the target request. The terms "earlier time" and "later time" are relative. It is understood that, over time, the programs used to process the target request are: the first program, the first program, the second program, and the second program, respectively.

[0125] Optionally, if the result returned by the first request does not match the result returned by the second request, there is no need to switch the first program to the second program. In addition, if the result returned by the first request does not match the result returned by the second request, the second program may be further modified so that the result returned by the second request of the target request generated by the modified second program matches the result returned by the first request of the target request generated by the first program.

[0126] The program switching method provided by the embodiment of the present disclosure receives a target request, and then sends the target request to a first program so that the first program generates a first request return result of the target request, and then copies the target request and sends the copied target request to a second program so that the second program generates a second request return result of the target request, wherein the program parameters of the second program are the same as the program parameters of the first program, and then determines whether the first request return result and the second request return result match, and if the first request return result and the second request return result match, the first program is switched to the second program. By using this method, when the first request return result returned by the first program matches the second program return result returned by the second program, the first program can be switched to the second program with the same program parameters as the first program, thereby realizing program switching within the background project without the front-end perception, thereby reducing or even avoiding the impact of program switching on the front-end.

[0127] Figure 2 A flowchart of another program switching method provided by an embodiment of the present disclosure is shown as follows: Figure 2 As shown, the method specifically includes:

[0128] 201. Receive a target request.

[0129] In the embodiment of the present disclosure, the execution subject of the program switching method (eg, a server, a terminal device, a program switching apparatus, etc.) may receive a target request and then execute step 202 .

[0130] 202. Send the target request to a first program, so that the first program generates a first request return result of the target request.

[0131] In the embodiment of the present disclosure, the execution subject may send the target request to the first program, so that the first program generates a first request return result of the target request. Thereafter, step 203 is executed.

[0132] 203. Copy the target request, and send the copied target request to a second program, so that the second program generates a second request return result of the target request.

[0133] In the embodiment of the present disclosure, the execution subject may copy the target request and send the copied target request to the second program, so that the second program generates a second request return result of the target request.

[0134] 204. Use a first log to associate and store the first request identifier and the request return result generated by the first program.

[0135] In the embodiment of the present disclosure, the execution entity may use a first log to associate and store the first request identifier with the request return result generated by the first program.

[0136] The first request identifier is an identifier of a target request sent to the first program.

[0137] 205. Use a second log to associate and store the second request identifier and the request return result generated by the second program.

[0138] In the embodiment of the present disclosure, the execution entity may use a second log to associate and store the second request identifier with the request return result generated by the second program.

[0139] The second request identifier is an identifier of a target request sent to the second program.

[0140] 206. Parse the first log to determine the request return result stored in the first log in association with the request identifier of the target request, and use the request return result determined from the first log as the first request return result.

[0141] In the disclosed embodiment, the execution entity may parse the first log to determine the request return result stored in the first log in association with the request identifier of the target request, and use the request return result determined from the first log as the first request return result. Thereafter, step 207 is executed.

[0142] 207. Parse the second log to determine the request return result stored in the second log in association with the request identifier of the target request, and use the request return result determined from the second log as the second request return result.

[0143] In the disclosed embodiment, the execution entity may parse the second log to determine the request return result stored in the second log in association with the request identifier of the target request, and use the request return result determined from the second log as the second request return result. Thereafter, step 208 is executed.

[0144] 208. Determine whether the result returned by the first request is the same as the result returned by the second request.

[0145] In the embodiment of the present disclosure, the execution entity may determine whether the result returned by the first request is the same as the result returned by the second request, and then, if not, execute step 209; if so, execute step 210.

[0146] 209. Determine that the result returned by the first request does not match the result returned by the second request.

[0147] In an embodiment of the present disclosure, the execution entity may determine that the result returned by the first request does not match the result returned by the second request.

[0148] 210. Determine whether the result returned by the first request matches the result returned by the second request.

[0149] In the embodiment of the present disclosure, the execution entity may determine that the result returned by the first request matches the result returned by the second request, and then execute step 211 .

[0150] 211. Switch the first program to the second program.

[0151] In the embodiment of the present disclosure, the execution entity may switch the first program to the second program.

[0152] In the embodiment of the present disclosure, steps 201 , 202 , and 203 are substantially the same as the above-mentioned steps 101 , 102 , and 103 , and are not described again here.

[0153] The program switching method provided by the embodiment of the present disclosure monitors the first request return result and the second request return result by real-time parsing of the first log and the second log, and then determines whether the first request return result and the second request return result match by judging whether the first request return result and the second request return result are the same. This can improve the timeliness of determining whether the first request return result and the second request return result match.

[0154] Figure 3A This is a flowchart of another program switching method provided by an embodiment of the present disclosure. This method can be applied to program switching scenarios such as software functions, software frameworks, and program libraries. This method can be applied to electronic devices such as servers.

[0155] Specifically, if Figure 3A As shown, the method specifically includes:

[0156] 301. Receive a target request. Then, execute step 302.

[0157] 302. Send the target request to the first program, so that the first program generates a first request return result of the target request. Then, execute step 303.

[0158] 303. Copy the target request and send the copied target request to the second program, so that the second program generates a second request return result of the target request. Then, execute step 304.

[0159] 304. Determine whether the status code of the first request result is the same as the status code of the second request result, and whether the size of the first returned result is the same as the size of the second returned result. If so, proceed to step 305.

[0160] 305. Determine whether the content of the first returned result is the same as the content of the second returned result. If so, proceed to step 307; if not, proceed to step 306.

[0161] 306. Determine that the result returned by the first request does not match the result returned by the second request.

[0162] 307. Determine whether the result returned by the first request matches the result returned by the second request. Then, execute step 308.

[0163] 308. Switch the first program to the second program.

[0164] In the embodiment of the present disclosure, steps 301 , 302 , and 303 are substantially the same as the above-mentioned steps 101 , 102 , and 103 , and are not described again here.

[0165] As an example, here we take the first program as the currently used software framework (hereinafter referred to as the old framework) and the second program as the software framework used to replace the first program (hereinafter referred to as the new framework) as an example to illustrate this embodiment. Among them, the old framework has two technology stacks and three frameworks, namely the gin and gorilla frameworks of golang (a programming language) and the celetics framework of python (another programming language). It is planned to migrate to the JAVA (another programming language) technology stack and re-implement it using the springboot and dubbo frameworks. In this context, the business cannot be upgraded as a whole, and the front-end and test resources are limited, which is not enough to support the iteration of the background switching according to the conventional method. Therefore, the following method can be used to perform the above steps:

[0166] like Figure 3BAs shown, when the target request enters the Nginx front-end of the above-mentioned execution entity, it is forwarded to the old framework according to the original link. After the result is returned (that is, the result returned by the first request), the return result (that is, the result returned by the first request) is saved to the local first log; at the same time, a copy of the target request is forwarded to the new framework, and after the result is returned (that is, the result returned by the second request), the return result (that is, the result returned by the second request) is saved to the local second log.

[0167] For example, the detailed data structure can be as follows:

[0168] '$remote_addr\t$remote_user\t$request\t$status\t$body_bytes_sent\t$response_body'.

[0169] Where $remote_addr represents the address of the device sending the target request, also known as the remote address; $remote_user represents the username corresponding to the device sending the target request, also known as the remote username; request represents the request information of the target request (such as the request line, request header, and request body); body_bytes_sent represents the size of the first return result, or the size of the second return result; $response_body represents the content of the first return result, or the content of the second return result; \t represents a horizontal tab (jump to the next TAB (keyboard tab) position). \t is an integer multiple of the length of the current string to 8.

[0170] Next, the first and second logs are scanned separately. Two $response_body entries with the same $remote_addr\t$remote_user\t$request\t$status\t$body_bytes_sent values ​​are found in both files. The intermediate results of the two key-value structures are extracted and compared. Verification passes if they match. The key is $remote_addr + $remote_user + $request, and the value is body_bytes_sent + $response_body. The "+" operator is used to concatenate strings.

[0171] Finally, if the verification is passed, the target request received subsequently is forwarded to the new framework, and the content of the first return result generated by the new framework is returned to the front end (ie, the client), thereby completing the switch between the old and new frameworks.

[0172] Specifically, the following steps may be included:

[0173] Step 1: Modify the Nginx.conf configuration and add the log format data structure.

[0174] Step 2: Modify the site log configuration and process the result returned by the first request.

[0175] Specifically, you can modify the site log configuration in the following ways:

[0176] First, turn on the switch for reading the request data body and set it to the on state.

[0177] After that, define the return body content and set the initial value to empty characters.

[0178] Then, open the Lua language script for custom request content.

[0179] Subsequently, the return body data is defined to obtain the old interface $response_body (ie, the content of the first return result).

[0180] In the prior art, the gateway typically does not output the content of the first return result. However, by including the content of the first return result in the log output, it is possible to perform an offline comparison and confirmation of the results directly based on the log data in the subsequent verification phase. In other words, the old interface $response_body (i.e., the content of the first return result) is compared with the new interface $response_body (i.e., the content of the second return result) to see if they are equal.

[0181] Step 3: Configure the mirroring method within the site.

[0182] Step 4: Add an internal site to forward target requests to the new framework.

[0183] The function of the newly added site is to forward the received target request to the new framework.

[0184] Here, in addition to the above-mentioned method of adding a new internal site to realize the function of forwarding the received target request to the new framework, other methods can also be used to realize this function, for example, it can also be realized by modifying the code of the existing site.

[0185] Step 5: Add mirroring processing to the old framework to trigger replication.

[0186] Step 6: Obtain the second log and parse it. Use the GetLine method and the StringSplit method to obtain $remote_addr, $remote_user, $request, $status, $body_bytes_sent, and $response_body respectively, and use $remote_addr+$remote_user+$request as the key to create an index.

[0187] Step 7: Parse the first log and use the GetLine method and StringSplit method to obtain $remote_addr, $remote_user, $request, $status, $body_bytes_sent, and $response_bod respectively, and use $remote_addr+$remote_user+$request as the key to create an index.

[0188] Step 8: traverse the Key index generated in step 6, and extract the old interface $response_body and the new interface $response_body respectively and parse them according to step 9 below.

[0189] Step 9: Use the JSON.parseObject method to parse $response_body and compare whether the two JsonObjects are equal.

[0190] Step 10: After verification, directly switch traffic to the new framework (that is, send subsequent target requests received to the new framework), and cancel the mirroring process in the old framework, thereby canceling the replication.

[0191] In the above example, the interface parameters and returned results of the new and old frameworks must be consistent. Only in this way can the front-end seamlessly switch between frameworks. Furthermore, supported changes include: interface names, microservice business implementation, microservice deployment, and links. Beyond the interface parameters and returned results, other content between the new and old frameworks can differ.

[0192] The above example replicates traffic from the old framework, imports it into the new framework, and compares the results returned by the new framework with those from the old framework in batches to identify risks. This allows framework switching to be completed within the backend project, without the frontend being aware of it. This enriches testing methods by simultaneously importing live traffic for comparison and verification, in addition to regular testing. Furthermore, validating the new framework through real-time traffic replication improves testing efficiency.

[0193] The program switching method provided by the embodiment of the present disclosure further determines whether the first request return result and the second request return result match only when the first request result status code is the same as the second request result status code and the size of the first return result is the same as the size of the second return result. When the first request result status code is different from the second request result status code and / or the size of the first return result is different from the size of the second return result, it is directly determined that the first request return result and the second request return result do not match, thereby improving the speed of determining the mismatch between the first request return result and the second request return result.

[0194] Figure 4 A schematic diagram of a program switching device provided in an embodiment of the present disclosure, specifically comprising:

[0195] a receiving unit configured to receive a target request;

[0196] a sending unit configured to send the target request to a first program, so that the first program generates a first request return result of the target request;

[0197] a copying unit configured to copy the target request and send the copied target request to a second program, so that the second program generates a second request return result of the target request, wherein program parameters of the second program are the same as those of the first program;

[0198] A first determining unit is configured to determine whether the result returned by the first request matches the result returned by the second request;

[0199] The switching unit is configured to switch the first program to the second program if the result returned by the first request matches the result returned by the second request.

[0200] Optionally, in the apparatus of any embodiment of the present disclosure, a first log is used to associate and store a first request identifier and a request return result generated by the first program, wherein the first request identifier is an identifier of a target request sent to the first program; a second log is used to associate and store a second request identifier and a request return result generated by the second program, wherein the second request identifier is an identifier of a target request sent to the second program; and

[0201] The above device also includes:

[0202] a first parsing unit configured to parse the first log to determine a request return result stored in the first log in association with the request identifier of the target request, and use the request return result determined from the first log as the first request return result;

[0203] a second parsing unit configured to parse the second log to determine a request return result stored in the second log in association with the request identifier of the target request, and use the request return result determined from the second log as a second request return result;

[0204] a second determining unit configured to determine that the result returned by the first request matches the result returned by the second request if the result returned by the first request is the same as the result returned by the second request;

[0205] The third determining unit is configured to determine that the result returned by the first request and the result returned by the second request do not match if the result returned by the first request and the result returned by the second request are different.

[0206] Optionally, in the device of any embodiment of the present disclosure, the first request return result includes: a first request result status code, a size of the first return result, and content of the first return result; the second request return result includes: a second request result status code, a size of the second return result, and content of the second return result; and

[0207] The above device also includes:

[0208] a fourth determining unit configured to, if the first request result status code is the same as the second request result status code, and the size of the first returned result is the same as the size of the second returned result, determine whether the content of the first returned result is the same as the content of the second returned result;

[0209] a fifth determining unit configured to determine that the first request return result and the second request return result match if the content of the first return result is the same as the content of the second return result;

[0210] The sixth determining unit is configured to determine that the first request return result and the second request return result do not match if the content of the first return result is different from the content of the second return result.

[0211] Optionally, in the device of any embodiment of the present disclosure, the device further includes:

[0212] The seventh determination unit is configured to determine that the first request return result and the second request return result do not match if the first request result status code is different from the second request result status code, and / or the size of the first return result is different from the size of the second return result.

[0213] Optionally, in the device of any embodiment of the present disclosure, the request identifier includes at least one of the following:

[0214] The address of the device that sends the target request, the user name corresponding to the device that sends the target request, and the request information of the target request.

[0215] Optionally, in the apparatus of any embodiment of the present disclosure, the copying unit is further configured to:

[0216] If the number of requests received per unit time is greater than or equal to a preset number threshold, then copy the target request; and / or

[0217] If the program delay duration of the first program is greater than or equal to a preset duration threshold, the target request is copied.

[0218] Optionally, in the device of any embodiment of the present disclosure, the first program is a program framework, and the second program is a program framework different from the first program.

[0219] The program switching device provided in this embodiment can be as follows Figure 4 The program switching device shown in , can execute as follows Figure 1-3B All steps of the program switching method in the program switching method are implemented Figure 1-3B For technical effects of the program switching method shown, please refer to Figure 1-3B For the sake of brevity, the relevant description will not be repeated here.

[0220] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure is shown. Figure 5 The electronic device 500 shown includes: at least one processor 501, a memory 502, at least one network interface 504 and another user interface 503. The various components in the electronic device 500 are coupled together via a bus system 505. It is understood that the bus system 505 is used to achieve connection and communication between these components. In addition to including a data bus, the bus system 505 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, the bus system 505 is not shown in FIG. Figure 5 Various buses are labeled as bus system 505.

[0221] The user interface 503 may include a display, a keyboard, or a pointing device (eg, a mouse, a trackball, a touchpad, or a touch screen).

[0222] It is understood that the memory 502 in the embodiment of the present disclosure may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link DRAM (SLDRAM), and direct RAM bus random access memory (DRRAM). The memory 502 described herein is intended to include, but is not limited to, these and any other suitable types of memory.

[0223] In some embodiments, the memory 502 stores the following elements, executable units, or data structures, or a subset thereof, or an extended set thereof: an operating system 5021 and application programs 5022 .

[0224] The operating system 5021 includes various system programs, such as a framework layer, a core library layer, and a driver layer, for implementing various basic services and handling hardware-based tasks. Application programs 5022 include various application programs, such as a media player and a browser, for implementing various application services. Programs implementing the methods of the embodiments of the present disclosure may be included in application programs 5022.

[0225] In the embodiment of the present disclosure, by calling the program or instructions stored in the memory 502, specifically, the program or instructions stored in the application 5022, the processor 501 is configured to execute the method steps provided in each method embodiment, for example, including:

[0226] Receive target request;

[0227] Sending the target request to the first program so that the first program generates a first request return result of the target request;

[0228] Copying the target request, and sending the copied target request to a second program, so that the second program generates a second request return result of the target request, wherein program parameters of the second program are the same as those of the first program;

[0229] Determine whether the result returned by the first request matches the result returned by the second request;

[0230] If the result returned by the first request matches the result returned by the second request, the first program is switched to the second program.

[0231] Optionally, in the method of any embodiment of the present disclosure, a first log is used to associate and store a first request identifier and a request return result generated by the first program, wherein the first request identifier is an identifier of a target request sent to the first program; a second log is used to associate and store a second request identifier and a request return result generated by the second program, wherein the second request identifier is an identifier of a target request sent to the second program; and

[0232] The above method uses the following method to determine whether the result returned by the first request matches the result returned by the second request:

[0233] Parsing the first log to determine a request return result stored in the first log in association with the request identifier of the target request, and using the request return result determined from the first log as the first request return result;

[0234] Parsing the second log to determine the request return result stored in the second log in association with the request identifier of the target request, and using the request return result determined from the second log as the second request return result;

[0235] If the result returned by the first request is the same as the result returned by the second request, then determining that the result returned by the first request matches the result returned by the second request;

[0236] If the result returned by the first request is different from the result returned by the second request, it is determined that the result returned by the first request is not matched with the result returned by the second request.

[0237] Optionally, in the method of any embodiment of the present disclosure, the first request return result includes: a first request result status code, a size of the first return result, and content of the first return result; the second request return result includes: a second request result status code, a size of the second return result, and content of the second return result; and

[0238] The above method uses the following method to determine whether the result returned by the first request matches the result returned by the second request:

[0239] If the first request result status code is the same as the second request result status code, and the size of the first returned result is the same as the size of the second returned result, determining whether the content of the first returned result is the same as the content of the second returned result;

[0240] If the content of the first returned result is the same as the content of the second returned result, then determining that the first request returned result and the second request returned result match;

[0241] If the content of the first returned result is different from the content of the second returned result, it is determined that the first request returned result and the second request returned result do not match.

[0242] Optionally, in the method of any embodiment of the present disclosure, the method further includes:

[0243] If the first request result status code is different from the second request result status code, and / or the size of the first return result is different from the size of the second return result, it is determined that the first request return result and the second request return result do not match.

[0244] Optionally, in the method of any embodiment of the present disclosure, the request identifier includes at least one of the following:

[0245] The address of the device that sends the target request, the user name corresponding to the device that sends the target request, and the request information of the target request.

[0246] Optionally, in the method of any embodiment of the present disclosure, the copying of the target request includes:

[0247] If the number of requests received per unit time is greater than or equal to a preset number threshold, then copy the target request; and / or

[0248] If the program delay duration of the first program is greater than or equal to a preset duration threshold, the target request is copied.

[0249] Optionally, in the method of any embodiment of the present disclosure, the first program is a program framework, and the second program is a program framework different from the first program.

[0250] The methods disclosed in the above embodiments of the present disclosure can be applied to or implemented by processor 501. Processor 501 may be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by hardware integrated logic circuits in processor 501 or by software instructions. The above processor 501 may be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The methods, steps, and logic block diagrams disclosed in the embodiments of the present disclosure can be implemented or executed. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in conjunction with the embodiments of the present disclosure can be directly implemented and executed by a hardware decoding processor, or by a combination of hardware and software units in the decoding processor. The software units can be located in a storage medium well-known in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, etc. The storage medium is located in the memory 502 , and the processor 501 reads the information in the memory 502 and completes the steps of the above method in combination with its hardware.

[0251] It is understood that the embodiments described herein may be implemented using hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit may be implemented in one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers, microprocessors, or other electronic units or combinations thereof for performing the above-mentioned functions of the present disclosure.

[0252] For software implementation, the techniques described above can be implemented by a unit that performs the functions described above. The software code can be stored in a memory and executed by a processor. The memory can be implemented in the processor or external to the processor.

[0253] The electronic device provided in this embodiment may be Figure 5 The electronic device shown in FIG. 1 can perform the following operations: Figure 1-3B All steps of the program switching method in the program switching method are implemented Figure 1-3B For technical effects of the program switching method shown, please refer to Figure 1-3B The relevant description of 1-31-31-3 is concise and will not be repeated here.

[0254] The present disclosure also provides a storage medium (computer-readable storage medium). The storage medium stores one or more programs. The storage medium may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as read-only memory, flash memory, hard disk, or solid-state drive; and the memory may also include a combination of the aforementioned types of memory.

[0255] When one or more programs in the storage medium can be executed by one or more processors, the program switching method executed on the electronic device side can be implemented.

[0256] The processor is configured to execute the program switching program stored in the memory to implement the following steps of the program switching method executed on the electronic device side:

[0257] Receive target request;

[0258] Sending the target request to the first program so that the first program generates a first request return result of the target request;

[0259] Copying the target request, and sending the copied target request to a second program, so that the second program generates a second request return result of the target request, wherein program parameters of the second program are the same as those of the first program;

[0260] Determine whether the result returned by the first request matches the result returned by the second request;

[0261] If the result returned by the first request matches the result returned by the second request, the first program is switched to the second program.

[0262] Optionally, in the method of any embodiment of the present disclosure, a first log is used to associate and store a first request identifier and a request return result generated by the first program, wherein the first request identifier is an identifier of a target request sent to the first program; a second log is used to associate and store a second request identifier and a request return result generated by the second program, wherein the second request identifier is an identifier of a target request sent to the second program; and

[0263] The above method uses the following method to determine whether the result returned by the first request matches the result returned by the second request:

[0264] Parsing the first log to determine a request return result stored in the first log in association with the request identifier of the target request, and using the request return result determined from the first log as the first request return result;

[0265] Parsing the second log to determine the request return result stored in the second log in association with the request identifier of the target request, and using the request return result determined from the second log as the second request return result;

[0266] If the result returned by the first request is the same as the result returned by the second request, then determining that the result returned by the first request matches the result returned by the second request;

[0267] If the result returned by the first request is different from the result returned by the second request, it is determined that the result returned by the first request is not matched with the result returned by the second request.

[0268] Optionally, in the method of any embodiment of the present disclosure, the first request return result includes: a first request result status code, a size of the first return result, and content of the first return result; the second request return result includes: a second request result status code, a size of the second return result, and content of the second return result; and

[0269] The above method uses the following method to determine whether the result returned by the first request matches the result returned by the second request:

[0270] If the first request result status code is the same as the second request result status code, and the size of the first returned result is the same as the size of the second returned result, determining whether the content of the first returned result is the same as the content of the second returned result;

[0271] If the content of the first returned result is the same as the content of the second returned result, then determining that the first request returned result and the second request returned result match;

[0272] If the content of the first returned result is different from the content of the second returned result, it is determined that the first request returned result and the second request returned result do not match.

[0273] Optionally, in the method of any embodiment of the present disclosure, the method further includes:

[0274] If the first request result status code is different from the second request result status code, and / or the size of the first return result is different from the size of the second return result, it is determined that the first request return result and the second request return result do not match.

[0275] Optionally, in the method of any embodiment of the present disclosure, the request identifier includes at least one of the following:

[0276] The address of the device that sends the target request, the user name corresponding to the device that sends the target request, and the request information of the target request.

[0277] Optionally, in the method of any embodiment of the present disclosure, the copying of the target request includes:

[0278] If the number of requests received per unit time is greater than or equal to a preset number threshold, then copy the target request; and / or

[0279] If the program delay duration of the first program is greater than or equal to a preset duration threshold, the target request is copied.

[0280] Optionally, in the method of any embodiment of the present disclosure, the first program is a program framework, and the second program is a program framework different from the first program.

[0281] Professionals should also be further aware that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this disclosure.

[0282] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein may be implemented using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0283] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present disclosure in detail. It should be understood that the above description is only a specific implementation method of the present disclosure and is not intended to limit the scope of protection of the present disclosure. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present disclosure should be included in the scope of protection of the present disclosure.

Claims

1. A program switching method, characterized in that: The method comprises: Receive target request; Sending the target request to a first program, so that the first program generates a first request return result of the target request; Copying the target request, and sending the copied target request to a second program, so that the second program generates a second request return result of the target request, wherein program parameters of the second program are the same as program parameters of the first program; Determine whether the first request return result and the second request return result match, wherein the first request return result includes: a first request result status code, the size of the first return result, and the content of the first return result; the second request return result includes: a second request result status code, the size of the second return result, and the content of the second return result; specifically including: if the first request result status code is the same as the second request result status code, and the size of the first return result is the same as the size of the second return result, then determine whether the content of the first return result is the same as the content of the second return result; if the content of the first return result is the same as the content of the second return result, then determine that the first request return result and the second request return result match; if the content of the first return result is different from the content of the second return result, then determine that the first request return result and the second request return result do not match; or, Using a first log to associate and store a first request identifier and a request return result generated by the first program, wherein the first request identifier is an identifier of a target request sent to the first program; using a second log to associate and store a second request identifier and a request return result generated by the second program, wherein the second request identifier is an identifier of a target request sent to the second program; and The method determines whether the first request return result and the second request return result match in the following manner: parsing the first log to determine the request return result stored in association with the request identifier of the target request in the first log, and using the request return result determined from the first log as the first request return result; parsing the second log to determine the request return result stored in association with the request identifier of the target request in the second log, and using the request return result determined from the second log as the second request return result; if the first request return result and the second request return result are the same, determining that the first request return result and the second request return result match; if the first request return result and the second request return result are different, determining that the first request return result and the second request return result do not match; If the result returned by the first request matches the result returned by the second request, the first program is switched to the second program, wherein the first program is a program framework and the second program is a program framework different from the first program.

2. The method according to claim 1, characterized in that The method further comprises: If the first request result status code is different from the second request result status code, and / or the size of the first return result is different from the size of the second return result, it is determined that the first request return result and the second request return result do not match.

3. The method according to claim 1, characterized in that The request identifier includes at least one of the following: The address of the device sending the target request, the user name corresponding to the device sending the target request, and the request information of the target request.

4. The method according to any one of claims 1 to 3, characterized in that The copying of the target request comprises: If the number of requests received per unit time is greater than or equal to a preset number threshold, copying the target request; and / or If the program delay duration of the first program is greater than or equal to a preset duration threshold, the target request is copied.

5. A program switching device, characterized in that: The device comprises: a receiving unit configured to receive a target request; a sending unit, configured to send the target request to a first program, so that the first program generates a first request return result of the target request; a copying unit configured to copy the target request and send the copied target request to a second program, so that the second program generates a second request return result of the target request, wherein program parameters of the second program are the same as those of the first program; A first determining unit is configured to determine whether the first request return result and the second request return result match, wherein the first request return result includes: a first request result status code, a first return result size, and a first return result content; the second request return result includes: a second request result status code, a second return result size, and a second return result content; specifically including: if the first request result status code is the same as the second request result status code, and the size of the first return result is the same as the size of the second return result, determining whether the content of the first return result is the same as the content of the second return result; if the content of the first return result is the same as the content of the second return result, determining that the first request return result and the second request return result match; if the content of the first return result is different from the content of the second return result, determining that the first request return result and the second request return result do not match; or, Using a first log to associate and store a first request identifier and a request return result generated by the first program, wherein the first request identifier is an identifier of a target request sent to the first program; using a second log to associate and store a second request identifier and a request return result generated by the second program, wherein the second request identifier is an identifier of a target request sent to the second program; and Determine whether the first request return result and the second request return result match in the following manner: parse the first log to determine the request return result stored in association with the request identifier of the target request in the first log, and use the request return result determined from the first log as the first request return result; parse the second log to determine the request return result stored in association with the request identifier of the target request in the second log, and use the request return result determined from the second log as the second request return result; if the first request return result and the second request return result are the same, determine that the first request return result and the second request return result match; if the first request return result and the second request return result are different, determine that the first request return result and the second request return result do not match; The switching unit is configured to switch the first program to the second program if the result returned by the first request matches the result returned by the second request, wherein the first program is a program framework and the second program is a program framework different from the first program.

6. An electronic device, characterized in that: include: memory for storing computer programs; A processor is configured to execute a computer program stored in the memory, and when the computer program is executed, implements the method described in any one of claims 1 to 4 above.

7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.

Citation Information

Patent Citations

  • State switching method and device, storage medium and electronic device

    CN109731334A

  • Request processing method and device, electronic equipment and storage medium

    CN114006892A