CN-121996362-A - Request processing method and device, storage medium and electronic equipment
Abstract
The application discloses a request processing method, a device, a storage medium and electronic equipment, belonging to the technical field of computers, wherein the method is applied to a decision engine for synchronously running a main strategy and a running accompanying strategy in a production environment, and comprises the steps of generating a decision acquisition request based on a decision request mark, sending the decision acquisition request to a head component of a first component link and a head component of a second component link, triggering the first component link to carry out the main strategy decision according to a topology corresponding to the main strategy until a strategy result is obtained and the second component link carries out the running accompanying strategy decision according to the topology corresponding to the running accompanying strategy; and executing a data acquisition operation based on the target data request identifier to obtain target data for generating a decision result, wherein the target data request identifier generation operation and the data acquisition operation are idempotent operations. The application ensures idempotency when multiple requests are made for the same data.
Inventors
- LIU YUXIANG
- DING FENGXIANG
- WANG KEMIAO
- CHEN BO
- LI CHAO
Assignees
- 腾讯科技(深圳)有限公司
Dates
- Publication Date
- 20260508
- Application Date
- 20241107
Claims (12)
- 1. A method of request processing, the method being applied to a decision engine that runs a master policy and a companion policy synchronously in a production environment, the method comprising: Under the condition that a target request sent by a client is received, a corresponding decision request identifier is generated, and the target request is used for triggering the decision engine to output a corresponding decision result; Generating a decision acquisition request based on the decision request identifier, sending the decision acquisition request to a head component of a first component link, and triggering the first component link to carry out decision based on the main policy according to the topology corresponding to the main policy until a decision result is output by the tail of the first component link; The decision acquisition request is sent to a head component in a second component link, and the second component link is triggered to carry out decision based on the running strategy according to the topology corresponding to the running strategy; Executing a data acquisition operation based on the target data request identifier to obtain target data for generating a decision result, wherein the target component is a component for requesting data in the first component link or the second component link, and the target data request identifier generation operation and the data acquisition operation are idempotent operations; And feeding back the decision result to the client.
- 2. The method of claim 1, wherein the target component is configured to send a data acquisition request to a third party service or wherein the target component is configured to send a data acquisition request for internal data to the decision engine itself.
- 3. The method according to claim 1 or 2, wherein performing a data acquisition operation based on the target data request identity results in target data for generating a decision result, comprising: Generating a corresponding data acquisition request based on the target data request identifier; sending out a locking request based on the data acquisition request; Under the condition that the lock is successfully acquired within a first preset time, inquiring a cache based on the target data request identifier, wherein a cache record in the cache comprises the request identifier and corresponding response data; And under the condition that a cache record comprising the target data request identifier exists in the cache, taking response data in the cache record as response data of the data acquisition request, wherein the response data is the target data, and performing lock releasing processing on the data acquisition request.
- 4. The method of claim 3, wherein performing a data acquisition operation based on the target data request identification results in target data for generating a decision result, further comprising: transmitting the data acquisition request to a third party service or the decision engine when a cache record comprising the target data request identifier does not exist in the cache; under the condition that the response data fed back by the third party service or the decision engine is obtained, the response data is used as the target data, a target cache record is generated based on the target data request identification and the response data, and the target cache record is stored in the cache; and carrying out lock releasing processing on the data acquisition request.
- 5. The method of claim 4, wherein prior to generating a target cache record based on the target data request identification and the response data, the method further comprises: querying the cache based on the target data request identification; And deleting the cache record of the target data request identifier under the condition that the cache record of the target data request identifier exists in the cache.
- 6. The method of claim 3, wherein performing a data acquisition operation based on the target data request identification results in target data for generating a decision result, further comprising: And under the condition that the lock is not successfully acquired within the first preset time, re-executing the data acquisition operation based on the target data request identifier at intervals of a second preset time to obtain target data for generating a decision result.
- 7. A method according to claim 3, wherein said issuing a locking request based on said data acquisition request comprises: checking the lock state of the data acquisition request within a third preset time, wherein the third preset time is smaller than the first preset time; If the lock state indicates that the locking is not successful, adding the data acquisition request into a synchronous block, wherein the synchronous block is used for checking the lock state of the data acquisition request again and ensuring that the data acquisition request is not locked by a component other than the synchronous block; And if the data acquisition request is not locked successfully in the synchronous block, locking the data acquisition request.
- 8. The method according to claim 1 or 2, wherein the preset data is context data corresponding to the decision acquisition request, the preset data comprises the decision request identifier, and the preset data further comprises at least one of data representing account information, a data type of the data to be requested, and a data content and a data range of the data to be requested.
- 9. A request processing apparatus, the apparatus being applied to a decision engine that runs a master policy and a companion policy synchronously in a production environment, the apparatus comprising: The target request acquisition module is used for generating a corresponding decision request identifier under the condition of receiving a target request sent by the client, wherein the target request is used for triggering the decision engine to output a corresponding decision result; The decision engine executing module is used for executing the following operations: Generating a decision acquisition request based on the decision request identifier, sending the decision acquisition request to a head component of a first component link, and triggering the first component link to carry out decision based on the main policy according to the topology corresponding to the main policy until a decision result is output by the tail of the first component link; The decision acquisition request is sent to a head component in a second component link, and the second component link is triggered to carry out decision based on the running strategy according to the topology corresponding to the running strategy; Executing a data acquisition operation based on the target data request identifier to obtain target data for generating a decision result, wherein the target component is a component for requesting data in the first component link or the second component link, and the target data request identifier generation operation and the data acquisition operation are idempotent operations; And feeding back the decision result to the client.
- 10. A computer device comprising a processor and a memory having stored therein at least one instruction, at least one program, code set or instruction set that is loaded and executed by the processor to implement the request processing method of any of claims 1 to 8.
- 11. A computer readable storage medium having stored therein at least one instruction, at least one program, code set, or instruction set, the at least one instruction, the at least one program, the code set, or instruction set being loaded and executed by a processor to implement the request processing method of any of claims 1 to 8.
- 12. A computer program product, characterized in that the computer program product comprises computer instructions, which are read by a processor of a computer device, which computer instructions are executed by the processor of the computer device to implement the request processing method according to any of claims 1 to 8.
Description
Request processing method and device, storage medium and electronic equipment Technical Field The present application relates to the field of computer technologies, and in particular, to a method and an apparatus for processing a request, a storage medium, and an electronic device. Background A decision engine is a software component or system that implements automated decisions through logic and rules. The strategy used by the decision engine to actually execute the automated decision is the main strategy, and the strategy operated by the decision engine but not outputting the automated decision result is the accompanying strategy. The related art generally sets a test environment similar to the production environment in which the main strategy is located for deploying the companion strategy, and needs to ensure that the test environment is highly identical to the production environment. However, the test environment may not completely simulate the production environment, resulting in inaccuracy of the running result or an increase in running analysis cost. In addition, the related art generally cannot operate the main strategy and the running strategy synchronously, but can only operate sequentially, thereby resulting in an increase in running time cost. In addition, when executing the main policy or the accompany policy, the decision engine may request data from the third party service, and the main policy and the accompany policy may request the same data, which creates a problem of multiple requests for the same data, multiple requests for the same data create multiple billing, and an idempotent problem. Disclosure of Invention The embodiment of the application provides a request processing method, a request processing device, a storage medium and electronic equipment, which can avoid the cost expense caused by independently constructing a test environment for a running accompanying strategy, avoid the time loss caused by a running accompanying method in which a main strategy and the running accompanying strategy run successively, and simultaneously avoid the repeated charging problem caused by the running accompanying strategy, and ensure the idempotent of carrying out repeated requests on the same data. According to an aspect of an embodiment of the present application, there is provided a request processing method applied to a decision engine that synchronously runs a main policy and a run-along policy in a production environment, the method including: Under the condition that a target request sent by a client is received, a corresponding decision request identifier is generated, and the target request is used for triggering the decision engine to output a corresponding decision result; Generating a decision acquisition request based on the decision request identifier, sending the decision acquisition request to a head component of a first component link, and triggering the first component link to carry out decision based on the main policy according to the topology corresponding to the main policy until a decision result is output by the tail of the first component link; The decision acquisition request is sent to a head component in a second component link, and the second component link is triggered to carry out decision based on the running strategy according to the topology corresponding to the running strategy; Executing a data acquisition operation based on the target data request identifier to obtain target data for generating a decision result, wherein the target component is a component for requesting data in the first component link or the second component link, and the target data request identifier generation operation and the data acquisition operation are idempotent operations; And feeding back the decision result to the client. According to an aspect of an embodiment of the present application, there is provided a request processing apparatus applied to a decision engine that synchronously runs a main policy and a run-along policy in a production environment, the apparatus comprising: The target request acquisition module is used for generating a corresponding decision request identifier under the condition of receiving a target request sent by the client, wherein the target request is used for triggering the decision engine to output a corresponding decision result; The decision engine executing module is used for executing the following operations: Generating a decision acquisition request based on the decision request identifier, sending the decision acquisition request to a head component of a first component link, and triggering the first component link to carry out decision based on the main policy according to the topology corresponding to the main policy until a decision result is output by the tail of the first component link; The decision acquisition request is sent to a head component in a second component link, and the second component link is triggered to carry out decisi