CN117014513A - Data request method and device, electronic equipment and storage medium - Google Patents
Data request method and device, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN117014513A CN117014513A CN202311122388.8A CN202311122388A CN117014513A CN 117014513 A CN117014513 A CN 117014513A CN 202311122388 A CN202311122388 A CN 202311122388A CN 117014513 A CN117014513 A CN 117014513A
- Authority
- CN
- China
- Prior art keywords
- target
- retransmission
- request information
- strategy
- acquisition request
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 51
- 230000004044 response Effects 0.000 claims description 28
- 238000004590 computer program Methods 0.000 claims description 17
- 230000002159 abnormal effect Effects 0.000 claims description 8
- 238000004891 communication Methods 0.000 description 6
- 230000005540 biological transmission Effects 0.000 description 5
- 230000005856 abnormality Effects 0.000 description 4
- 238000010586 diagram Methods 0.000 description 3
- 238000005516 engineering process Methods 0.000 description 2
- 230000006870 function Effects 0.000 description 2
- 230000000977 initiatory effect Effects 0.000 description 2
- 230000002411 adverse Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000003247 decreasing effect Effects 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 239000002699 waste material Substances 0.000 description 1
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/50—Network services
- H04L67/60—Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computer And Data Communications (AREA)
Abstract
The application relates to the technical field of data processing, and provides a data request method, a data request device, electronic equipment and a storage medium. Intercepting a data request instruction sent by a client and generating acquisition request information corresponding to the data request instruction; sending the acquisition request information to a target server; if the data acquisition from the target server fails based on the acquisition request information, determining a target retransmission strategy aiming at the acquisition request information; the method and the device realize the determination of the corresponding target retransmission strategy based on the current acquisition request information, further solve the problem that only one retransmission strategy is set to cause single retransmission strategy to influence retransmission experience, and simultaneously, the request interceptor retransmits the acquisition request information to the target server according to the target retransmission strategy to try to acquire the data again, so that the problem that the user experience is poor because the data request cannot be carried out again when the client fails to acquire the data from the server is avoided.
Description
Technical Field
The present application relates to the field of data processing technologies, and in particular, to a data request method, a data request device, an electronic device, and a storage medium.
Background
When the client needs to acquire data from the server, the client generates a data request instruction and sends the data request instruction to the server. However, in some cases, such as the problems of unstable server network, short interruption of service, or overload of a certain node request, the server may not respond in time and return data corresponding to the data request instruction, so that the data request of the client fails, and the product competitiveness, the customer experience and the service quality are adversely affected.
Disclosure of Invention
In view of the above, the embodiments of the present application provide a data request method, apparatus, electronic device, and storage medium, so as to solve the problem in the prior art that when a client fails to acquire data from a server, the data request will not be performed again, resulting in poor user experience.
In a first aspect of an embodiment of the present application, there is provided a data request method, including: intercepting a data request instruction sent by a client and generating acquisition request information corresponding to the data request instruction; sending the acquisition request information to a target server; if the data acquisition from the target server fails based on the acquisition request information, determining a target retransmission strategy aiming at the acquisition request information; and retransmitting the acquisition request information to the target server according to the target retransmission strategy.
In a second aspect of an embodiment of the present application, there is provided a data request apparatus, including: the interception module is used for intercepting a data request instruction sent by the client and generating acquisition request information corresponding to the data request instruction; the sending module is used for sending the acquisition request information to the target server; a determining module, configured to determine a target retransmission policy for the acquisition request information if it is determined that the acquisition of data from the target server fails based on the acquisition request information; and the processing module is used for retransmitting the acquisition request information to the target server according to the target retransmission strategy.
In a third aspect of the embodiments of the present application, there is provided an electronic device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, the processor implementing the steps of the above method when executing the computer program.
In a fourth aspect of the embodiments of the present application, there is provided a computer readable storage medium storing a computer program which, when executed by a processor, implements the steps of the above method.
Compared with the prior art, the embodiment of the application has the beneficial effects that: according to the embodiment of the application, the data request instruction sent by the client is intercepted, and the acquisition request information corresponding to the data request instruction is generated; sending the acquisition request information to a target server; if the data acquisition from the target server fails based on the acquisition request information, determining a target retransmission strategy aiming at the acquisition request information; the method and the device realize the determination of the corresponding target retransmission strategy based on the current acquisition request information, further solve the problem that only one retransmission strategy is set, so that the retransmission strategy is single to influence retransmission experience, and simultaneously, the request interceptor retransmits the acquisition request information to the target server according to the target retransmission strategy to try to acquire the data again, so that the problem that when a client fails to acquire the data from the server, the data request cannot be carried out again, so that the user experience is poor is avoided, and meanwhile, the problem that the client retransmits the data request instruction to the target server, so that the load of the client is too high, and the client collapses is avoided.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic view of an application scenario according to an embodiment of the present application;
FIG. 2 is a flow chart of a data request method according to an embodiment of the present application;
FIG. 3 is a flowchart of another data request method according to an embodiment of the present application;
FIG. 4 is a flowchart of another data request method according to an embodiment of the present application;
FIG. 5 is a flowchart of another data request method according to an embodiment of the present application;
FIG. 6 is a flow chart of yet another alternative data request method provided by an embodiment of the present application;
FIG. 7 is a flow chart of an alternative method of requesting data according to an embodiment of the present application;
FIG. 8 is a flow chart of yet another alternative data request method provided by an embodiment of the present application;
FIG. 9 is a schematic diagram of a data request device according to an embodiment of the present application;
fig. 10 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth such as the particular system architecture, techniques, etc., in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
A data request method and apparatus according to embodiments of the present application will be described in detail with reference to the accompanying drawings.
Fig. 1 is a schematic view of an application scenario according to an embodiment of the present application. The application scenario may include terminal devices 1, 2 and 3, a server 4 and a network 5.
The terminal devices 1, 2 and 3 may be hardware or software. When the terminal devices 1, 2 and 3 are hardware, they may be various electronic devices having a display screen and supporting communication with the server 4, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like; when the terminal apparatuses 1, 2, and 3 are software, they can be installed in the electronic apparatus as described above. The terminal devices 1, 2 and 3 may be implemented as a plurality of software or software modules, or as a single software or software module, to which the embodiments of the present application are not limited. Further, various applications, such as a data processing application, an instant messaging tool, social platform software, a search class application, a shopping class application, and the like, may be installed on the terminal devices 1, 2, and 3.
The server 4 may be a server that provides various services, for example, a background server that receives a request transmitted from a terminal device with which communication connection is established, and the background server may perform processing such as receiving and analyzing the request transmitted from the terminal device and generate a processing result. The server 4 may be a server, a server cluster formed by a plurality of servers, or a cloud computing service center, which is not limited in this embodiment of the present application.
The server 4 may be hardware or software. When the server 4 is hardware, it may be various electronic devices that provide various services to the terminal devices 1, 2, and 3. When the server 4 is software, it may be a plurality of software or software modules providing various services to the terminal devices 1, 2 and 3, or may be a single software or software module providing various services to the terminal devices 1, 2 and 3, to which the embodiment of the present application is not limited.
The network 5 may be a wired network using coaxial cable, twisted pair wire, and optical fiber connection, or may be a wireless network that can implement interconnection of various communication devices without wiring, for example, bluetooth (Bluetooth), near field communication (Near Field Communication, NFC), infrared (Infrared), etc., which is not limited in the embodiment of the present application.
The user can establish a communication connection with the server 4 via the network 5 through the terminal devices 1, 2, and 3 to receive or transmit information or the like.
It should be noted that the specific types, numbers and combinations of the terminal devices 1, 2 and 3, the server 4 and the network 5 may be adjusted according to the actual requirements of the application scenario, which is not limited in the embodiment of the present application.
A data request method and apparatus according to embodiments of the present application will be described in detail with reference to the accompanying drawings.
Fig. 2 is a data request method according to an embodiment of the present application, as shown in fig. 2, where the method includes:
s201, intercepting a data request instruction sent by a client, and generating acquisition request information corresponding to the data request instruction;
s202, sending the acquisition request information to a target server;
s203, if the acquisition of the data from the target server based on the acquisition request information fails, determining a target retransmission strategy aiming at the acquisition request information;
s204, retransmitting the acquisition request information to the target server according to the target retransmission strategy.
Specifically, the data request method provided in this example is applied to a request interceptor, and it can be understood that all systems, components and devices capable of intercepting a request interface of a client may be used as the request interceptor, where the client includes, but is not limited to, a terminal that uses a micro service to issue a data request instruction; the request interceptor intercepts data request instructions issued by the client by intercepting a client request interface that is used to determine the data request instructions that need to be intercepted, which in some examples is a uniform resource identifier (Uniform Resource Identifier, URI).
In some examples, the request interceptor is capable of intercepting all of the fetch request information issued by the client request interface. In some examples, the request interceptor may intercept the acquisition request information sent by a URI address preset in the client request interface, where the URI address may be a precise address or a fuzzy address, for example, the precise address is as follows: v 0/veccle/getDetail, the exact address representing that the data request instructions beginning with v 0/veccle/getDetail all need to be intercepted, the ambiguous address is as follows: v 0/v_cycle/, representing v 0/v_cycle/, the fuzzy address representing that the data request command beginning with v 0/v_cycle/needs to be intercepted; it can be understood that the above URI addresses are only used for illustration, and are not used for limiting the method provided by the present example to only intercept the data request instruction of the above URI addresses, and specific URI addresses can be flexibly set by related personnel according to actual requirements.
It can be understood that the data request instruction carries an interface address, a service name of the client, a target service name of the target server, a request parameter, an initiation time, a request mode and the like; after receiving the data request instruction, the request interceptor generates acquisition request information according to the data request instruction, where in some examples, the acquisition request information carries a service name of a client, a target service name of a target server, a request parameter, an initiation time, a request mode, and the like, where the acquisition request information and the data request instruction are the same as data acquired by requesting from the target server, and the difference is that: the data request instruction is sent by the client and is used for obtaining a request of data from the target server; the acquisition request information is a request issued by the request interceptor for acquiring data from the target server.
In some examples, the request interceptor sends the acquisition request information to the target server after generating the acquisition request information, and the target server can search corresponding data according to the acquisition request information when receiving the acquisition request information; it can be understood that the request interceptor can determine, based on the service name of the target server, node information deployed by the service corresponding to the target server, for example, the service corresponding to the target server is deployed with 3 nodes, where three nodes are respectively: node 1: xxx, node 2:192.168.X. Xxx, node three 192.168.X. Xxx, then the request interceptor can select a less loaded service node from the plurality of service nodes corresponding to the target server according to the load balancer policy.
In some examples, the request interceptor determines a target retransmission policy for the acquisition request information if it determines that the acquisition of data from the target server based on the acquisition request information fails; specifically, the request interceptor determines that the acquisition of data from the target server based on the acquisition request information fails, including, but not limited to, any one of the following cases, the first case: the request interceptor does not receive the data returned by the target server for the acquisition request information within the preset response time; second case: the request interceptor receives the data acquisition failure information and/or the abnormal information returned by the server; for example, the preset response time is 5 minutes, the request interceptor sends the acquisition request information to the target server and counts time when the acquisition request information is sent, if the request interceptor still does not receive the data returned by the target server for the acquisition request information after the count time satisfies five minutes, the request interceptor judges that the acquisition of the data from the target server based on the acquisition request information fails; for another example, the request interceptor sends the acquisition request information to the target server, and the target server returns response information for failure in acquiring data for the acquisition request information, and the request interceptor determines that data acquisition from the target server fails based on the acquisition request information.
It can be understood that if the target server returns the corresponding data for the acquisition request information, the request interceptor determines that the acquisition of the data from the target server based on the acquisition request information is successful, and the interception requester directly returns the data returned by the target server to the client.
In some examples, when the request interceptor confirms that the acquisition of the data fails, the request interceptor determines a target retransmission policy for the acquisition request information, where the target retransmission policy is a preset retransmission policy, and at least some target retransmission policies corresponding to the acquisition request information are different, so as to determine a corresponding target retransmission policy for the current acquisition request information, and further avoid the problem that all the acquisition request information only corresponds to one retransmission policy, resulting in a single retransmission policy affecting retransmission experience.
It can be understood that if the request interceptor cannot determine the target retransmission policy corresponding to the acquisition request information, stopping the subsequent flow, and returning the information of failure in acquiring the data from the target service area to the client; in some examples, if the request interceptor cannot determine the target retransmission policy corresponding to the acquisition request information, then retransmitting using a default target retransmission policy.
In some examples, after determining the target retransmission policy for the acquisition request information, the request interceptor retransmits the acquisition request information to the target server according to the target retransmission policy, where the request interceptor retransmits the acquisition request information to implement the data required by the client, so as to avoid the problem that when the server fails, the client fails to acquire the data from the server without subsequent retransmission operation, resulting in poor user experience.
According to the technical scheme provided by the embodiment of the application, the data request instruction sent by the client is intercepted, and the acquisition request information corresponding to the data request instruction is generated; sending the acquisition request information to a target server; if the data acquisition from the target server fails based on the acquisition request information, determining a target retransmission strategy aiming at the acquisition request information; the method and the device realize the determination of the corresponding target retransmission strategy based on the current acquisition request information, further solve the problem that only one retransmission strategy is set, so that the retransmission strategy is single to influence retransmission experience, and simultaneously, the request interceptor retransmits the acquisition request information to the target server according to the target retransmission strategy to try to acquire the data again, so that the problem that when a client fails to acquire the data from the server, the data request cannot be carried out again, so that the user experience is poor is avoided, and meanwhile, the problem that the client retransmits the data request instruction to the target server, so that the load of the client is too high, and the client collapses is avoided.
In some embodiments, as shown in fig. 3, determining a target retransmission policy for the acquisition request information includes:
s301, determining a target service name corresponding to a target server;
s302, determining a target retransmission strategy corresponding to the target service name according to the corresponding relation between the preset service name and the retransmission strategy and the target service name.
Specifically, the request interceptor can determine the target service name of the target server carried in the data request instruction by analyzing the data request instruction, and then determine the target retransmission policy corresponding to the target service name according to the corresponding relationship between the preset service name and the retransmission policy and the target service name, where the corresponding relationship between the preset service name and the retransmission policy is set by related personnel according to actual requirements.
The foregoing example is accepted, and the correspondence between the preset service name and the retransmission policy may be stored in various forms, for example, the correspondence between the preset service name and the retransmission policy may be stored in the form of a key value pair; for another example, the correspondence between the preset service name and the retransmission policy is stored in a table form.
In this example, the corresponding relationship between the preset service name and the retransmission policy is stored in a table form as an example, and the corresponding relationship between the preset service name and the retransmission policy is as follows:
Service name | Retransmission strategy |
A | X |
… | … |
N | Z |
When the request interceptor determines that the target service name corresponding to the target server is a, according to the target service name a being queried in the table, the target retransmission policy corresponding to the target service name a may be determined to be X.
It can be understood that, when the request interceptor determines that the target service name corresponding to the target server is B, according to the target service name B being then queried in the upper table (the upper table does not include the service name B), the request interceptor cannot determine the target retransmission policy for acquiring the request information at this time.
In some examples, the corresponding relation between the preset service name and the retransmission policy is stored in a database, and the request interceptor queries the target retransmission policy corresponding to the target service name from the database each time after determining the target service name corresponding to the target server; in some examples, after determining the target service name corresponding to the target server, the request interceptor determines whether a target retransmission policy corresponding to the target service name exists in the local cache, and if the target retransmission policy corresponding to the target service name does not exist in the local cache, queries the target retransmission policy corresponding to the target service name in the database, and stores the target retransmission policy corresponding to the target service name in the local cache; if the target retransmission strategy corresponding to the target service name exists in the local cache, the target retransmission strategy corresponding to the target service name is directly determined from the local cache, and further the problem that the database is too high in pressure due to the fact that the request interceptor inquires from the database after determining the target service name corresponding to the target server each time is avoided.
According to the technical scheme provided by the embodiment of the application, the target service name corresponding to the target server is determined; and determining a target retransmission strategy corresponding to the target service name according to the corresponding relation between the preset service name and the retransmission strategy and the target service name, wherein the target retransmission strategy is determined based on the current acquisition request information by searching the target service name in the corresponding relation between the preset service name and the retransmission strategy, so that the problem that only one retransmission strategy is set to cause single influence on retransmission experience is avoided.
In some embodiments, as shown in fig. 4, retransmitting the acquisition request information to the target server according to the target retransmission policy includes:
s401, obtaining the retransmission times and retransmission intervals contained in the target retransmission strategy;
s402, the acquisition request information is retransmitted to the target server according to the retransmission times and the retransmission intervals.
Specifically, each target retransmission policy carries retransmission times and retransmission intervals, and the request interceptor retransmits the acquired request information to the target server according to the retransmission times and retransmission intervals after determining the retransmission times and the retransmission intervals; taking the example of the retransmission number of 5 and the retransmission interval of 1 minute as an example, the request interceptor retransmits the acquisition request information to the target server for the first time and starts to count time, and after the count time of one minute is completed, retransmits the acquisition request information to the target server … for the second time, and so on until the request interceptor retransmits the request information to the target server for the fifth time.
It can be understood that, if the request interceptor receives the data returned by the target server for the acquisition request information during the process of retransmitting the acquisition request information to the target server according to the retransmission times and retransmission intervals, the request interceptor directly stops the step of retransmitting the acquisition request information to the target server according to the retransmission times and retransmission intervals, and transmits the data returned by the target server for the acquisition request information to the client.
Taking the example that the retransmission time is 5 and the retransmission interval is 1 minute as an example, the request interceptor retransmits the acquisition request information to the target server for the first time and starts timing, and after one minute of timing is completed, retransmits the acquisition request information to the target server for the second time and starts timing, if the data returned by the target server aiming at the acquisition request information is received in the timing process, the request interceptor stops retransmitting the acquisition request information to the target server, and the target server aims at the data returned by the acquisition request information.
In some examples, after retransmitting the acquisition request information to the target server according to the target retransmission policy, the method further comprises: if the acquisition request information is retransmitted to the target server according to the retransmission times and retransmission intervals, and the data returned by the target server for the acquisition request information is not received yet, the request interceptor returns a data acquisition failure message to the client.
It can be appreciated that the retransmission interval may be 0, and the request interceptor continuously retransmits the acquisition request information to the target server, and stops retransmitting the acquisition request information to the target server when the number of retransmissions is reached or when the data returned by the target server for the acquisition request information is received.
According to the technical scheme provided by the embodiment of the application, the retransmission times and the retransmission intervals contained in the target retransmission strategy are obtained; the acquisition request information is retransmitted to the target server according to the retransmission times and the retransmission intervals, so that the target server is retransmitted based on the determined retransmission times and retransmission intervals, and the problem of excessive load caused by excessive retransmission times of the acquisition request information by the request interceptor due to random retransmission of the acquisition request information is solved.
In some embodiments, as shown in fig. 5, retransmitting the acquisition request information to the target server according to the target retransmission policy includes:
s501, determining a request mode corresponding to a data request instruction;
s502, if the request mode accords with a preset request mode, determining a retransmission pre-strategy corresponding to the data request instruction;
s503, determining strategy parameters corresponding to the retransmission pre-strategy, and obtaining target parameters configured for the retransmission pre-strategy in advance;
S504, if the strategy parameters accord with the target parameters, retransmitting the acquisition request information to the target server according to the target retransmission strategy.
Specifically, the request mode of the client side sending out the data request instruction includes, but is not limited to: GET, POST, DELETE, PUT, the preset request manner includes, but is not limited to: GET, POST, DELETE, PUT, wherein the preset request mode is flexibly set by related personnel according to actual demands; taking a POST as an example of a preset request mode, after a client sends a data request instruction, a request interceptor determines a request mode corresponding to the data request instruction sent by the client, if the request interceptor determines that the request mode corresponding to the data request instruction sent by the client is GET, the request interceptor determines that the request mode does not conform to the preset request mode, and the request interceptor stops determining a retransmission pre-strategy corresponding to the data request instruction and stops the subsequent steps; if the request interceptor determines that the request mode corresponding to the data request instruction sent by the client is POST, the request interceptor judges that the request mode accords with the preset request mode, and the request interceptor continues to execute the subsequent steps.
In some examples, if the request mode accords with the preset request mode, the request interceptor determines the retransmission pre-strategy corresponding to the data request command, and it can be understood that the retransmission pre-strategy is a preset retransmission pre-strategy, and in some examples, the retransmission pre-strategies corresponding to different data request commands are the same; in some examples, the retransmission preamble policies corresponding to different data request instructions are different. For example, the request interceptor determines the corresponding retransmission pre-policy according to the request mode corresponding to the data request instruction, different request modes correspond to different retransmission pre-policies, or different request modes correspond to the same retransmission pre-policy.
It can be appreciated that in some examples, if the request interceptor determines that the data request instruction does not have a corresponding retransmission pre-policy, then the acquisition request information may be retransmitted directly to the target server according to the target retransmission policy.
In some examples, after the request interceptor determines the retransmission front policy, it determines policy parameters corresponding to the retransmission front policy, and obtains target parameters configured in advance for the retransmission front policy; finally, if the strategy parameters accord with the target parameters, the acquisition request information is processed according to the target retransmission strategy; and if the target retransmission strategy parameter does not accord with the target parameter, stopping the subsequent steps.
According to the technical scheme provided by the embodiment of the application, the request mode corresponding to the data request instruction is determined; if the request mode accords with the preset request mode, determining a retransmission pre-strategy corresponding to the data request instruction; determining strategy parameters corresponding to the retransmission pre-strategy, and acquiring target parameters configured for the retransmission pre-strategy in advance; and if the strategy parameters accord with the target parameters, retransmitting the acquisition request information to the target server according to the target retransmission strategy. The strategy parameters are determined through the retransmission pre-strategy, and the acquisition request information is processed according to the target retransmission strategy when the strategy parameters accord with the target parameters, so that the problem of invalid retransmission caused by directly retransmitting the acquisition request information to the target server according to the target retransmission strategy and further the problem of system resource waste are avoided.
In some examples, the target parameters include: a preset target type; as shown in fig. 6, before retransmitting the acquisition request information to the target server according to the target retransmission policy, the method further includes:
s601, if the retransmission pre-strategy is an abnormal strategy, determining that the strategy parameter is response information returned by the target server;
s602, analyzing the response information to obtain the type of the response information;
S603, matching the type of the response information with a preset target type to determine whether the strategy parameters accord with the target parameters.
Specifically, if the retransmission pre-strategy determined by the request interceptor is an abnormal strategy, determining the corresponding strategy parameter as response information returned by the target server; it can be understood that if the target server cannot acquire data based on the acquisition request information at present due to any reason such as network congestion, short service interruption, or overload of a certain node request, the target server returns failure information of acquiring the data as response information; if the target server cannot acquire data based on the acquisition request information due to abnormal interface configuration, the target server returns the abnormal interface configuration as response information; when the target server can acquire data based on the acquisition request information, the corresponding data is returned.
In the above example, the request interceptor analyzes the response information to obtain the type of the response information, that is, the request interceptor determines whether the response information belongs to "acquisition data failure information" or "interface configuration abnormality", and it can be understood that, if there is an interface configuration abnormality, if the interface configuration abnormality is not solved, the target server cannot normally acquire data no matter how many times the request information is retransmitted, so the example uses "acquisition data failure information" as a preset target type. Specifically, when the type of the request interceptor analysis response information is 'acquisition data failure information', determining that the strategy parameters accord with the target parameters; when the type of the request interceptor analysis response information is 'interface configuration abnormality', determining that the strategy parameters do not accord with the target parameters.
According to the technical scheme provided by the embodiment of the application, if the retransmission front-end strategy is an abnormal strategy, the strategy parameter is determined to be response information returned by the target server; analyzing the response information to obtain the type of the response information; and matching the type of the response information with a preset target type to determine whether the strategy parameters accord with the target parameters, wherein when the retransmission pre-strategy is an abnormal strategy, the strategy parameters are determined to be the response information returned by the target server, so that the effect of accurately determining the strategy parameters is realized, and further, whether the strategy parameters accord with the target parameters is accurately determined.
In some examples, the target parameters include: as shown in fig. 7, before retransmitting the acquisition request information to the target server according to the target retransmission policy, the method further includes:
s701, if the retransmission pre-strategy is a timeout strategy, determining a strategy parameter as the sending time of obtaining the initial sending of the request information to the target server;
s702, determining a difference time length according to the sending time and the current time;
s703, comparing the difference time length with a preset timeout time length to determine whether the policy parameters conform to the target parameters.
Specifically, if the request interceptor determines that the retransmission pre-policy is a timeout policy, determining that the policy parameter is a transmission time when the acquisition request information is initially transmitted to the target server, that is, a time when the request interceptor transmits the acquisition request information to the target server for the first time, and taking the transmission time as the policy parameter.
After the request interceptor acquires the sending time, determining a difference time length according to the sending time and the current time, for example, the sending time acquired by the request interceptor is 10.00 in the same day, the current time is 10.05 in the same day, and the difference time length is five minutes.
After determining the difference time length, the request interceptor compares the difference time length with a preset timeout time length to determine whether the strategy parameters accord with the target parameters, wherein the preset timeout time length is a time length set by related personnel according to actual requirements; specifically, taking a preset timeout period as an example, if the difference period is less than five minutes, the request interceptor determines whether the policy parameters conform to the target parameters, and if the difference period is not less than five minutes, the request interceptor determines that the policy parameters do not conform to the target parameters.
According to the technical scheme provided by the embodiment of the application, if the retransmission pre-strategy is a timeout strategy, determining the strategy parameter as the sending time of the initial sending of the acquisition request information to the target server; determining a difference time length according to the sending time and the current time; comparing the difference time length with a preset timeout time length to determine whether the strategy parameters accord with the target parameters, wherein the example realizes accurate determination of the strategy parameters by acquiring the initial transmission time, and further realizes subsequent accurate determination of whether the strategy parameters accord with the target parameters.
In some examples, as shown in fig. 8, after retransmitting the acquisition request information to the target server according to the target retransmission policy, the method further includes:
s801, receiving data returned by a target server based on the acquisition request information;
s802, transmitting data returned by the target server based on the acquisition request information to the client.
Specifically, if the acquisition request information is retransmitted to the target server according to the target retransmission policy, the target server acquires corresponding data based on the acquisition request information and transmits the corresponding data to the request interceptor, and the request interceptor receives the data returned by the target server based on the acquisition request information and transmits the data returned by the target server based on the acquisition request information to the client, so that the client acquires the data corresponding to the data request instruction.
It can be understood that, if the request interceptor re-transmits the acquisition request information to the target server according to the target retransmission policy, and then the request interceptor fails to acquire data from the target server based on the acquisition request information (including at least one of the target server failing to acquire corresponding data based on the acquisition request information, the target server failing to acquire retransmitted acquisition request information, and the target server failing to transmit corresponding data to the request interceptor after acquiring corresponding data based on the acquisition request information), at this time, the request interceptor returns data acquisition failure information to the client, so that the user knows that the data acquisition fails.
According to the technical scheme provided by the embodiment of the application, the data returned by the target server based on the acquisition request information is received; the data returned by the target server based on the acquisition request information is transmitted to the client, so that the data returned by the target server based on the target retransmission strategy is acquired, and the problem that the user experience is poor because the data request cannot be carried out again when the client fails to acquire the data from the server in the related technology is solved.
Any combination of the above optional solutions may be adopted to form an optional embodiment of the present application, which is not described herein.
The following are examples of the apparatus of the present application that may be used to perform the method embodiments of the present application. For details not disclosed in the embodiments of the apparatus of the present application, please refer to the embodiments of the method of the present application.
The present embodiment also provides a data request device, as shown in fig. 9, including:
the interception module 901 is configured to intercept a data request instruction sent by a client and generate acquisition request information corresponding to the data request instruction;
a transmitting module 902 configured to transmit the acquisition request information to the target server;
a determining module 903 configured to determine a target retransmission policy for the acquisition request information if it is determined that the acquisition of data from the target server fails based on the acquisition request information;
a processing module 904 configured to retransmit the acquisition request information to the target server according to the target retransmission policy.
In some examples, the determination module 903 is further configured to determine a target service name corresponding to the target server; and determining a target retransmission strategy corresponding to the target service name according to the preset corresponding relation between the service name and the retransmission strategy and the target service name.
In some examples, the processing module 904 is further configured to obtain a number of retransmissions and a retransmission interval contained in the target retransmission policy; and retransmitting the acquisition request information to the target server according to the retransmission times and the retransmission intervals.
In some examples, the processing module 904 is further configured to determine a request manner corresponding to the data request instruction; if the request mode accords with the preset request mode, determining a retransmission pre-strategy corresponding to the data request instruction; determining strategy parameters corresponding to the retransmission pre-strategy, and acquiring target parameters configured for the retransmission pre-strategy in advance; and if the strategy parameters accord with the target parameters, retransmitting the acquisition request information to the target server according to the target retransmission strategy.
In some examples, the processing module 904 is further configured to determine that the policy parameter is response information returned by the target server if the retransmission pre-policy is an exception policy; analyzing the response information to obtain the type of the response information; and matching the type of the response information with a preset target type to determine whether the strategy parameters accord with the target parameters.
In some examples, the processing module 904 is further configured to determine the policy parameter as a transmission time of the initial transmission of the acquisition request information to the target server if the retransmission pre-policy is a timeout policy; determining a difference time length according to the sending time and the current time; and comparing the difference time length with a preset timeout time length to determine whether the strategy parameters accord with the target parameters.
In some examples, the processing module 904 is further configured to receive data returned by the target server based on the acquisition request information; and transmitting the data returned by the target server based on the acquisition request information to the client.
According to the technical scheme provided by the embodiment of the application, the device of the embodiment of the application intercepts the data request instruction sent by the client and generates the acquisition request information corresponding to the data request instruction; sending the acquisition request information to a target server; if the data acquisition from the target server fails based on the acquisition request information, determining a target retransmission strategy aiming at the acquisition request information; the method and the device realize the determination of the corresponding target retransmission strategy based on the current acquisition request information, further solve the problem that only one retransmission strategy is set to cause single retransmission strategy to influence retransmission experience, and simultaneously, the request interceptor retransmits the acquisition request information to the target server according to the target retransmission strategy to try to acquire the data again, so that the problem that the client side is collapsed due to overhigh load of the client side caused by the fact that the client side retransmits the data request instruction to the target server is avoided.
Fig. 9 is a schematic diagram of an electronic device 9 according to an embodiment of the present application. As shown in fig. 9, the electronic apparatus 9 of this embodiment includes: a processor 901, a memory 902 and a computer program 903 stored in the memory 902 and executable on the processor 901. The steps of the various method embodiments described above are implemented when the processor 901 executes the computer program 903. Alternatively, the processor 901 performs the functions of the modules/units in the above-described apparatus embodiments when executing the computer program 903.
The electronic device 9 may be a desktop computer, a notebook computer, a palm computer, a cloud server, or the like. The electronic device 9 may include, but is not limited to, a processor 901 and a memory 902. It will be appreciated by those skilled in the art that fig. 9 is merely an example of the electronic device 9 and is not limiting of the electronic device 9 and may include more or fewer components than shown, or different components.
The processor 901 may be a central processing unit (Central Processing Unit, CPU) or other general purpose processor, digital signal processor (Digital Signal Processor, DSP), application specific integrated circuit (Application Specific Integrated Circuit, ASIC), field programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, or the like.
The memory 902 may be an internal storage unit of the electronic device 9, for example, a hard disk or a memory of the electronic device 9. The memory 902 may also be an external storage device of the electronic device 9, for example, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash Card (Flash Card) or the like, which are provided on the electronic device 9. The memory 902 may also include both internal and external memory units of the electronic device 9. The memory 902 is used to store computer programs and other programs and data required by the electronic device.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional units and modules is illustrated, and in practical application, the above-described functional distribution may be performed by different functional units and modules according to needs, i.e. the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-described functions. The functional units and modules in the embodiment may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit, where the integrated units may be implemented in a form of hardware or a form of a software functional unit.
The integrated modules/units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the present application may implement all or part of the flow of the method of the above embodiment, or may be implemented by a computer program to instruct related hardware, and the computer program may be stored in a computer readable storage medium, where the computer program, when executed by a processor, may implement the steps of each of the method embodiments described above. The computer program may comprise computer program code, which may be in source code form, object code form, executable file or in some intermediate form, etc. The computer readable medium may include: any entity or device capable of carrying computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer Memory, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), an electrical carrier signal, a telecommunications signal, a software distribution medium, and so forth. It should be noted that the content of the computer readable medium can be appropriately increased or decreased according to the requirements of the area and the patent practice, for example, in some areas, the computer readable medium does not include the electric carrier signal and the telecommunication signal according to the area requirements and the patent practice.
The above embodiments are only for illustrating the technical solution of the present application, and are not limiting; although the application has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present application, and are intended to be included in the scope of the present application.
Claims (10)
1. A method of requesting data, the method comprising:
intercepting a data request instruction sent by a client, and generating acquisition request information corresponding to the data request instruction;
the acquisition request information is sent to a target server;
if the acquisition of the data from the target server based on the acquisition request information fails, determining a target retransmission strategy aiming at the acquisition request information;
and retransmitting the acquisition request information to the target server according to the target retransmission strategy.
2. The method of claim 1, wherein determining a target retransmission policy for the acquisition request information comprises:
Determining a target service name corresponding to the target server;
and determining the target retransmission strategy corresponding to the target service name according to the corresponding relation between the preset service name and the retransmission strategy and the target service name.
3. The method of claim 2, wherein retransmitting the acquisition request information to the target server according to the target retransmission policy comprises:
acquiring the retransmission times and retransmission intervals contained in the target retransmission strategy;
and retransmitting the acquisition request information to the target server according to the retransmission times and the retransmission intervals.
4. The method of claim 1, wherein retransmitting the acquisition request information to the target server according to the target retransmission policy comprises:
determining a request mode corresponding to the data request instruction;
if the request mode accords with a preset request mode, determining a retransmission pre-strategy corresponding to the data request instruction;
determining strategy parameters corresponding to the retransmission pre-strategy, and acquiring target parameters configured for the retransmission pre-strategy in advance;
and if the strategy parameters accord with the target parameters, retransmitting the acquisition request information to the target server according to the target retransmission strategy.
5. The method of claim 4, wherein the target parameters comprise: a preset target type; before retransmitting the acquisition request information to the target server according to the target retransmission policy, the method further includes:
if the retransmission pre-strategy is an abnormal strategy, determining that the strategy parameter is response information returned by the target server;
analyzing the response information to obtain the type of the response information;
and matching the type of the response information with the preset target type to determine whether the strategy parameters accord with the target parameters.
6. The method of claim 4, wherein the target parameters comprise: a preset timeout period; before retransmitting the acquisition request information to the target server according to the target retransmission policy, the method further includes:
if the retransmission pre-strategy is a timeout strategy, determining that the strategy parameter is the sending time of the acquisition request information initially sent to the target server;
determining a difference time length according to the sending time and the current time;
and comparing the difference time length with the preset timeout time length to determine whether the strategy parameters accord with the target parameters.
7. The method of claim 6, wherein after retransmitting the acquisition request information to the target server according to the target retransmission policy, the method further comprises:
receiving data returned by the target server based on the acquisition request information;
and transmitting the data returned by the target server based on the acquisition request information to the client.
8. A data requesting apparatus, the apparatus comprising:
the intercepting module is used for intercepting a data request instruction sent by a client and generating acquisition request information corresponding to the data request instruction;
the sending module is used for sending the acquisition request information to a target server;
a determining module, configured to determine a target retransmission policy for the acquisition request information if it is determined that the acquisition of data from the target server fails based on the acquisition request information;
and the processing module is used for retransmitting the acquisition request information to the target server according to the target retransmission strategy.
9. An electronic device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the steps of the method according to any of claims 1 to 7 when the computer program is executed.
10. A computer readable storage medium storing a computer program, characterized in that the computer program when executed by a processor implements the steps of the method according to any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311122388.8A CN117014513A (en) | 2023-08-31 | 2023-08-31 | Data request method and device, electronic equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311122388.8A CN117014513A (en) | 2023-08-31 | 2023-08-31 | Data request method and device, electronic equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN117014513A true CN117014513A (en) | 2023-11-07 |
Family
ID=88574493
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202311122388.8A Pending CN117014513A (en) | 2023-08-31 | 2023-08-31 | Data request method and device, electronic equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117014513A (en) |
-
2023
- 2023-08-31 CN CN202311122388.8A patent/CN117014513A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US12035211B2 (en) | Communication method and apparatus, computer-readable medium, and electronic device | |
CN112261094B (en) | Message processing method and proxy server | |
CN108718347B (en) | Domain name resolution method, system, device and storage medium | |
CN111104675A (en) | Method and device for detecting system security vulnerability | |
US11741174B2 (en) | Direct leg access for proxy web scraping | |
CN114584330A (en) | Vulnerability testing method and device | |
CN111241523B (en) | Authentication processing method, device, equipment and storage medium | |
EP3614644B1 (en) | Over-the-air provisioning of network services based on a reverse auction | |
CN106686040A (en) | Message processing method and message processing device | |
CN114268631B (en) | Low-delay network system, communication connection method thereof and readable storage medium | |
CN110096381B (en) | Method, device, equipment and medium for realizing remote procedure call | |
US20230018983A1 (en) | Traffic counting for proxy web scraping | |
CN110798495A (en) | Method and server for end-to-end message push in cluster architecture mode | |
CN113542324A (en) | Message pushing method and device | |
CN117014513A (en) | Data request method and device, electronic equipment and storage medium | |
CN113271300B (en) | Authentication system and method | |
CN115604282A (en) | Resource data processing method and device, electronic equipment and storage medium | |
CN110941805B (en) | Identity authentication method and device | |
CN114338574A (en) | Instant messaging method, management node and system | |
CN111490997B (en) | Task processing method, proxy system, service system and electronic equipment | |
CN110545333B (en) | Message processing method and device and network system | |
CN111046061A (en) | Data query method, device, system, equipment and storage medium | |
CN113691462B (en) | Response method and device of Internet group management protocol | |
CN114285743B (en) | Method, device, electronic equipment and storage medium for updating configuration information | |
CN109889590B (en) | Message processing method, device, client and computer readable medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
TA01 | Transfer of patent application right | ||
TA01 | Transfer of patent application right |
Effective date of registration: 20240118 Address after: No. 13 Xingxiang Road, Zengjia Town, High tech Zone, Shapingba District, Chongqing, 400039 Applicant after: Chongqing Selis Phoenix Intelligent Innovation Technology Co.,Ltd. Address before: 401120 No. 618 Liangjiang Avenue, Longxing Town, Yubei District, Chongqing City Applicant before: Chongqing Celes New Energy Automobile Design Institute Co.,Ltd. |