CN113961463A - Application environment switching method and system, storage medium and electronic equipment - Google Patents

Application environment switching method and system, storage medium and electronic equipment Download PDF

Info

Publication number
CN113961463A
CN113961463A CN202111262053.7A CN202111262053A CN113961463A CN 113961463 A CN113961463 A CN 113961463A CN 202111262053 A CN202111262053 A CN 202111262053A CN 113961463 A CN113961463 A CN 113961463A
Authority
CN
China
Prior art keywords
environment
target
request
switching
rule
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
Application number
CN202111262053.7A
Other languages
Chinese (zh)
Inventor
翟一鸣
饶恩慧
钱晶
周廉贵
冯春宇
肖宁
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Wodong Tianjun Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN202111262053.7A priority Critical patent/CN113961463A/en
Publication of CN113961463A publication Critical patent/CN113961463A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3696Methods or tools to render software testable
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3664Environments for testing or debugging software

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The present disclosure relates to the field of computer technologies, and in particular, to a method, an apparatus, a system, a storage medium, and an electronic device for switching application environments. The method comprises the following steps: responding to the environment switching operation of a user, and acquiring an item identifier and an environment request parameter of a current service request; screening a target switching rule from pre-configured switching rules and determining a target environment corresponding to the target switching rule according to the project identification and the environment request parameter; and judging whether to rewrite the current service request according to the target switching rule, and sending the current service request to the target environment for processing according to a judgment result. After various environment switching rules are customized, the target switching rules and the corresponding target environment can be determined based on the environment switching operation of the user, so that the service request is sent to the target environment for processing according to the target switching rules, the code intrusiveness is low, and the multi-test environment switching capability can be rapidly and simply endowed to the project.

Description

Application environment switching method and system, storage medium and electronic equipment
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to an application environment switching method, an application environment switching system, a computer storage medium, and an electronic device.
Background
In the iterative process of project research and development, developers or testers are generally required to debug projects in multiple application environments, for example, most projects have at least two environments, namely a test environment and a production environment, and part of projects also have a pre-release environment between the two environments, so that the same set of codes suitable for multiple environments needs to be realized through environment switching.
In the related art, a domain Name address query request sent by a browser to a Domain Name Server (DNS) is hijacked by tampering a local HOST (home Name System) file, and a domain Name IP (Internet Protocol) address queried by the browser is changed to a specific IP address for environment switching, but this method needs to determine whether modification is effective many times, which wastes development cycles; in another related technology, the seamless switching of the environments is realized by aggregating a plurality of environments, however, a large amount of network communication layer codes are required to be changed to realize the switching function, and the server side of all the environments needs to complete the configuration supporting the cross-domain request, so that the requirements on a third-party system are high, and the development period is long; in another related technology, environment switching is realized in a local research and development environment reverse proxy mode, but the switching logic of the environment switching can only be available in a local research and development environment, and the environment switching method is complex in configuration, poor in flexibility and even difficult to deploy in server side environments such as testing, pre-releasing and the like.
Therefore, it is required to provide a new application context switching method.
It is to be noted that the information invented in the background section above is only for enhancement of understanding of the background of the present disclosure, and thus may include information that does not constitute prior art known to those of ordinary skill in the art.
Disclosure of Invention
The present disclosure is directed to providing an application environment switching method and system, a computer storage medium, and an electronic device, thereby avoiding problems of a large development period, low development efficiency and flexibility, and a large code intrusion in the environment switching at least to some extent.
Additional features and advantages of the disclosure will be set forth in the detailed description which follows, or in part will be obvious from the description, or may be learned by practice of the disclosure.
According to an aspect of the present disclosure, there is provided an application environment switching method, including: responding to the environment switching operation of a user, and acquiring an item identifier and an environment request parameter of a current service request; screening a target switching rule from pre-configured switching rules and determining a target environment corresponding to the target switching rule according to the project identification and the environment request parameter; and judging whether to rewrite the current service request according to the target switching rule, and sending the current service request to the target environment for processing according to a judgment result.
In an exemplary embodiment of the present disclosure, the determining, according to the target switching rule, whether to rewrite the current service request, and sending the current service request to the target environment for processing according to a determination result includes: judging whether the current service request meets the verification rule of the target environment or not according to the configuration information; if yes, directly sending the current service request to the target environment for processing; if not, rewriting the current service request according to the target switching rule to obtain a service rewriting request, and sending the service rewriting request to the target environment for processing.
In an exemplary embodiment of the present disclosure, the rewriting the current service request according to the target switching rule to obtain a service rewriting request, and sending the service rewriting request to the target environment for processing includes: rewriting the request head of the service request according to the target switching rule, and correspondingly processing a request body according to the rewritten request head to obtain a service rewriting request; and sending the service rewriting request to the target environment for processing.
In an exemplary embodiment of the present disclosure, after the rewriting the current service request according to the target switching rule to obtain a service rewriting request, and sending the service rewriting request to the target environment for processing, the method further includes: receiving result response information returned by processing the service rewriting request in the target environment; according to a preset interception rule corresponding to the target switching rule, performing data definition transformation processing on the result response information to obtain a target response result; and feeding back the target response result to a user.
In an exemplary embodiment of the present disclosure, the screening a target switching rule from preconfigured switching rules and determining a target environment corresponding to the target switching rule according to the item identifier and the environment request parameter includes: determining a candidate switching rule under an environment corresponding to a project identifier from a corresponding relation between the pre-configured project identifier and the environment; and acquiring the target switching rule corresponding to the environment request parameter from the candidate switching rules, and determining the environment corresponding to the environment request parameter as the target environment.
In an exemplary embodiment of the present disclosure, before acquiring the item identifier and the environment request parameter of the current service request in response to the environment switching operation of the user, the method further includes: responding to the environment configuration operation of a user, and obtaining a plurality of environments of the current project and the corresponding relation between the environments and the environment request parameters; receiving a rule customization operation instruction initiated aiming at each environment, and generating a switching rule and an interception rule corresponding to each environment; the switching rule corresponding to each environment comprises configuration information of the corresponding environment.
In an exemplary embodiment of the disclosure, before the obtaining of the item identifier and the environment request parameter of the current service request in response to the environment switching operation of the user, the method further includes: providing interface request parameter information, and receiving the current service request forwarded based on the interface request parameter information.
According to an aspect of the present disclosure, there is provided an application environment switching system, the system including an application environment switching apparatus and a service configuration layer; the application environment switching device comprises: the information acquisition module is used for responding to the environment switching operation of the user and acquiring the project identification and the environment request parameter of the current service request; the rule environment determining module is used for screening a target switching rule from pre-configured switching rules according to the project identification and the environment request parameter and determining a target environment corresponding to the target switching rule; the service processing module is used for judging whether to rewrite the current service request according to the target switching rule and sending the current service request to the target environment for processing according to the judgment result; the service configuration layer is used for providing a visualized switching rule configuration platform for a user.
In an exemplary embodiment of the present disclosure, the target switching rule includes configuration information corresponding to a target environment, and the service processing module includes: the judging unit is used for judging whether the current service request meets the check rule of the target environment or not according to the configuration information; the processing unit is used for directly sending the current service request to the target environment for processing if the current service request meets the verification rule of the target environment; and the rewriting unit is used for rewriting the current service request according to the target switching rule to obtain a service rewriting request and sending the service rewriting request to the target environment for processing if the current service request does not meet the check rule of the target environment.
According to an aspect of the present disclosure, there is provided a computer storage medium having stored thereon a computer program which, when executed by a processor, implements the application environment switching method of any one of the above.
According to an aspect of the present disclosure, there is provided an electronic device including: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to perform any one of the above application environment switching methods via execution of the executable instructions.
According to the application environment switching method in the exemplary embodiment of the disclosure, according to the environment switching operation of a user, an item identifier and an environment request parameter of a current service request are obtained, so that a target switching rule is screened out from pre-configured switching rules and a corresponding target environment is determined, and therefore whether the current service request needs to be rewritten or not is judged according to the target switching rule, and the current service request is sent to the target environment to be processed according to a judgment result. On one hand, in the environment switching process, the specific implementation of environment switching is not required to be concerned, and additional functions such as dynamic domain name cross-domain support and the like are not required to be provided at the back end of the environment, so that a user only needs to select the environment to be switched, and the project identification and the environment request parameter of the current service request can be obtained according to the selection of the user so as to decide a target switching rule and a target environment, so that the service request is sent to the target environment for processing according to the target switching rule, and the environment switching efficiency and the flexibility are high; on the other hand, the environment switching rule can be customized aiming at the application needing to be accessed into the environment, the application has no technical stack requirement, the compatibility is good, the application code invasion is low, and the access cost is low; on the other hand, for the same project, a developer can rapidly realize the switching capability of multiple test environments given to the same project by customizing different switching rules, namely, the test or development under multiple environments is realized, and the manpower and material resources consumed by the research and development environment processing are reduced.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The above and other objects, features and advantages of exemplary embodiments of the present disclosure will become readily apparent from the following detailed description read in conjunction with the accompanying drawings. Several embodiments of the present disclosure are illustrated by way of example, and not by way of limitation, in the figures of the accompanying drawings and in which:
fig. 1 illustrates a flowchart of an application environment switching method according to an exemplary embodiment of the present disclosure;
FIG. 2 illustrates a flow chart for determining target switching rules and target contexts according to an exemplary embodiment of the present disclosure;
FIG. 3 depicts a flowchart of a process for sending a service rewrite request to a target environment for processing, according to an illustrative embodiment of the present disclosure;
FIG. 4 illustrates a flowchart of an application context switching method according to an exemplary embodiment of the present disclosure;
FIG. 5 is a diagram illustrating an environment switching framework implementation process according to an exemplary embodiment of the present disclosure;
fig. 6 shows a schematic structural diagram of an application environment switching apparatus according to an exemplary embodiment of the present disclosure;
FIG. 7 shows a schematic diagram of a storage medium according to an exemplary embodiment of the present disclosure; and
fig. 8 shows a block diagram of an electronic device according to an exemplary embodiment of the present disclosure.
In the drawings, the same or corresponding reference numerals indicate the same or corresponding parts.
Detailed Description
Exemplary embodiments will now be described more fully with reference to the accompanying drawings. The exemplary embodiments, however, may be embodied in many different forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concept of exemplary embodiments to those skilled in the art. The same reference numerals in the drawings denote the same or similar structures, and thus their detailed description will be omitted.
Furthermore, the described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of embodiments of the disclosure. One skilled in the relevant art will recognize, however, that the subject matter of the present disclosure can be practiced without one or more of the specific details, or with other methods, components, devices, steps, and so forth. In other instances, well-known structures, methods, devices, implementations, or operations are not shown or described in detail to avoid obscuring aspects of the disclosure.
The block diagrams shown in the figures are functional entities only and do not necessarily correspond to physically separate entities. That is, these functional entities may be implemented in the form of software, or in one or more software-hardened modules, or in different networks and/or processor devices and/or microcontroller devices.
The environment switching is a technical means for solving the problem of multi-environment fast switching applied to the modern Web (World Wide Web) by a mode of reverse proxy of a server and middle-layer data processing. In the related art, the following several ways are adopted to implement context switching:
(1) modifying native HOST bindings
The http(s) (Hyper Text Transfer Protocol) request principle is: the browser obtains an Application Programming Interface (API) domain name address by splitting a Uniform Resource Locator (URL) Protocol address character string in a code, initiates a domain name address query request to a Domain Name Server (DNS) agreed in a network, returns an IP address for querying a domain name by the DNS, and initiates a Transmission Control Protocol (TCP) connection to the IP address by the browser, so as to exchange data;
(2) front-end network interaction layer multi-address switching
By modifying a front-end interface layer, adding remote address switching selection logic to aggregate a plurality of environments to realize environment seamless;
(3) local research and development environment reverse proxy
The reverse proxy is to forward the request to different environment interfaces in a proxy forwarding manner, for example, the front end can solve the problem of multi-environment switching by configuring a webpack (a front end research and development package, local service framework) or an ad hoc express (a Node JS (browser scripting language based language environment)) local service manner.
However, the related art in the art has the following drawbacks:
(1) modifying native HOST bindings
The browser domain name resolution has cache, the operating system also has the cache problem, and the modification of the HOST file of the system often needs to confirm whether the HOST file is effective for many times, so that the development period is wasted; in addition, in the mobile application development, in the real machine testing stage, the HOST file of the mobile terminal (such as a mobile phone) is difficult to modify, so that the debugging difficulty is increased;
(2) front-end network interaction layer multi-address switching
The method has the advantages that the method has high intrusiveness on the front-end codes, a large amount of network communication layer codes need to be changed to add a switching function, all environment servers are required to be configured to support cross-domain requests, the requirements on a third-party system are high, the development period is long, and the development experience is poor;
(3) local research and development environment reverse proxy
The switching logic can only be available in a local research and development environment, and has complex configuration, poor flexibility and even difficult deployment in server environments such as testing, pre-release and the like, and the deployment cost is higher.
Based on this, in the exemplary embodiment of the present disclosure, there is first provided an application environment switching method applied to a server (hereinafter, referred to as a core interface service), the application environment switching method including the steps of:
step S110: responding to the environment switching operation of a user, and acquiring an item identifier and an environment request parameter of a current service request;
step S120: screening a target switching rule from pre-configured switching rules and determining a target environment corresponding to the target switching rule according to the project identification and the environment request parameter;
step S130: and judging whether to rewrite the current service request according to the target switching rule, and sending the current service request to the target environment for processing according to a judgment result.
According to the application environment switching method in the embodiment, on one hand, in the environment switching process, the specific implementation of environment switching is not required to be concerned, and additional functions such as dynamic domain name cross-domain support and the like are not required to be provided at the environment rear end, and a user only needs to select the environment to be switched, so that the item identifier and the environment request parameter of the current service request can be obtained according to the selection of the user to decide a target switching rule and a target environment, the service request is sent to the target environment according to the target switching rule to be processed, and the environment switching efficiency and the flexibility are high; on the other hand, the environment switching rule can be customized aiming at the application needing to be accessed into the environment, the application has no technical stack requirement, the compatibility is good, the application code invasion is low, and the access cost is low; on the other hand, for the same project, a developer can rapidly realize the switching capability of multiple test environments given to the same project by customizing different switching rules, namely, the test or development under multiple environments is realized, and the manpower and material resources consumed by the research and development environment processing are reduced.
The application context switching method in the exemplary embodiment of the present disclosure is further described below with reference to fig. 1.
In step S110, in response to the environment switching operation of the user, the item identifier and the environment request parameter of the current service request are acquired.
In an exemplary embodiment of the present disclosure, the context switching operation of the user includes a process of accessing the current service request to an application context switching device (hereinafter, referred to as a core interface service), and processing the current service request through the core interface service. Specifically, when a main application (to-be-accessed application) is loaded, a user judges whether environment switching is needed according to the current application environment, and if so, the environment switching operation is executed: firstly, interface request entry data is adjusted to provide interface request parameter information for core interface services, so that service requests are forwarded to the core interface services, wherein the core interface services are service frameworks based on Node JS Web and can provide high concurrency support for project development. For example, when the main application is loaded, the core interface service generates interface request parameter information (base address), and when the environment needs to be switched, the base address of the interface request entry data is pointed to the base address generated by the core interface service, such as a BaseUrl field value.
The API is a set of definitions, programs and protocols, and can realize the intercommunication between computer software, and the main function is to provide a function set for providing a set of routines which can be accessed by application programs and developers based on certain software or hardware without accessing source codes or understanding the details of internal working mechanisms. Application programming interface APIs in the present disclosure include, but are not limited to XHR, Fetch, where Fetch provides a JavaScript interface for accessing and manipulating specific parts of the HTTP pipe, such as requests and responses; XHR is a browser API that is based on the fact that XHR developers do not need to be concerned with the underlying implementation, but rather do so by the browser, such as connection management, protocol negotiation, HTTP request formatting, etc. The service request can be accessed to the corresponding core interface service by adjusting the interface request parameter information.
Further, after the current service request is forwarded to the core interface service, acquiring an item identifier and an environment request parameter of the current service request according to the environment switching operation of the user; the item identification is unique identification information for identifying the iterative item, and can be numbers, letters, characters or a combination of data, characters or characters, the same item can comprise a plurality of environments and corresponding environment request parameters, and the form of the item identification and the number of the environments under the same item are not specially limited by the method; the context request parameter identifies the context of the handover required by the currently accessed application. Specifically, a plurality of environment options can be provided for a user, the user selects an environment through operations such as clicking, dragging, selecting and the like, and then determines a corresponding item identifier and an environment request parameter according to a target environment option selected by the user.
In an exemplary embodiment of the present disclosure, before performing the context switching operation, context configuration may be performed and switching rules may be configured for different applications to be accessed. Specifically, first, in response to an environment configuration operation of a user, a plurality of environments of a current item, a corresponding relationship between the environments and an environment request parameter are obtained, for example, a dragging, selecting or typing mode is performed through a visual interface, which is not particularly limited by the present disclosure; secondly, receiving a rule customization operation instruction initiated aiming at each environment, and generating a switching rule and an interception rule corresponding to each environment; the switching rule corresponding to each environment comprises configuration information of the corresponding environment. The following table 1 shows the corresponding relationship among the item identifier, the environment request parameter, the switching rule and the interception rule:
TABLE 1
Figure BDA0003326117800000081
Figure BDA0003326117800000091
Referring to table 1, a user may configure the corresponding relationship among the item identifier, the environment request parameter, the switching rule, and the interception rule shown in table 1 through a visual interface, that is, a plurality of environments may be configured for a same item, and each environment has a corresponding environment request parameter, switching rule, and interception rule, for example, the item identifier 1 of a certain item corresponds to three environments (environment 1, environment 2, and environment 3, respectively), and each environment has a corresponding environment request parameter, switching rule, and interception rule. It should be noted that table 1 is only an example, the number of environments included in the same item may be 2, 3, and the like, and the number of environments corresponding to the item is not particularly limited in the present disclosure.
The method and the device can customize the environment switching rule aiming at the application needing to be accessed, and because the service of the method and the device is constructed based on the native language, the environment switching has no any technical stack requirement on the application needing to be accessed, the compatibility is good, the code intrusiveness to the application is low, and the access cost is low. For example, a user may configure a platform based on a visualized switching rule, and perform a customization operation of an environment and a corresponding switching rule by dragging a development tool in a toolkit, directly typing, and the like. As only the environment switching rule needs to be configured, the manpower and material resources consumed by environment development and development processing are greatly reduced.
In step S120, a target switching rule is screened from the pre-configured switching rules according to the item identifier and the environment request parameter, and a target environment corresponding to the target switching rule is determined.
In the exemplary embodiment of the present disclosure, a plurality of environments may be configured for the same project, and each environment corresponds to a different switching rule, and as can be seen from step S110, the present disclosure may customize and store the switching rule according to the application to be accessed. Based on this, as shown in fig. 2, the steps of screening out a target switching rule from preconfigured switching rules and determining a target environment corresponding to the target switching rule according to the project identifier and the environment request parameter include:
in step S210, a candidate switching rule in an environment corresponding to the item identifier is determined from the correspondence between the pre-configured item identifier and the environment.
In the exemplary embodiment of the present disclosure, since different projects are configured with different environments, and the same project is configured with a plurality of switching rules, and target environments required by different users under the same project are also different, first, according to a project identifier in a service request, a candidate switching rule corresponding to the project identifier is obtained. For example, the item id1 is configured with a production environment 1, a test environment 1, and a pre-release environment 1, corresponding to a switching rule 1a, a switching rule 2a, and a switching rule 3a, respectively, the item id2 is configured with a production environment 2, a test environment 2, and a pre-release environment 2, corresponding to a switching rule 1b, a switching rule 2b, and a switching rule 3b, respectively, then the candidate switching rule is determined to be "switching rule 1, switching rule 2 and switching rule 3" for the item identifier "id 1" carried in the service request sent by user a, the candidate switching rule is also determined to be "switching rule 1a, switching rule 2a and switching rule 3 a" for the item identifier "id 1" carried in the service request sent by user B, and the candidate switching rules are determined to be "switching rule 1b, switching rule 2b and switching rule 3 b" for the item identifier "id 2" carried in the service request sent by the user C.
In step S220, a target switching rule corresponding to the environment request parameter is obtained from the candidate switching rules, and an environment corresponding to the environment request parameter is determined as a target environment.
In the exemplary embodiment of the present disclosure, a target switching rule corresponding to an environment request parameter carried in a current service request is obtained from candidate switching rules under the same item. Continuing to refer to the example in step S210, if the candidate switching rules obtained by the user a and the user B are the same and are "switching rule 1a, switching rule 2a, and switching rule 3 a", the target switching rules required by the user a and the user B are continuously determined according to the environment request parameters, if the user a is a production environment and the user B is a test environment. Further, the environment corresponding to the environment request parameter is determined as the target handover environment based on the corresponding relationship between the environment request parameter and the environment.
Based on this, because the current service request carries the project identification and the environment request parameter, the target switching rule required by different service requests of different users can be accurately determined, so that the environment switching can be completed after the user selects the target environment to be switched through environment switching operations such as clicking, selecting and the like, the environment switching efficiency is high, and the overall influence on the project is small.
In step S130, it is determined whether to perform a rewrite operation on the current service request according to the target switching rule, and the current service request is sent to the target environment for processing according to the determination result.
In an exemplary embodiment of the present disclosure, the target switching rule includes configuration information corresponding to the target environment, and it may be determined whether the current service request satisfies a check rule of the target environment according to the configuration information, for example, whether a data format of the current service request satisfies a request format of the target environment, and the like; if the current service request is not satisfied, the current service request is rewritten according to the target switching rule to obtain a service rewriting request, and the service rewriting request is sent to the target environment for processing. The rewriting is to rewrite the implementation process of the method allowing access so that the service request meets the check rule of the accessed service and access is performed. Specifically, first, a request header of the service request may be rewritten according to a target switching rule; secondly, the request body is processed correspondingly according to the rewritten request head to obtain a service rewriting request, for example, the request head source of the service request is modified, and the format of the request body is converted into the format of the request body required by the request head source according to the modified request head source, such as the adjustment of a parameter list or a structural body form; and finally, sending the service rewriting request to a target environment for processing, namely, sending the service rewriting request to the target environment if the service rewriting request meets the check rule of the target environment.
Further, fig. 3 shows a flowchart of sending a service rewrite request to a target environment for processing according to an exemplary embodiment of the present disclosure, and as shown in fig. 3, the process includes the following steps:
in step S310, receiving result response information returned by the processing service rewriting request in the target environment;
in an exemplary embodiment of the present disclosure, a service rewrite request is processed in a target environment, and result response information is returned.
In step S320, according to a preset interception rule corresponding to the target switching rule, performing data definition transformation processing on the result response information to obtain a target response result;
in an exemplary embodiment of the present disclosure, the interception rule is an inverse process of the corresponding target switching rule, and before forwarding the result response information to the user, the result response information is processed based on the interception rule, so that the result response information can be successfully received by the user. In some possible implementation manners, corresponding request interceptors are configured for each environment, so that the result response information is subjected to definition transformation through the request interceptors. Therefore, through the combination of the switching rules of the environment and the request interceptor, the service request can meet the check rules of various environments, and a complete multi-environment switching project can be constructed.
In step S330, the target response result is fed back to the user.
In an exemplary embodiment of the present disclosure, the result response information defining the transformed result and conforming to the user-side information receiving rule is fed back to the user.
Fig. 4 is a flowchart illustrating an application environment switching method according to an exemplary embodiment of the present disclosure, and the following describes the application environment switching method of the present disclosure as a whole by taking multi-environment switching (service needs to be rewritten) under a certain main application as an example with reference to fig. 4.
In step S410, a service script is introduced into the main application and accessed to the application interface layer, that is, when the main application is loaded, the core interface service generates a basic address (interface request parameter information), and if the developer determines that the environment switching service is needed according to the current application environment, the developer modifies the interface request entry data and directs the basic address to the interface request parameter information provided by the core interface service; thus, the service request can be forwarded to the core interface service through the application front end;
in step S420, the user may log in the service configuration center, complete user registration in the service configuration center, and configure the environment, switching rule, interception rule, etc. of the required access application;
in step S430, in response to the environment switching operation of the user, switching the environment to a target environment, and rewriting the service request forwarded by the front end according to a target switching rule corresponding to the target environment to obtain a service rewriting request, so as to send the service rewriting request to the target environment a or environment B, and so on;
in step S440, after the result response information returned by the service rewriting request is processed in the target environment (environment a or environment B, etc.), the result response information is subjected to definition transformation processing according to the preset interception rule corresponding to the target switching rule to obtain a target response result, so that the target response result is fed back to the user.
Fig. 5 is a schematic diagram illustrating an implementation process of an environment switching framework according to an exemplary embodiment of the present disclosure, and as shown in fig. 5, an application to be accessed is accessed in a manner of importing, installing and initializing a third party package (e.g., an SDK) provided by the framework, where whether to perform environment switching and expose multiple environments to be switched are determined according to configuration information of a current environment, and if necessary, a HOOK may take over an API by manually modifying interface request parameter information, that is, connecting the application to be accessed to a core interface service (API).
In the application environment switching method in the embodiment of the present invention, in the environment switching process, it is not necessary to pay attention to specific implementation of environment switching, and it is also not necessary to provide additional functions such as dynamic domain name cross-domain support at the environment back end, and a user only needs to select an environment to be switched, and can obtain an item identifier and an environment request parameter of a current service request according to the selection of the user to decide a target switching rule and a target environment, so as to send the service request to the target environment for processing according to the target switching rule, and the environment switching efficiency and flexibility are high; the environment switching rule can be customized aiming at the application needing to be accessed into the environment, the application has no any technical stack requirement, the compatibility is good, the application code invasion is low, and the access cost is low; aiming at the same project, a developer can rapidly realize the switching capability of multiple testing environments given by the same project by customizing different switching rules, namely, the testing or the development under the multiple environments is realized, and the manpower and material resources consumed by the research and development environment processing are reduced.
In an exemplary embodiment of the present disclosure, an application environment switching system is also provided. The application environment switching system can comprise an application environment switching device and a service configuration layer; the application environment switching device 610 includes:
an information obtaining module 6101, configured to respond to the environment switching operation of the user, obtain an item identifier and an environment request parameter of the current service request;
a rule environment determination module 6102, configured to screen out a target switching rule from preconfigured switching rules and determine a target environment corresponding to the target switching rule according to the project identifier and the environment request parameter;
a service processing module 6103, configured to determine whether to perform a rewrite operation on the current service request according to the target switching rule, and send the current service request to the target environment for processing according to the determination result;
and the service configuration layer is used for providing a visualized switching rule configuration platform for a user.
In an exemplary embodiment of the disclosure, the target switching rule includes configuration information corresponding to the target environment, and the service processing module 6103 may include:
the judging unit is used for judging whether the current service request meets the check rule of the target environment or not according to the configuration information;
the processing unit is used for directly sending the current service request to the target environment for processing if the current service request meets the verification rule of the target environment;
and the rewriting unit is used for rewriting the current service request according to the target switching rule to obtain a service rewriting request and sending the service rewriting request to the target environment for processing if the current service request does not meet the check rule of the target environment.
In an exemplary embodiment of the present disclosure, the rewriting unit may further include:
the rewriting processing unit is used for rewriting a request head of the service request according to the target switching rule and corresponding to a processing request body according to the rewritten request head to obtain a service rewriting request;
and the sending unit is used for sending the service rewriting request to the target environment for processing.
In an exemplary embodiment of the present disclosure, the application environment switching device 610 may further include:
the information receiving module is used for receiving result response information returned by processing the service rewriting request in the target environment;
the data definition module is used for carrying out data definition transformation processing on the result response information according to a preset interception rule corresponding to the target switching rule to obtain a target response result;
and the result feedback module is used for feeding back the target response result to the user.
In an exemplary embodiment of the disclosure, the service processing module 6103 may include:
the candidate switching rule determining unit is used for determining a candidate switching rule under the environment corresponding to the item identifier from the corresponding relation between the preset item identifier and the environment;
and the target environment determining unit is used for acquiring the target switching rule corresponding to the environment request parameter from the candidate switching rules and determining the environment corresponding to the environment request parameter as the target environment.
In an exemplary embodiment of the present disclosure, the application environment switching device 610 may further include:
the environment configuration module is used for responding to the environment configuration operation of the user and obtaining a plurality of environments of the current project and the corresponding relation between the environments and the environment request parameters;
the rule generating module is used for receiving a rule customizing operation instruction initiated aiming at each environment and generating a switching rule and an interception rule corresponding to each environment;
the switching rule corresponding to each environment comprises configuration information of the corresponding environment.
The service configuration layer is used for providing a visual switching rule configuration platform and provides functions of user registration, environment creation and deletion, switching rule customization, interception rule customization and the like. For example, a developer may register an account in a service configuration layer, create a project, configure a plurality of environments under the project, configure corresponding switching rules and interception rules for each environment, and implement data transformation by using the switching rules and the interception rules, so that data requested to go and go can satisfy verification rules under various environments, for example, modify a request header source to be verified through an interface firewall. Based on the method, a user can construct a complete multi-environment switching project, so that the project is rapidly endowed with the multi-test environment switching capability.
Since each functional module of the application environment switching system in the exemplary embodiment of the present disclosure is the same as that in the embodiment of the application environment switching method, it is not described herein again.
It should be noted that although in the above detailed description reference is made to several modules or units of the application context switching system, such a division is not mandatory. Indeed, the features and functionality of two or more modules or units described above may be embodied in one module or unit, according to embodiments of the present disclosure. Conversely, the features and functions of one module or unit described above may be further divided into embodiments by a plurality of modules or units.
In addition, in the exemplary embodiments of the present disclosure, a computer storage medium capable of implementing the above method is also provided. On which a program product capable of implementing the above-described method of the present specification is stored. In some possible embodiments, aspects of the present disclosure may also be implemented in the form of a program product comprising program code for causing a terminal device to perform the steps according to various exemplary embodiments of the present disclosure described in the "exemplary methods" section above of this specification, when the program product is run on the terminal device.
Referring to fig. 7, a program product 700 for implementing the above method according to an exemplary embodiment of the present disclosure is described, which may employ a portable compact disc read only memory (CD-ROM) and include program code, and may be run on a terminal device, such as a personal computer. However, the program product of the present disclosure is not limited thereto, and in this document, a readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
The program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the readable storage medium include: an electrical connection having one or more wires, a portable disk, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
A computer readable signal medium may include a propagated data signal with readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A readable signal medium may also be any readable medium that is not a readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Program code for carrying out operations for the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computing device, partly on the user's device, as a stand-alone software package, partly on the user's computing device and partly on a remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computing device (e.g., through the internet using an internet service provider).
In addition, in an exemplary embodiment of the present disclosure, an electronic device capable of implementing the above method is also provided. As will be appreciated by one skilled in the art, aspects of the present disclosure may be embodied as a system, method or program product. Accordingly, various aspects of the present disclosure may be embodied in the form of: an entirely hardware embodiment, an entirely software embodiment (including firmware, microcode, etc.) or an embodiment combining hardware and software aspects that may all generally be referred to herein as a "circuit," module "or" system.
An electronic device 800 according to such an embodiment of the disclosure is described below with reference to fig. 8. The electronic device 800 shown in fig. 8 is only an example and should not bring any limitations to the functionality and scope of use of the embodiments of the present disclosure.
As shown in fig. 8, electronic device 800 is in the form of a general purpose computing device. The components of the electronic device 800 may include, but are not limited to: the at least one processing unit 810, the at least one memory unit 820, a bus 830 connecting different system components (including the memory unit 820 and the processing unit 810), and a display unit 840.
Wherein the storage unit stores program code that is executable by the processing unit 810 to cause the processing unit 810 to perform steps according to various exemplary embodiments of the present disclosure as described in the "exemplary methods" section above in this specification.
The storage unit 820 may include readable media in the form of volatile memory units such as a random access memory unit (RAM)8201 and/or a cache memory unit 8202, and may further include a read only memory unit (ROM) 8203.
The storage unit 820 may also include a program/utility 8204 having a set (at least one) of program modules 8205, such program modules 8205 including, but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which, or some combination thereof, may comprise an implementation of a network environment.
Bus 830 may be any of several types of bus structures including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
The electronic device 800 may also communicate with one or more external devices 900 (e.g., keyboard, pointing device, bluetooth device, etc.), with one or more devices that enable a user to interact with the electronic device 800, and/or with any devices (e.g., router, modem, etc.) that enable the electronic device 800 to communicate with one or more other computing devices. Such communication may occur via input/output (I/O) interfaces 850. Also, the electronic device 800 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network, such as the internet) via the network adapter 860. As shown, the network adapter 860 communicates with the other modules of the electronic device 800 via the bus 830. It should be appreciated that although not shown, other hardware and/or software modules may be used in conjunction with the electronic device 800, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.
Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein may be implemented by software, or by software in combination with necessary hardware. Therefore, the technical solution according to the embodiments of the present disclosure may be embodied in the form of a software product, which may be stored in a non-volatile storage medium (which may be a CD-ROM, a usb disk, a removable hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which may be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the embodiments of the present disclosure.
Furthermore, the above-described figures are merely schematic illustrations of processes included in methods according to exemplary embodiments of the present disclosure, and are not intended to be limiting. It will be readily understood that the processes shown in the above figures are not intended to indicate or limit the chronological order of the processes. In addition, it is also readily understood that these processes may be performed synchronously or asynchronously, e.g., in multiple modules.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is to be limited only by the terms of the appended claims.

Claims (11)

1. An application environment switching method, comprising:
responding to the environment switching operation of a user, and acquiring an item identifier and an environment request parameter of a current service request;
screening a target switching rule from pre-configured switching rules and determining a target environment corresponding to the target switching rule according to the project identification and the environment request parameter;
and judging whether to rewrite the current service request according to the target switching rule, and sending the current service request to the target environment for processing according to a judgment result.
2. The method according to claim 1, wherein the target switching rule includes configuration information corresponding to a target environment, and the determining, according to the target switching rule, whether to rewrite the current service request and sending the current service request to the target environment for processing according to a determination result includes:
judging whether the current service request meets the verification rule of the target environment or not according to the configuration information;
if yes, directly sending the current service request to the target environment for processing;
if not, rewriting the current service request according to the target switching rule to obtain a service rewriting request, and sending the service rewriting request to the target environment for processing.
3. The method according to claim 2, wherein the rewriting the current service request according to the target switching rule to obtain a service rewriting request, and sending the service rewriting request to the target environment for processing includes:
rewriting the request head of the service request according to the target switching rule, and correspondingly processing a request body according to the rewritten request head to obtain a service rewriting request;
and sending the service rewriting request to the target environment for processing.
4. The method of claim 2, wherein after the rewriting the current service request according to the target switching rule to obtain a service rewriting request and sending the service rewriting request to the target environment for processing, the method further comprises:
receiving result response information returned by processing the service rewriting request in the target environment;
according to a preset interception rule corresponding to the target switching rule, performing data definition transformation processing on the result response information to obtain a target response result;
and feeding back the target response result to a user.
5. The method according to claim 1, wherein the screening out a target switching rule from preconfigured switching rules and determining a target environment corresponding to the target switching rule according to the item identifier and the environment request parameter comprises:
determining a candidate switching rule under an environment corresponding to a project identifier from a corresponding relation between the pre-configured project identifier and the environment;
and acquiring the target switching rule corresponding to the environment request parameter from the candidate switching rules, and determining the environment corresponding to the environment request parameter as the target environment.
6. The method of claim 4, wherein before the obtaining of the item identifier and the context request parameter of the current service request in response to the context switch operation of the user, the method further comprises:
responding to the environment configuration operation of a user, and obtaining a plurality of environments of the current project and the corresponding relation between the environments and the environment request parameters;
receiving a rule customization operation instruction initiated aiming at each environment, and generating a switching rule and an interception rule corresponding to each environment;
the switching rule corresponding to each environment comprises configuration information of the corresponding environment.
7. The method according to any one of claims 1 to 6, wherein before the obtaining of the item identifier and the environment request parameter of the current service request in response to the user's environment switching operation, the method further comprises:
providing interface request parameter information, and receiving the current service request forwarded based on the interface request parameter information.
8. An application environment switching system, characterized in that the system comprises an application environment switching device and a service configuration layer;
the application environment switching device comprises:
the information acquisition module is used for responding to the environment switching operation of the user and acquiring the project identification and the environment request parameter of the current service request;
the rule environment determining module is used for screening a target switching rule from pre-configured switching rules according to the project identification and the environment request parameter and determining a target environment corresponding to the target switching rule;
the service processing module is used for judging whether to rewrite the current service request according to the target switching rule and sending the current service request to the target environment for processing according to a judgment result;
the service configuration layer is used for providing a visualized switching rule configuration platform for a user.
9. The system of claim 8, wherein the target handover rule includes configuration information corresponding to a target environment, and wherein the service processing module comprises:
the judging unit is used for judging whether the current service request meets the check rule of the target environment or not according to the configuration information;
the processing unit is used for directly sending the current service request to the target environment for processing if the current service request meets the verification rule of the target environment;
and the rewriting unit is used for rewriting the current service request according to the target switching rule to obtain a service rewriting request and sending the service rewriting request to the target environment for processing if the current service request does not meet the check rule of the target environment.
10. A storage medium having stored thereon a computer program which, when executed by a processor, implements the application environment switching method according to any one of claims 1 to 7.
11. An electronic device, comprising:
a processor; and
a memory for storing executable instructions of the processor;
wherein the processor is configured to perform the application context switching method of any one of claims 1 to 7 via execution of the executable instructions.
CN202111262053.7A 2021-10-28 2021-10-28 Application environment switching method and system, storage medium and electronic equipment Pending CN113961463A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111262053.7A CN113961463A (en) 2021-10-28 2021-10-28 Application environment switching method and system, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111262053.7A CN113961463A (en) 2021-10-28 2021-10-28 Application environment switching method and system, storage medium and electronic equipment

Publications (1)

Publication Number Publication Date
CN113961463A true CN113961463A (en) 2022-01-21

Family

ID=79468157

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111262053.7A Pending CN113961463A (en) 2021-10-28 2021-10-28 Application environment switching method and system, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN113961463A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114465960A (en) * 2022-02-07 2022-05-10 北京沃东天骏信息技术有限公司 Flow switching method and device and storage medium
CN115277662A (en) * 2022-07-23 2022-11-01 杭州迪普科技股份有限公司 Agent service switching test method, system, electronic equipment and readable medium
CN115842749A (en) * 2022-11-24 2023-03-24 中电信数智科技有限公司 Test environment switching method, device and system

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114465960A (en) * 2022-02-07 2022-05-10 北京沃东天骏信息技术有限公司 Flow switching method and device and storage medium
CN115277662A (en) * 2022-07-23 2022-11-01 杭州迪普科技股份有限公司 Agent service switching test method, system, electronic equipment and readable medium
CN115277662B (en) * 2022-07-23 2023-05-23 杭州迪普科技股份有限公司 Proxy service switching test method, system, electronic equipment and readable medium
CN115842749A (en) * 2022-11-24 2023-03-24 中电信数智科技有限公司 Test environment switching method, device and system

Similar Documents

Publication Publication Date Title
CN110198247B (en) Interface test method and system
US10244058B2 (en) Extending functionality of applications
CN113961463A (en) Application environment switching method and system, storage medium and electronic equipment
JP5171790B2 (en) Information processing apparatus, communication system, and program
RU2456768C2 (en) Device to control content distribution, terminal, software and system of content distribution
US7900214B2 (en) System and method for adaptable provisioning of generic application content
CN103150513B (en) The method of the implantation information in interception application program and device
CN105337787A (en) Multi-server monitoring method, device and system
CN110011875B (en) Dial testing method, device, equipment and computer readable storage medium
CN113055492A (en) Control method and device for service gray scale link, computer equipment and storage medium
US8387039B2 (en) System and method for customized provisioning of application content
US20170033980A1 (en) Agent manager for distributed transaction monitoring system
CN113014681A (en) Network card binding method and device of multi-network card server, electronic equipment and storage medium
CN103885775A (en) Method and device for obtaining driver file
CN100465950C (en) Web browser command button for client support
CN104375831A (en) Method, device and system realizing communication between webpage and applications on terminal equipment
CN116561013B (en) Testing method and device based on target service framework, electronic equipment and medium
CN111654548A (en) Method, device and system for downloading patch file and electronic equipment
CN114915565A (en) Method and system for debugging network
JP2007122691A (en) Information processor, information processing method and program
CN114416169A (en) Data processing method, medium, device and computing equipment based on micro front end
KR20220108967A (en) Method for generating application for controlling external electronic device and electronic apparatus for supporting the same
CN112486484A (en) Webpage version generation method and device
KR20100006497A (en) Method and system constituting web desktop framework
JP2021033316A (en) Scenario providing system, scenario providing apparatus, scenario information providing method, and program

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