Request updating method and device, storage medium and electronic device
By replacing domain names with interceptors and configuration files in the application, the problem that application requests are greatly affected by the server is solved, decentralized request processing is realized, the server load is reduced, the response speed is improved, and the user is improved Experience.
Patent Information
- Application Number
- CN202410968405.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-18
- Publication Date
- 2024-11-22
AI Technical Summary
In the prior art, the request sent by the application is greatly affected by the server, resulting in increased response time, computing cost and network load. The problem of the server routing and distribution function will affect all users, especially in the country where the routing server is located, the network is not allowed. Application usage is affected when requesting a transit.
Determine whether to intercept the request through the target application's interceptor, and determine the replaced target domain name through the configuration file, replace the original domain name with a suitable domain name, and send the request after the domain name replacement to the server, thereby reducing dependence on the server and realizing the request decentralized processing.
It reduces the computing cost and network load of the server, improves the request response speed, reduces the impact of users by a single point of failure, improves the user experience, and achieves the same effect as the server decision.
Smart Images

Figure CN119011667A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of smart home technology, and more specifically, to a request update method and device, a storage medium, and an electronic device. Background Art
[0002] At present, when an application processes user access information, it may involve privacy and security issues in various countries, so multiple data centers are built to handle requests from users in different countries. As for how to adapt to multiple data centers, most related technologies use server-side solutions, that is, the application only requests a server domain name, and the server makes a unified decision on the received requests, and then distributes them to servers in different data centers for processing.
[0003] Because in related technologies, the server makes unified decisions on requests, the reception and distribution of all requests need to be processed by the server, resulting in a significant increase in request response time, server computing costs and network load. In addition, when there is a problem with the routing distribution function of the server, all users are susceptible to fluctuations. When the country where the routing server is located does not allow network requests to transit, it will also affect the use of the application.
[0004] With regard to the problem in related technologies that requests sent by a target application are greatly affected by the server, no effective solution has been proposed yet.
[0005] Therefore, it is necessary to improve the related technology to overcome the above-mentioned defects in the related technology. Summary of the invention
[0006] The embodiments of the present invention provide a request updating method and device, a storage medium and an electronic device, so as to at least solve the problem that the request sent by the target application is greatly affected by the server.
[0007] According to one aspect of an embodiment of the present invention, a request update method is provided, comprising: in the case where a target application sends a target request, determining whether to intercept the target request through an interceptor of the target application; in the case where it is determined to intercept the target request, determining a first target domain name corresponding to the target request through a configuration file, wherein the configuration file is used to query domain names corresponding to multiple functional services, and the requests corresponding to the multiple functional services include the target request; replacing the original domain name carried in the target request with the first target domain name, and sending the target request after the domain name replacement to the server.
[0008] In an exemplary embodiment, determining whether to intercept the target request is performed by the interceptor of the target application, including: determining the target function service identifier of the target function service to be accessed by the target request based on the original domain name carried in the target request; and determining not to intercept the target request when the target function service identifier is not located in the target list, wherein the target list has multiple function service identifiers, each of the multiple function service identifiers corresponds to multiple data centers, and each of the multiple data centers is allowed to provide the function service.
[0009] In an exemplary embodiment, determining whether to intercept the target request by the interceptor of the target application includes: determining the target function service identifier of the target function service to be accessed by the target request according to the original domain name carried in the target request; when the target function service identifier is in the target list, detecting whether the terminal device corresponding to the target application is located in a preset area, and / or detecting whether the account currently logged in by the target application is a preset account, wherein the target list has multiple function service identifiers, and the function service corresponding to each function service identifier in the multiple function service identifiers corresponds to multiple data centers, and each of the multiple data centers allows the provision of the function service; the preset area is the area where the terminal device is located when the target application last sent a request corresponding to the target function service; the preset account is the account logged in by the target application when the target application last sent a request corresponding to the target function service, and the target application is running on the terminal device; when it is detected that the terminal device corresponding to the target application is not located in the preset area, determining to intercept the target request; and / or when it is detected that the account currently logged in by the target application is not the preset account, determining to intercept the target request.
[0010] In an exemplary embodiment, determining the first target domain name corresponding to the target request through a configuration file includes: detecting the target area where the terminal device corresponding to the target application is located; and determining the target function service to be accessed by the target request based on the original domain name carried in the target request, and determining multiple domain names corresponding to the target function service from the configuration file; and determining the first target domain name from the multiple domain names based on the target area.
[0011] In an exemplary embodiment, determining the first target domain name corresponding to the target request through a configuration file includes: detecting attribute information of an account currently logged in by the target application, wherein the attribute information includes a registration area of the account; and determining a target function service to be accessed by the target request based on the original domain name carried in the target request, and determining multiple domain names corresponding to the target function service from the configuration file; and determining the first target domain name from the multiple domain names based on the attribute information.
[0012] In an exemplary embodiment, before determining the first target domain name corresponding to the target request through a configuration file, the method further includes: determining whether the version of the configuration file in the server is consistent with the version of the configuration file in the target application, wherein the server stores the latest version of the configuration file; if the version of the configuration file in the server is inconsistent with the version of the configuration file in the target application, obtaining the latest version of the configuration file from the server to replace the configuration file stored in the target application.
[0013] In an exemplary embodiment, after sending the target request after the domain name replacement to the server, the method also includes: in a case where a request response message of the target request is not obtained, or the obtained request response message of the target request is used to indicate a request failure, determining whether a second target domain name corresponding to the target request is determined through the configuration file; in a case where the second target domain name corresponding to the target request is determined through the configuration file, replacing the first target domain name carried in the target request with the second target domain name, and sending the target request to the server again; in a case where the second target domain name corresponding to the target request is not determined through the configuration file, replacing the first target domain name carried in the target request with the original domain name, and sending the target request to the server again.
[0014] According to another aspect of an embodiment of the present invention, a request updating device is also provided, including: a first determination module, used to determine whether to intercept the target request through an interceptor of the target application when the target application sends the target request; a second determination module, used to determine the first target domain name corresponding to the target request through a configuration file when it is determined to intercept the target request, wherein the configuration file is used to query the domain names corresponding to multiple functional services, and the requests corresponding to the multiple functional services include the target request; a sending module, used to replace the original domain name carried in the target request with the first target domain name, and send the target request after the domain name replacement to the server.
[0015] According to another aspect of the embodiments of the present invention, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the above-requested update method when running.
[0016] According to another aspect of an embodiment of the present invention, there is provided an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the requested update method through the computer program.
[0017] According to another aspect of an embodiment of the present invention, a computer program product is provided, including a computer program, wherein the computer program is executed by a processor to execute the above-mentioned requested update method.
[0018] In an embodiment of the present application, requests are not intercepted by the server but by the application itself, so that requests sent by the target application are less affected by the server, thereby solving the problem that requests sent by the target application are greatly affected by the server. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0020] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0021] Figure 1 is a hardware environment diagram of a request update method according to an embodiment of the present application;
[0022] Figure 2 is a flow chart of a request update method according to an embodiment of the present invention;
[0023] Figure 3 is an overall flow chart of an optional request update method according to an embodiment of the present invention;
[0024] Figure 4 is a flow chart of an optional interceptor operation according to an embodiment of the present invention;
[0025] Figure 5 is a flow chart of configuration table reading and dynamic updating according to an embodiment of the present invention;
[0026] Figure 64 is a structural block diagram of a request updating device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0027] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0028] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0029] According to one aspect of an embodiment of the present application, a request update method is provided. The request update method is widely used in smart home (Smart Home), smart home, smart home device ecology, smart residential (IntelligenceHouse) ecology and other whole-house intelligent digital control application scenarios. Optionally, in this embodiment, the above request update method can be applied to Figure 1 In the hardware environment composed of the terminal device 102 and the server 104 shown in FIG. Figure 1 As shown, the server 104 is connected to the terminal device 102 via a network, and can be used to provide services (such as application services, etc.) for the terminal or a client installed on the terminal. A database can be set on the server or independently of the server to provide data storage services for the server 104. Cloud computing and / or edge computing services can be configured on the server or independently of the server to provide data computing services for the server 104.
[0030] The network may include but is not limited to at least one of the following: wired network, wireless network. The wired network may include but is not limited to at least one of the following: wide area network, metropolitan area network, local area network, and the wireless network may include but is not limited to at least one of the following: WIFI (Wireless Fidelity), Bluetooth. The terminal device 102 may be but is not limited to a PC, a mobile phone, a tablet computer, a smart air conditioner, a smart range hood, a smart refrigerator, a smart oven, a smart stove, a smart washing machine, a smart water heater, a smart washing device, a smart dishwasher, a smart projection device, a smart TV, a smart clothes drying rack, a smart curtain, a smart audio and video, a smart socket, a smart speaker, a smart fresh air device, a smart kitchen and bathroom device, a smart bathroom device, a smart sweeping robot, a smart window cleaning robot, a smart mopping robot, a smart air purification device, a smart steamer, a smart microwave oven, a smart kitchen treasure, a smart purifier, a smart water dispenser, a smart door lock, etc.
[0031] In order to solve the above problem, a request update method is provided in this embodiment, including but not limited to being applied to a target application program. Figure 2 is a flow chart of a request update method according to an embodiment of the present invention, the flow includes the following steps S202-S206:
[0032] Step S202: when the target application sends a target request, determining whether to intercept the target request through the interceptor of the target application;
[0033] Optionally, the target application includes, but is not limited to: social media applications, messaging applications, game applications, music and video applications, financial and payment applications, travel and navigation applications, etc., and the target request is used to access the target functional service.
[0034] In an exemplary embodiment, the above step S202 can be implemented by the following steps S11-S12:
[0035] Step S11: determining the target function service identifier of the target function service to be accessed by the target request according to the original domain name carried in the target request;
[0036] Optionally, there is a correspondence between different domain names and different functional services, and then through the correspondence, the target functional service to be accessed by the target request can be determined based on the original domain name.
[0037] Step S12: When the target function service identifier is not in the target list, determine not to intercept the target request, wherein the target list has multiple function service identifiers, and the function service corresponding to each function service identifier in the multiple function service identifiers corresponds to multiple data centers, and each of the multiple data centers is allowed to provide the function service.
[0038] Optionally, the original domain name is a domain name used by the target application to access the target functional service last time.
[0039] It should be noted that the domain name is the domain name part of the Uniform Resource Locator (URL), which is used to identify the address of a host or server on the network. It is usually composed of multiple levels of labels, among which the domain name includes: the original domain name, the first target domain name and the second target domain name.
[0040] It should be noted that the corresponding data center can be accessed through the domain name, and different data centers have different domain names.
[0041] Optionally, after the above step S11, the method further includes the following steps S21-S22:
[0042] Step S21: When the target function service identifier is in the target list, detecting whether the terminal device corresponding to the target application is located in a preset area, and / or detecting whether the account currently logged in by the target application is a preset account;
[0043] It should be noted that the preset area is the area where the terminal device is located when the target application last sent a request corresponding to the target function service; the preset account is the account logged in by the target application when the target application last sent a request corresponding to the target function service, and the target application is running on the terminal device;
[0044] In an exemplary embodiment, detecting whether the terminal device corresponding to the target application is located in a preset area can be implemented by following the steps S211-S212:
[0045] Step S211: Determine a first network address of a network currently used by the target application;
[0046] Step S212: When the first network address and the second network address do not correspond to the same area, determine that the terminal device corresponding to the target application is not located in the preset area, wherein the second network address is the network address of the network used by the target application when it last sent a request corresponding to the target function service.
[0047] Step S22: When it is detected that the terminal device corresponding to the target application is not located in the preset area, determine to intercept the target request; and / or when it is detected that the account currently logged in by the target application is not the preset account, determine to intercept the target request.
[0048] It should be noted that, if it is detected that the terminal device corresponding to the target application is not located in the preset area, it means that the location of the mobile terminal has changed. If it is not intercepted, the target request will not be able to successfully access the target function service (the data center corresponding to the original domain name cannot be accessed using the original domain name, and the terminal device can only access the data center corresponding to the original domain name when it is in the area corresponding to the original domain name). At this time, it is necessary to intercept the target request and replace the domain name in the target request according to the location of the terminal device.
[0049] It should be noted that, if it is detected that the account currently logged in by the target application is not the preset account, it means that the account logged in by the target application has changed. If it is not intercepted, the target request cannot successfully access the target function service (the data center that provides target function services for different accounts is different, and if the account currently logged in by the target application changes, it cannot successfully access the target function service). At this time, it is necessary to intercept the target request and switch the domain name in the target request to the domain name corresponding to the data center corresponding to the account currently logged in by the target application.
[0050] Step S204: in the case of determining to intercept the target request, determining a first target domain name corresponding to the target request through a configuration file, wherein the configuration file is used to query domain names corresponding to multiple functional services, and the requests corresponding to the multiple functional services include the target request;
[0051] It should be noted that the configuration file contains one or more domain names corresponding to multiple functional services, which can be queried by the target application. Different domain names correspond to different data centers, and the data center is allowed to provide the functional service.
[0052] In an exemplary embodiment, before the above step S204, the method further includes the following steps S31-S32:
[0053] Step S31: determining whether the version of the configuration file in the server is consistent with the version of the configuration file in the target application, wherein the server stores the latest version of the configuration file;
[0054] Step S32: when the version of the configuration file in the server is inconsistent with the version of the configuration file in the target application, obtain the latest version of the configuration file from the server to replace the configuration file stored in the target application.
[0055] Alternatively, if Figure 5 As shown, when the application program (APP) is started, the configuration file preset in the APP is read, and the legitimacy of the configuration file is detected. At the same time, it is determined whether the version of the configuration file in the server is consistent with the version of the configuration file in the application. If they are inconsistent, the latest version of the configuration file is queried in the server. If the latest version exists, the latest version is downloaded and the legitimacy of the latest version of the configuration file is verified. After passing the verification, the configuration file is moved to the path to be used in the sandbox to replace the original configuration file stored in the application.
[0056] It should be noted that in mobile application development, sandbox usually refers to the private file system space of the application, which is used to store the application's configuration files, data, etc. Moving the configuration file to the path to be used in the sandbox means moving the configuration file to the private file system space of the application so that the application can access and use it at runtime. This operation can protect the security of the configuration file and enable the application to easily read and modify the configuration information.
[0057] In an exemplary embodiment, the above step S204 can be implemented by the following steps S41-S43:
[0058] Step S41: Detecting the target area where the terminal device corresponding to the target application is located;
[0059] Step S42: determining the target function service to be accessed by the target request according to the original domain name carried in the target request, and determining multiple domain names corresponding to the target function service from the configuration file;
[0060] It should be noted that there is no specific order in which the above step S41 and the above step S42 are to be executed.
[0061] Step S43: Determine the first target domain name from the multiple domain names based on the target area.
[0062] It should be noted that different domain names correspond to different regions, and the data center corresponding to the i-th domain name among the multiple domain names is used to provide functional services for the i-th region, and thus the first target domain name corresponding to the target region can be determined from the multiple domain names.
[0063] Alternatively, if Figure 3As shown, when the application starts, it will request the interceptor to read the configuration file (i.e. Figure 3 ), the interceptor determines whether the region has changed, such as Figure 4 As shown, when the region changes, the domain name mapping relationship is obtained from the configuration file according to the region, and then the functional service with access is determined according to the original domain name carried in the request, thereby determining multiple domain names corresponding to the functional service according to the domain name mapping relationship.
[0064] In an exemplary embodiment, the above step S204 can also be implemented by the following steps S51-S53:
[0065] Step S51: Detecting attribute information of the account currently logged in by the target application, wherein the attribute information includes a registration area of the account;
[0066] Step S52: determining the target function service to be accessed by the target request according to the original domain name carried in the target request, and determining multiple domain names corresponding to the target function service from the configuration file;
[0067] It should be noted that there is no specific order in which the above step S51 and the above step S52 are to be executed.
[0068] Step S53: Determine the first target domain name from the multiple domain names based on the attribute information.
[0069] It should be noted that different domain names correspond to different areas (including registration areas), and the data center corresponding to the i-th domain name among multiple domain names is used to provide functional services for the i-th area, and then the first target domain name that has a corresponding relationship with the registration area can be determined from the multiple domain names.
[0070] Step S206: Replace the original domain name carried in the target request with the first target domain name, and send the target request after the domain name replacement to the server.
[0071] In the above steps, the request is intercepted by the application itself instead of the server, so that the request sent by the target application is less affected by the server, thus solving the problem that the request sent by the target application is greatly affected by the server.
[0072] In an exemplary embodiment, after sending the target request after the domain name replacement to the server, the method further includes the following steps S61-S63:
[0073] Step S61: when no request response message of the target request is obtained or the obtained request response message of the target request indicates a request failure, determining whether a second target domain name corresponding to the target request is determined through the configuration file;
[0074] It should be noted that the reasons for indicating request failure include, but are not limited to: failure to successfully access the corresponding data center according to the domain name carried in the request.
[0075] Step S62: when the second target domain name corresponding to the target request is determined through the configuration file, the first target domain name carried in the target request is replaced with the second target domain name, and the target request is sent to the server again;
[0076] That is to say, if the request fails, you can switch to another data center for access.
[0077] Step S63: when the second target domain name corresponding to the target request is not determined through the configuration file, the first target domain name carried in the target request is replaced with the original domain name, and the target request is sent to the server again.
[0078] Obviously, the above-described embodiments are only embodiments of a part of the present invention, rather than all embodiments. In order to better understand the above method, the above process is described below in conjunction with embodiments, but it is not intended to limit the technical solutions of the embodiments of the present invention, specifically:
[0079] In the related art, a server-side solution is used to adapt to multiple data centers, but the related art has the following disadvantages:
[0080] (1) The server makes unified decisions on requests. The reception and distribution of all requests need to be processed by the server, which greatly increases the request response time, the server's computing cost, and the network load.
[0081] (2) When there is a problem with the routing distribution function on the server side, all users are susceptible to fluctuations;
[0082] (3) When the country where the routing server is located does not allow network requests to transit, it will also affect the use of the application.
[0083] Therefore, this application changes the decision-making party of the distribution request from the server to the App (i.e. the above-mentioned application). At the same time, the decision points are dispersed to each App to achieve the purpose of decentralization. If a problem occurs in the server of one of the data centers (i.e. the above-mentioned terminal device), it will not affect all users. In addition, this application will pull the distribution policy configuration file from the server, and users do not have to update the App, reducing the computing cost and network load of the server, thereby improving the request response speed, improving the user experience, and achieving an effect consistent with the server's decision.
[0084] In an alternative embodiment, reference Figure 3 The overall process of the update method requested by this application includes:
[0085] 1. When the App starts and sends a request, the interceptor reads the preset configuration table (i.e. the above configuration file) and pulls the latest version of the configuration table to obtain the domain name mapping relationship. At the same time, the interceptor determines the region change. When the region changes, the domain name is set according to the region and the domain name mapping relationship;
[0086] 2. When the APP initiates a request, it will call the request application programming interface (API). The interceptor will intercept and judge each request, and replace the domain name of the intercepted request (that is, replace the original domain name with the first domain name as mentioned above), and then execute subsequent requests to achieve the purpose of requesting different data center servers.
[0087] 3. The request reaches the server. After the server processes the business, it returns the data to the request API;
[0088] 4. Request the API to return the data to the App for subsequent data processing.
[0089] It should be noted that API is a set of specifications that define how to interact with software components. Through API, different software systems can communicate and exchange data with each other to achieve functional expansion and integration.
[0090] In an alternative embodiment, reference Figure 4 ,The specific workflow of the interceptor includes:
[0091] 1. When the App is started, the interceptor will read the pre-built-in configuration table in the App and pull the latest version of the configuration file from the server for use in subsequent processes. At the same time, the interceptor will determine the regional change. When the regional change is determined, the corresponding data center and the domain name mapping relationship of each functional service in this data center are obtained from the configuration table according to the changed area, and cached in the management class. If the corresponding data center and domain name mapping relationship is not found in the configuration table, the mapping relationship is set to empty and cached in the management class;
[0092] 2. The APP sends a request, and the interceptor determines whether the request needs to be intercepted. If not, the original domain name is used for subsequent requests. If interception is required, the subsequent steps are continued;
[0093] 3. Find the corresponding function service name in the configuration table according to the original domain name of the current request. If the corresponding function service name is not obtained, continue to use the original domain name for subsequent requests. If the corresponding function service name is obtained, continue to execute subsequent steps;
[0094] 4. Use the obtained function service name as the key (i.e. the above function service identifier) to find the actual domain name of this function service in the configured domain name mapping relationship management class. If the corresponding actual domain name cannot be found, continue to use the original domain name for subsequent requests. If the corresponding actual domain name is obtained, continue to execute the subsequent steps;
[0095] 5. Use the actual domain name found to replace the original domain name and continue the update process for subsequent requests.
[0096] In an alternative embodiment, reference Figure 5 , the dynamic update process of the configuration table includes:
[0097] 1. Read the preset configuration table process:
[0098] 1) After the App is started, read the configuration table pre-built into the App;
[0099] 2) Check the legitimacy of the configuration table;
[0100] 3) Move the configuration table installation to the path to be used;
[0101] 2. Download and pull the latest configuration table process:
[0102] 1) After the App is started, it queries the server to see whether the configuration table has the latest version;
[0103] 2) If the latest version does not exist, the pull process ends; if the latest version exists, continue to execute the subsequent steps;
[0104] 3) Download the latest version of the configuration table from the server;
[0105] 4) Check the legitimacy of the configuration table;
[0106] 5) Move the latest version of the configuration table to the path folder to be used;
[0107] 6) Delete the original version of the configuration table in the path folder to be used.
[0108] It should be noted that for the server side, when there are multiple data centers, the server side often makes routing distribution decisions, which increases the server load cost, indirectly leads to an increase in request response time, and may also affect all users due to single point failures. After distributing the decision points to each App side, the server load is reduced and the risk of single point failure is reduced; the use of remote pull routing distribution strategy, based on the above advantages, can also achieve dynamic configuration without updating the App, which is flexible and convenient, greatly improving the user experience.
[0109] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods of various embodiments of the present invention.
[0110] In the present embodiment, a request updating device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the equipment described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware is also possible and conceived.
[0111] Figure 6 is a structural block diagram of a request update device according to an embodiment of the present invention, the device comprising:
[0112] A first determination module 62, configured to determine whether to intercept the target request through an interceptor of the target application when the target application sends the target request;
[0113] A second determination module 64 is used to determine a first target domain name corresponding to the target request through a configuration file when it is determined to intercept the target request, wherein the configuration file is used to query domain names corresponding to multiple functional services, and the requests corresponding to the multiple functional services include the target request;
[0114] The sending module 66 is used to replace the original domain name carried in the target request with the first target domain name, and send the target request after the domain name replacement to the server.
[0115] The above device does not intercept requests through the server, but intercepts requests through the application itself, so that the requests sent by the target application are less affected by the server, solving the problem that the requests sent by the target application are greatly affected by the server.
[0116] In an exemplary embodiment, the above-mentioned first determination module 62 is also used to determine the target function service identifier of the target function service to be accessed by the target request based on the original domain name carried in the target request; when the target function service identifier is not located in the target list, determine not to intercept the target request, wherein the target list has multiple function service identifiers, and the function service corresponding to each function service identifier in the multiple function service identifiers corresponds to multiple data centers, and each of the multiple data centers is allowed to provide the function service.
[0117] In an exemplary embodiment, the first determination module 62 is further used to determine the target function service identifier of the target function service to be accessed by the target request according to the original domain name carried in the target request; when the target function service identifier is in the target list, detect whether the terminal device corresponding to the target application is located in a preset area, and / or detect whether the account currently logged in by the target application is a preset account, wherein the target list has multiple function service identifiers, and the function service corresponding to each function service identifier in the multiple function service identifiers corresponds to multiple data centers, and each of the multiple data centers allows the provision of the function service; the preset area is the area where the terminal device is located when the target application last sent a request corresponding to the target function service; the preset account is the account logged in by the target application when the target application last sent a request corresponding to the target function service, and the target application is running on the terminal device; when it is detected that the terminal device corresponding to the target application is not located in the preset area, determine to intercept the target request; and / or when it is detected that the account currently logged in by the target application is not the preset account, determine to intercept the target request.
[0118] In an exemplary embodiment, the above-mentioned second determination module 64 is also used to detect the target area where the terminal device corresponding to the target application is located; and determine the target function service to be accessed by the target request based on the original domain name carried in the target request, and determine multiple domain names corresponding to the target function service from the configuration file; determine the first target domain name from the multiple domain names based on the target area.
[0119] In an exemplary embodiment, the above-mentioned second determination module 64 is also used to detect the attribute information of the account currently logged in by the target application, wherein the attribute information includes the registration area of the account; and determine the target function service to be accessed by the target request based on the original domain name carried in the target request, and determine multiple domain names corresponding to the target function service from the configuration file; determine the first target domain name from the multiple domain names based on the attribute information.
[0120] In an exemplary embodiment, the above-mentioned device also includes: an acquisition module, which is used to determine whether the version of the configuration file in the server is consistent with the version of the configuration file in the target application before determining the first target domain name corresponding to the target request through the configuration file, wherein the latest version of the configuration file is stored in the server; when the version of the configuration file in the server is inconsistent with the version of the configuration file in the target application, the latest version of the configuration file is obtained from the server to replace the configuration file stored in the target application.
[0121] In an exemplary embodiment, the above-mentioned device also includes: a third determination module, which is used to determine whether the second target domain name corresponding to the target request is determined through the configuration file after sending the target request after the domain name replacement to the server, if the request response message of the target request is not obtained, or the request response message of the target request obtained is used to indicate a request failure; the sending module is also used to replace the first target domain name carried in the target request with the second target domain name, and send the target request to the server again when the second target domain name corresponding to the target request is determined through the configuration file; if the second target domain name corresponding to the target request is not determined through the configuration file, replace the first target domain name carried in the target request with the original domain name, and send the target request to the server again.
[0122] An embodiment of the present invention further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.
[0123] Optionally, in this embodiment, the storage medium may be configured to store a computer program for performing the following steps:
[0124] S1, when a target application sends a target request, determining whether to intercept the target request through an interceptor of the target application;
[0125] S2, in the case of determining to intercept the target request, determining a first target domain name corresponding to the target request through a configuration file, wherein the configuration file is used to query domain names corresponding to multiple functional services, and the requests corresponding to the multiple functional services include the target request;
[0126] S3: Replace the original domain name carried in the target request with the first target domain name, and send the target request after the domain name replacement to the server.
[0127] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0128] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.
[0129] An embodiment of the present invention further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0130] Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program:
[0131] S1, when a target application sends a target request, determining whether to intercept the target request through an interceptor of the target application;
[0132] S2, in the case of determining to intercept the target request, determining a first target domain name corresponding to the target request through a configuration file, wherein the configuration file is used to query domain names corresponding to multiple functional services, and the requests corresponding to the multiple functional services include the target request;
[0133] S3: Replace the original domain name carried in the target request with the first target domain name, and send the target request after the domain name replacement to the server.
[0134] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0135] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.
[0136] An embodiment of the present invention further provides a computer program product, including a computer program, and when the computer program is executed by a processor, the steps in any one of the above method embodiments are performed.
[0137] Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order than here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
[0138] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A request update method, characterized in that: include: In the case where the target application sends a target request, determining whether to intercept the target request through an interceptor of the target application; In the case of determining to intercept the target request, determining a first target domain name corresponding to the target request through a configuration file, wherein the configuration file is used to query domain names corresponding to multiple functional services, and the requests corresponding to the multiple functional services include the target request; The original domain name carried in the target request is replaced with the first target domain name, and the target request after the domain name replacement is sent to the server.
2. The request updating method according to claim 1, characterized in that: Determining whether to intercept the target request by the interceptor of the target application program includes: Determine the target function service identifier of the target function service to be accessed by the target request according to the original domain name carried in the target request; In the case that the target function service identifier is not in the target list, it is determined not to intercept the target request, wherein the target list has multiple function service identifiers, each of the multiple function service identifiers corresponds to a function service corresponding to multiple data centers, and each of the multiple data centers is allowed to provide the function service.
3. The request updating method according to claim 1, characterized in that: Determining whether to intercept the target request by the interceptor of the target application program includes: Determine the target function service identifier of the target function service to be accessed by the target request according to the original domain name carried in the target request; In the case where the target function service identifier is in the target list, detecting whether the terminal device corresponding to the target application is located in a preset area, and / or detecting whether the account currently logged in by the target application is a preset account, wherein the target list has multiple function service identifiers, and the function service corresponding to each function service identifier in the multiple function service identifiers corresponds to multiple data centers, and each of the multiple data centers is allowed to provide the function service; the preset area is the area where the terminal device is located when the target application last sent a request corresponding to the target function service; the preset account is the account logged in by the target application when the target application last sent a request corresponding to the target function service, and the target application is running on the terminal device; When it is detected that the terminal device corresponding to the target application is not located in the preset area, determine to intercept the target request; and / or when it is detected that the account currently logged in by the target application is not the preset account, determine to intercept the target request.
4. The request updating method according to claim 1, characterized in that: Determining a first target domain name corresponding to the target request through a configuration file includes: Detecting a target area where a terminal device corresponding to the target application is located; and Determine the target function service to be accessed by the target request according to the original domain name carried in the target request, and determine multiple domain names corresponding to the target function service from the configuration file; The first target domain name is determined from the plurality of domain names based on the target zone.
5. The request updating method according to claim 1, characterized in that: Determining a first target domain name corresponding to the target request through a configuration file includes: Detecting attribute information of an account currently logged in by the target application, wherein the attribute information includes a registration area of the account; and Determine the target function service to be accessed by the target request according to the original domain name carried in the target request, and determine multiple domain names corresponding to the target function service from the configuration file; The first target domain name is determined from the plurality of domain names based on the attribute information.
6. The request updating method according to claim 1, characterized in that: Before determining the first target domain name corresponding to the target request through the configuration file, the method further includes: Determine whether the version of the configuration file in the server is consistent with the version of the configuration file in the target application, wherein the server stores the latest version of the configuration file; When the version of the configuration file in the server is inconsistent with the version of the configuration file in the target application, the latest version of the configuration file is obtained from the server to replace the configuration file stored in the target application.
7. The request updating method according to claim 1, characterized in that: After sending the target request after the domain name replacement to the server, the method further includes: In a case where a request response message of the target request is not obtained, or the obtained request response message of the target request is used to indicate a request failure, determining whether a second target domain name corresponding to the target request is determined through the configuration file; In the case where the second target domain name corresponding to the target request is determined through the configuration file, the first target domain name carried in the target request is replaced with the second target domain name, and the target request is sent to the server again; In the case that the second target domain name corresponding to the target request is not determined through the configuration file, the first target domain name carried in the target request is replaced with the original domain name, and the target request is sent to the server again.
8. A request updating device, characterized in that: include: A first determination module, configured to determine whether to intercept the target request through an interceptor of the target application when the target application sends the target request; A second determination module is used to determine a first target domain name corresponding to the target request through a configuration file when it is determined to intercept the target request, wherein the configuration file is used to query domain names corresponding to multiple functional services, and the requests corresponding to the multiple functional services include the target request; The sending module is used to replace the original domain name carried in the target request with the first target domain name, and send the target request after the domain name replacement to the server.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein the program executes the method according to any one of claims 1 to 7 when executed.
10. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to execute the method according to any one of claims 1 to 7 through the computer program.
Citation Information
Cited By
APP multinational network request adaptation method and device, storage medium and terminal
CN119743533A
APP multi-country network request adaptation methods, devices, storage media and terminals
CN119743533B
Service request processing method and device, equipment, storage medium and program product
CN121664890A
