Business request processing method, device, equipment and medium
By preconfiguring the main processing logic and determining the implementation strategy, the problem of poor CGI reusability is solved, the service request processing of multiple network protocols is realized, and code development is simplified.
Patent Information
- Application Number
- CN202110725546.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-29
- Publication Date
- 2025-03-04
- Estimated Expiration
- 2041-06-29
AI Technical Summary
When existing servers are compatible with multiple network protocols, CGI has poor reusability, resulting in the need to develop multiple CGIs, which increases the complexity of code development.
By preconfiguring the main processing logic, the implementation strategies of each first subprocessing logic are determined according to the network protocol of the target service request, and the service request processing of multiple types of network protocols is realized, and the reusability of CGI is improved.
It realizes service request processing for multiple network protocols, improves the reusability of CGI, simplifies the code development of CGI, and reduces the difficulty of development.
Smart Images

Figure CN115550468B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device, equipment and medium for processing a business request. Background Art
[0002] Common Gateway Interface (CGI) refers to the application programming interface (API) provided by a server to external devices, such as mobile phones or IoT devices. Different external devices may use different network protocols to access the server, such as Hyper Text Transfer Protocol (HTTP) or Message Queuing Telemetry Transport (MQTT), which requires the server to have certain compatibility.
[0003] Currently, servers generally create multiple CGIs, each CGI is used to adapt to the corresponding network protocol, so that the server can be compatible with more network protocols, but each CGI can only handle the corresponding network protocol, that is, the reusability of a single CGI is poor. Summary of the invention
[0004] The embodiments of the present application provide a service request processing method, apparatus, device and medium for improving the reusability of CGI.
[0005] On the one hand, a service request processing method is provided, comprising:
[0006] Obtaining a target network protocol corresponding to a target service request;
[0007] Based on the target network protocol, determining first implementation strategies of the plurality of first sub-processing logics in the main processing logic, wherein the main processing logic includes a first main process commonly used when performing protocol parsing on multiple types of service requests, the first main process includes the plurality of first sub-processing logics, and the main processing logic is pre-configured, and one type of service request among the multiple types of service requests corresponds to one network protocol;
[0008] Based on the obtained multiple first implementation strategies, executing the first main process on the target business request to obtain a parsing result of the target business request;
[0009] Based on the analysis result, the target service request is processed accordingly.
[0010] The present application provides a service request processing device, including:
[0011] A protocol acquisition module, used to obtain a target network protocol corresponding to a target service request;
[0012] a strategy determination module, configured to determine, based on the target network protocol, a first implementation strategy of each of a plurality of first sub-processing logics in the main processing logic, wherein the main processing logic includes a first main process commonly used when performing protocol parsing on multiple types of service requests, the first main process includes the multiple first sub-processing logics, and the main processing logic is pre-configured, and one type of service request among the multiple types of service requests corresponds to one network protocol;
[0013] A process execution module, configured to execute the first main process on the target business request based on the obtained multiple first implementation strategies, and obtain a parsing result of the target business request;
[0014] The service execution module is used to process the target service request accordingly based on the analysis result.
[0015] In a possible embodiment, the policy determination module is specifically used to:
[0016] Determine a first execution mode corresponding to the target business request from an execution mode set, wherein each execution mode in the execution mode set indicates that when parsing a type of business request, at least one first sub-processing logic among the multiple first sub-processing logics is implemented as non-empty, and at least one first sub-processing logic is implemented as empty, and the empty-implemented first sub-processing logic means that an input when executing the first sub-processing logic is the same as an output after executing the first sub-processing logic;
[0017] Based on the target network protocol, the first implementation strategy for the first sub-processing logic of each non-empty implementation and the first implementation strategy for the first sub-processing logic of each empty implementation are determined from the implementation strategy set, wherein each implementation strategy in the implementation strategy set is an implementation method of a sub-processing logic, and the first implementation strategy corresponding to the first sub-processing logic of each empty implementation is used for the first sub-processing logic corresponding to the empty implementation.
[0018] In a possible embodiment, the device further includes a writing module, wherein the writing module is specifically configured to:
[0019] Writing a second execution mode of a newly added type of business request into the execution mode set, wherein the second execution mode includes at least one first type of sub-processing logic with a non-empty implementation and at least one second type of sub-processing logic with an empty implementation among the multiple sub-processing logics when parsing the newly added type of business request;
[0020] The newly added implementation strategy is written into the implementation strategy set, wherein the newly added implementation strategy is a newly added implementation method of a sub-processing logic.
[0021] In a possible embodiment, the main processing logic further includes the execution order of the multiple first sub-processing logics, the multiple first sub-processing logics include a first unified package conversion sub-process, a session verification sub-process, a decompression sub-process and a deserialization sub-process, and the multiple first implementation strategies include a first package conversion method corresponding to the unified package conversion sub-process, a session verification method corresponding to the session verification sub-process, a decompression method corresponding to the decompression sub-process, and a deserialization method corresponding to the deserialization sub-process; the process execution module is specifically used to:
[0022] Based on the multiple first implementation strategies and in the execution order, the following multiple sub-processing logics are executed for the service request:
[0023] Based on the first packet conversion method, the first unified packet conversion sub-process is executed on the target network protocol and the target service request to obtain a unified packet that complies with preset rules;
[0024] Based on the session verification method, executing a session verification sub-process on the unified package;
[0025] Based on the decompression method, a decompression sub-process is executed on the result after executing the session verification sub-process;
[0026] Based on the deserialization method, a deserialization processing sub-process is performed on the result after the decompression sub-process is executed.
[0027] In a possible embodiment, the main processing logic is represented by a base class, the base class includes a plurality of first classes, each first class corresponds to a first sub-processing logic, and each first sub-processing logic is represented by a second class inherited from the corresponding first class;
[0028] The policy determination module is specifically used to construct a plurality of respective instances of the second class based on the target network protocol, wherein each second class in the plurality of second classes corresponds to a first sub-processing logic in the plurality of first sub-processing logics;
[0029] The process execution module is specifically used to call the method of the instance corresponding to each first sub-processing logic in the multiple first sub-processing logics through the base class to execute the corresponding first sub-processing logic.
[0030] In a possible embodiment, the main processing logic further includes a second main process commonly used when performing protocol encapsulation on multiple types of business processing results, and the second main process includes multiple second sub-processing logics; the business execution module is specifically used to:
[0031] Based on the analysis result, executing the business logic corresponding to the target business request to obtain a business processing result;
[0032] Based on the second implementation strategies corresponding to each of the multiple second sub-processing logics, the second main process is executed on the business processing result to obtain business packet return data, wherein the business packet return data is data that satisfies the target network protocol, wherein each second implementation strategy is determined based on the target network protocol and is an implementation method of a second sub-processing logic.
[0033] In a possible embodiment, the multiple second sub-processing logics include a serialization sub-process, a compression sub-process, a session signature sub-process, and a second unified package conversion sub-process, and the second implementation strategies corresponding to each of the multiple second sub-processing logics include a serialization method corresponding to the serialization sub-process, a compression method corresponding to the compression sub-process, a session signature method corresponding to the session signature sub-process, and a second package conversion method corresponding to the second unified package conversion sub-process; the business execution module is specifically used to:
[0034] Based on the serialization method, executing the serialization sub-process on the business processing result;
[0035] Based on the compression method, a compression sub-process is executed on the result after executing the serialization sub-process;
[0036] Based on the session signature method, executing the session signature sub-process on the result after executing the compression sub-process;
[0037] Based on the second unified package conversion method, the second unified package conversion sub-process is executed on the result after executing the session signature sub-process.
[0038] In a possible embodiment, the main processing logic is represented by a base class; and the service execution module is specifically used for:
[0039] The business logic is executed based on the parsing result through the third class inherited from the base class to obtain the business processing result.
[0040] In a possible embodiment, the main processing logic is represented by a base class, the base class includes multiple fourth classes, each fourth class corresponds to a second sub-processing logic, and each second sub-processing logic is represented by a fifth class inherited from the corresponding fourth class; the business execution module is specifically used to:
[0041] constructing a plurality of instances of the fifth class respectively, wherein each of the plurality of fifth classes corresponds to a second sub-processing logic in the plurality of second sub-processing logics;
[0042] Through the base class, a method of an instance corresponding to each first sub-processing logic in the plurality of second sub-processing logics is called to execute the corresponding second sub-processing logic.
[0043] An embodiment of the present application provides a computer device, including:
[0044] at least one processor, and a memory communicatively coupled to the at least one processor;
[0045] The memory stores instructions that can be executed by the at least one processor, and the at least one processor implements any of the service request processing methods discussed above by executing the instructions stored in the memory.
[0046] An embodiment of the present application provides a computer storage medium, wherein the computer storage medium stores computer instructions. When the computer instructions are executed on a computer, the computer executes any of the business request processing methods discussed above.
[0047] Since the embodiment of the present application adopts the above technical solution, it has at least the following technical effects:
[0048] In the embodiment of the present application, a first main process for parsing multiple types of business requests is pre-configured. When parsing a business request, the network protocol corresponding to the business request is first determined, and then the first implementation strategy of each first sub-processing logic in the first main process is determined according to the network protocol, which is equivalent to determining the specific implementation of each first sub-processing logic, so as to parse the business request according to each first implementation strategy. Since this method only needs to determine the first implementation strategy of the first sub-processing logic corresponding to the network protocol when parsing business requests of different network protocols, the business request corresponding to any network protocol can be parsed, thereby improving the reusability of CGI. Moreover, for parsing business requests of different network protocols, it is only necessary to define the first implementation strategy of the first sub-processing logic of each network protocol without changing the first main process, which can reduce the workload and difficulty of developing the code corresponding to the protocol parsing process. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1A A schematic diagram of a network architecture applicable to the service request processing method provided in an embodiment of the present application;
[0050] Figure 1BA schematic diagram of a scenario applicable to the service request processing method provided in an embodiment of the present application;
[0051] Figure 1C A schematic diagram of a framework of the fusion CGI provided in the embodiment of the present application;
[0052] Figure 2 A flowchart of a method for processing a business request provided in an embodiment of the present application;
[0053] Figure 3A A schematic diagram of the main processing logic provided in an embodiment of the present application;
[0054] Figure 3B A schematic diagram of the base class, the first class and the second class provided in the embodiment of the present application;
[0055] Figure 4 A schematic diagram of a process flow for executing a first main process provided in an embodiment of the present application;
[0056] Figure 5 A schematic diagram of a process flow for executing a second main process provided in an embodiment of the present application;
[0057] Figure 6 Provided for the embodiments of this application Figure 1B Schematic diagram of the interaction between the client and the server;
[0058] Figure 7 A schematic diagram of an interface change during a service request processing process provided by an embodiment of the present application;
[0059] Figure 8 A schematic diagram of the structure of a service request processing device provided in an embodiment of the present application;
[0060] Fig. 9 A schematic diagram of the structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0061] In order to better understand the technical solution provided by the embodiments of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0062] In order to help those skilled in the art better understand the technical solution of the present application, the terms involved in the present application are introduced below.
[0063] 1. Common Gateway Interface (CGI): In the computer field, CGI assists web services in executing programs similar to console applications (also known as command-line interface programs). This program is a common protocol for implementing dynamic page provision on the server. Such a program is called a CGI script. Normally, a request corresponds to the execution of a CGI script, and a web page is generated. In short, a business request sends data from the client to a CGI program via standard input. The CGI program can be regarded as a CGI service, or CGI for short. In addition to standard input, it can also carry other data, such as uniform resource locator (URL) path, hypertext transfer protocol (HTTP) header or one or more of the environment variables converted to the process. In other words, the interaction between the client and the server can be completed through CGI, for example, sending a message, searching for a product, adding a friend, etc. The client in the embodiment of the present application generally refers to an application, a small program or a web page, etc., and the present application does not limit this.
[0064] 2. Fusion common gateway interface (Fusion CGI): refers to a CGI that can process service requests of multiple network protocols. The CGI provided in the embodiment of the present application belongs to a fusion CGI. An example of a fusion CGI is ILinkFusionBaseCgi.
[0065] 3. Network protocol: refers to the network protocol between the client and the server, specifically the network application layer protocol. For example, the client and the server interact using the http protocol, and the IoT device interacts with the server using the message queuing telemetry transport (MQTT) protocol.
[0066] 4. Main processing logic: It can be called the main logic, or the main CGI processing flow. It refers to the main flow that is common to multiple types of network protocols. Protocol processing includes two parts: protocol parsing and protocol encapsulation. Therefore, the main processing logic can specifically include the first main flow that is common to multiple types of business requests when performing protocol parsing. Each type of business request corresponds to a type of network protocol. The first main flow specifically includes multiple first sub-processing logics. In other words, multiple first sub-processing logics are common to parsing multiple types of business requests, and each first sub-processing logic can be understood as a sub-flow for parsing a business request.
[0067] The main processing logic may also include the execution order of multiple first sub-processing logics, and the execution order may be understood as the order in which the multiple first sub-processing logics are executed. In addition, the main processing logic may also include a second main process that is common when performing protocol encapsulation on multiple types of business processing results. Each type of business processing result corresponds to a type of network protocol, or may be understood as the processing result of a business request of a type of network protocol. The second main process specifically includes multiple second sub-processing logics, and each second sub-processing logic may be understood as a sub-process in the encapsulated business processing result. The second main process may also include the execution order of multiple second sub-processing logics.
[0068] For the sake of distinction, the execution order of the plurality of first sub-processing logics is referred to as a first execution order, and the execution order of the plurality of second sub-processing logics is referred to as a second execution order.
[0069] 5. Implementation strategy: refers to the implementation method of the sub-processing logic. One sub-processing logic can correspond to multiple implementation strategies. For example, the second sub-processing logic is a compression sub-process. The compression sub-process can use the LZ4 compression algorithm or the Zlib compression algorithm. That is, the LZ4 compression algorithm or the Zlib compression algorithm are both regarded as two implementation strategies of the second sub-processing logic.
[0070] For ease of distinction, the implementation strategy corresponding to the first sub-processing logic in the embodiment of the present application is referred to as the first implementation strategy, and the implementation strategy corresponding to the second sub-processing logic is referred to as the second implementation strategy.
[0071] 6. Execution mode: It can be understood as the execution mode of the process. For the sake of distinction, in the embodiment of the present application, the execution mode of the first main process corresponding to the target business request is referred to as the first execution mode, the execution mode of the first main process corresponding to the newly added business request is referred to as the second execution mode, and the execution mode of the second main process is referred to as the third execution mode. The first execution mode can be understood as the first sub-processing logic belonging to the non-empty implementation and the first sub-processing logic belonging to the empty implementation among multiple first sub-processing logics when parsing the target business request. The sub-processing logic of the empty implementation means that the input when executing the sub-processing logic is the same as the output after executing the sub-processing logic, that is, the sub-processing logic is executed, but the execution result, that is, the output of the sub-processing logic has no effect on the final main processing logic. The meaning of the second execution mode can refer to the meaning of the first execution mode. The third execution mode can be understood as the second sub-processing logic belonging to the non-empty implementation and the second sub-processing logic belonging to the empty implementation among multiple second sub-processing logics when encapsulating the business processing results corresponding to a class of business requests.
[0072] 7. Request context: The request context can be understood as the location where the resources needed in the business request processing are saved, such as one or both of variables or functions. The life cycle of the request context is the time period for processing a business request. For example, flask.request is an example of a request context. When receiving a business request, flask.request is created, and after the business request processing is completed, flask.request is destroyed.
[0073] 8. Class: In object-oriented programming, it is a construct of an object-oriented computer programming language. It is a blueprint for creating objects and describes the common characteristics and methods of the created objects. Classes can include base classes, abstract classes and concrete classes. It should be noted that base classes, abstract classes and concrete classes can be three independent concepts, and they can also have a mutual affiliation relationship. For example, a concrete class is a derived class of a base class, and a concrete class is a derived class of an abstract class. This application does not make specific restrictions on this. The following describes the three categories separately.
[0074] ① Base class: also known as the parent class or super class, refers to the class that is inherited. The base class defines the class of pure virtual member functions. The class that inherits from the base class can also be called a derived class, or a subclass. The derived class contains all the members of the base class, and also includes its own unique members. The derived class and the derived class object access the members in the base class just like accessing their own members. They can be used directly without adding any operators, but the derived class still cannot access the private members in the base class. The derived class can belong to a specific class.
[0075] ②Abstract class: It is defined as not and cannot be instantiated as a specific object. In the class inheritance relationship, abstract classes are often defined at a higher level. In the practical activities of programming, abstract classes and interfaces are similar in that abstract classes are more inclined to regulate common methods and properties. However, there is a very big difference from interfaces in that abstract classes can often provide an implementation of an interface when regulating a common method and property. The abstract interface mentioned in the embodiments of the present application is equivalent to an abstract class.
[0076] ③Concrete class: can be instantiated into a specific object, which can be an abstract class or a derived class of a base class.
[0077] To understand the above concepts more clearly, let's take things in the real world as an example. For example, "fruit" can be considered an abstract class, and "apple" and "banana" can be derived classes of the abstract class. The difference is that "fruit" is a concept and it will not have an instance, but "apple" and "banana" will have corresponding instances.
[0078] The first and fourth categories mentioned below can be abstract classes defined in the base class, the second category can be a specific class derived from the first category, the third category can be a specific class inherited from the base class, and the fifth category can be a specific class derived from the fourth category. The first and fourth categories can be the same or different.
[0079] It should be noted that "at least one" in the embodiments of the present application refers to one or more, "multiple" refers to two or more, and unless otherwise specified, "first", "second" and "third" are only used to distinguish and do not limit the order of precedence, etc.
[0080] With the rapid development of Internet technology and Internet of Things technology, there are more and more types of terminal devices, such as mobile phones or Internet of Things devices. Different types of terminals may use different network protocols to access the server, such as HTTP, MQTT or other private protocols. However, the business logic of a CGI often does not change due to changes in network protocols. For example, a CGI used to implement the Automatic Speech Recognition (ASR) function will use the same processing logic for business requests of different network protocols.
[0081] At present, in order to make the server compatible with heterogeneous network protocols, multiple CGIs are generally provided for the same business logic, and each CGI is adapted to a different network protocol. This makes CGI reusability poor and requires the development of multiple CGIs, which makes code development complicated.
[0082] For example, CGI includes interceptors, which are used to intercept, authenticate, and serialize the frequency of business requests. Since business requests include pre-processing and post-processing, pre-processing of business requests refers to protocol parsing of business requests, and post-processing refers to the process of protocol encapsulation of business processing results. According to the current method, it is necessary to define the pre-processing function PreProcess and the post-processing function PostProcess separately, and correspondingly, the interceptor in the CGI needs to inherit the respective subclasses of the pre-processing function and the post-processing function, making the code development of CGI more complicated.
[0083] In view of this, the embodiment of the present application provides a business request processing method, which decomposes the protocol processing into specific sub-processing logics, and uses each sub-processing logic to construct a pipeline architecture common to various types of business requests, which is equivalent to pre-configuring the main processing logic. When parsing the business request, the implementation strategy of each first sub-processing logic is determined directly according to the business request. Based on the determined implementation strategy, the business request can be parsed, so that it can be compatible with the protocol processing of business requests of various network protocols, thereby improving the reusability of CGI. And because there is no need to pre-configure the implementation strategy of each first sub-processing logic in the CGI code, only the main processing logic needs to be pre-configured, thereby simplifying the code development of CGI.
[0084] Please refer to Figure 1A , is a schematic diagram of a network architecture applicable to the service request processing method provided in the embodiment of the present application. The network architecture schematic diagram includes a client 111, an access layer 112 and a service layer 113.
[0085] The specific implementation of the client 111 can refer to the above. The access layer 112 refers to the part of the network that is directly connected or accessed by users. The purpose of the access layer 112 is to allow the client 111 to connect to the network. The business layer 113 is used to parse the corresponding business request and execute the corresponding business logic.
[0086] Specifically, the client 111 generates a service request, the access layer 112 forwards the service request to the service layer 113, the service layer 113 performs protocol parsing on the service request and executes corresponding service logic according to the parsing result, wherein the process of performing protocol parsing on the service request and executing service logic will be introduced below.
[0087] As a possible embodiment, the business layer 113 may be deployed with multiple CGIs, each CGI being used to independently implement functions such as parsing business requests and executing business logic.
[0088] Please refer to Figure 1B , is a schematic diagram of a scenario applicable to the service request processing method provided in the embodiment of the present application. The schematic diagram of the scenario includes multiple terminal devices 110 and a server 120, and each terminal device 110 corresponds to a client 111. Each terminal 110 can communicate with the server 120 through a communication network. It should be noted that, Figure 1B Two terminal devices 110 are taken as an example, but the number of terminals 110 is not limited in practice.
[0089] The terminal device 110 is an electronic device used by the user, which may be a smart phone, tablet computer, laptop computer, desktop computer, smart speaker, smart watch, gaming device, smart TV or smart wearable device, etc., which is a computer device with certain computing capabilities and runs software or websites.
[0090] The server 120 may be deployed with one or more CGIs, and the meaning of CGI can be referred to above. The server 120 may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.
[0091] Among them, cloud computing can be understood as a computing model that distributes computing tasks on a resource pool composed of a large number of computers, so that various application systems can obtain computing power, storage space and information services as needed. The network that provides resources is called "cloud". The resources in the "cloud" are infinitely expandable in the eyes of users, and can be obtained at any time, used on demand, expanded at any time, and paid for by use.
[0092] In a possible embodiment, the communication network may be a wired communication network or a wireless communication network, which is not limited in the present application.
[0093] The following is an example of the interaction between the terminal device 110 and the server 120.
[0094] For example, a user may perform an access operation on the terminal device 110, such as inputting a search keyword, and the client 111 generates a service request based on the access operation, and the service request is used to request corresponding service data. The client 111 sends the service request to the server 120. After receiving the service request, the server 120 may process the service request through the corresponding CGI to obtain service response data. The server 120 may also feedback the service response data to the client 111 through the CGI. The process of the server 120 processing the service request will be described below.
[0095] In a possible application scenario, in order to reduce communication latency, servers 120 may be deployed in various regions, or different servers 120 may serve the regions corresponding to each terminal for load balancing. Multiple servers 120 can share data through blockchain, and multiple servers 120 are equivalent to a data sharing system composed of multiple servers 120. For example, terminal 110 is located at location a and communicates with server 120, and terminal 110 is located at location b and communicates with other servers 120.
[0096] Each server 120 in the data sharing system has a node identifier corresponding to the server 120. Each server 120 in the data sharing system can store the node identifiers of other servers 120 in the data sharing system, so that the generated blocks can be broadcast to other servers 120 in the data sharing system according to the node identifiers of other servers 120. Each server 120 can maintain a node identifier list as shown in the following table, and store the server 120 name and the node identifier in the node identifier list. The node identifier can be an Internet Protocol (IP) address for interconnection between networks and any other information that can be used to identify the node.
[0097] In a possible application scenario, the business request processing method involved in the embodiment of the present application can be widely used in various specific application scenarios, for example, in smart homes, virtual reality, augmented reality, unmanned driving, smart marketing, smart office, smart wearable, smart transportation, smart cities, drones, robots, vehicle networks, automatic driving, smart transportation and other application scenarios, and the present application does not impose any restrictions on this.
[0098] The CGI in the embodiment of the present application can process multiple network protocols, which is equivalent to providing a fusion CGI. Figure 1C A schematic diagram of a framework of the fusion CGI shown in FIG. 1 is used to introduce the framework of the CGI in the embodiment of the present application by way of example, or Figure 1C It can also be understood as Figure 1A or Figure 1B A framework diagram of CGI in , or it can be understood as Figure 1B A framework diagram of a server in .
[0099] Please refer to Figure 1C The framework diagram includes the main processing logic, processor factory, implementation strategy set, basic authentication algorithm library, request context management and request permission management. The main functions of each part are introduced below.
[0100] 1. Main processing logic.
[0101] The meaning of the main processing logic can be found in the previous text.
[0102] 2. Processor factory.
[0103] The processor factory includes multiple processors. The processor here can be understood as a virtual processor that implements the processing function, rather than a physical processor. The processor factory is used to determine the execution mode corresponding to the business request according to the current business request. The meaning of the execution mode can refer to the above. For example, the processor factory can determine the first execution mode corresponding to the target business request according to the request context of the target business request.
[0104] 3. Implement the policy set.
[0105] The implementation strategy set may also be called a sub-process strategy set, including multiple implementation strategies, specifically multiple first implementation strategies and multiple second implementation strategies. The meanings of the first implementation strategy and the second implementation strategy may refer to the above text.
[0106] 4. Basic authentication algorithm library.
[0107] The basic authentication algorithm library includes multiple basic authentication algorithms, each of which can be used to authenticate the terminal device or account of the target business request.
[0108] 5. Request context management module.
[0109] The request context management module is used to encapsulate the request context corresponding to the business request. The meaning of the request context can be referred to in the previous text.
[0110] 6. Request permission management module.
[0111] The request permission management module is used to provide permission configuration management, for example, to configure whether various business requests require configuration of login status, etc.
[0112] It should be noted that Figure 1C The architecture of CGI in the embodiment of the present application is only introduced as an example, but the architecture of CGI in the embodiment of the present application is not limited to this.
[0113] As an example, Figure 1C Any of the processor factory, implementation strategy set, basic authentication algorithm library, request context management, and request permission management is an optional part.
[0114] As an example, among other things, Figure 1CIt can also include functional modules that implement other aspect logics. Aspect logic refers to other processing besides the main processing logic, and refers to the processing logic for aspect programs. For example, CGI can also include request shielding modules, anti-spam modules, etc. The request shielding module is used to shield illegal requests, and the anti-spam module is used to clean up spam requests, etc.
[0115] The following describes the business request processing method provided by the exemplary embodiment of the present application in combination with the application scenario described above and with reference to the accompanying drawings. It should be noted that the above application scenario is only shown to facilitate understanding of the spirit and principles of the present application, and the implementation of the present application is not limited in this respect.
[0116] The service request processing method in the embodiment of the present application can be Figure 1A The business layer in Figure 1A CGI deployed in the business layer, Figure 1B Terminal equipment in Figure 1B Servers in Figure 1B CGI deployed in the server, or Figure 1B The terminal device and the server cooperate to execute, etc., and this application does not limit this.
[0117] The following is a business request processing method. Figure 1B The CGI execution in the server 120 in the example is used to introduce the service request processing method. Figure 2 , is a flow chart of the service request processing method. The service request processing method includes the following steps.
[0118] S21, obtaining a target network protocol corresponding to the target service request.
[0119] The client can generate a service request based on the access operation performed by the user. The access operation can refer to the above. The client sends the service request to the server, and the CGI in the server can receive the service request from the client. Any service request that needs to be processed can be regarded as a target service request, which is used to request corresponding data from the CGI.
[0120] In order to facilitate the subsequent processing of the target service request, after obtaining the target service request, the CGI can determine the target network protocol corresponding to the target service request. The meaning of the network protocol can be referred to in the previous text. The CGI can determine the target network protocol by itself, or can obtain the target network protocol of the target service request from an intermediate device, such as a network forwarding device or a proxy device, etc., which is not limited in this application.
[0121] For example, the target service request is as follows:
[0122] GET / xxxHTTP / 1.1 / bar?var1=value1&var2=with%20percent%20encoding. This target service request is used to request the operating environment of the server.
[0123] S22, based on the target network protocol, determining the first implementation strategy of each of the plurality of first sub-processing logics in the main processing logic, wherein the main processing logic includes a first main process that is common when performing protocol parsing on multiple types of business requests.
[0124] The first main process includes a plurality of first sub-processing logics, and the main processing logic is pre-configured, and one type of service request among the plurality of types of service requests corresponds to one network protocol.
[0125] CGI can pre-store the first main process, but when parsing business requests corresponding to different network protocols, the implementation strategy corresponding to each first sub-processing logic may be different. Therefore, in the embodiment of the present application, CGI can determine the first implementation strategy of each first sub-processing logic suitable for parsing the target business request based on the target network protocol, so as to facilitate the subsequent use of the corresponding first implementation strategy and execute the corresponding first sub-processing logic for the target business request. For example, the server can pre-store an implementation strategy set, and CGI calls the implementation strategy set based on the target network protocol, and determines the first implementation strategy corresponding to each first sub-processing logic from the implementation strategy set. Or, for example, the implementation strategy set can be directly pre-stored in CGI.
[0126] Continuing to refer to the target service request exemplified in S21, CGI can determine that the target network protocol of the target service request is the HTTP protocol.
[0127] S23, based on the obtained multiple first implementation strategies, executing the first main process for the target business request to obtain a parsing result of the target business request.
[0128] CGI can adopt multiple first implementation strategies to execute corresponding first sub-processing logics in multiple first sub-processing logics respectively. After executing multiple first sub-processing logics, it is equivalent to executing the first main process, and the corresponding parsing result of the target business request can be obtained.
[0129] S24: Based on the analysis result, the target service request is processed accordingly.
[0130] CGI can execute corresponding business logic on the parsing results, which is equivalent to performing corresponding processing on the target business request.
[0131] Continuing to refer to the target service request in S21, CGI can parse the target service request, and after processing the target service request accordingly, it can generate service response data, specifically the operating environment parameters of the server, including the name of the server and the port in the server for processing the target service request. The operating environment parameters of the server are as follows:
[0132] SERVER_NAME="127.0.0.1"
[0133] SERVER_PORT="80".
[0134] Here, "SERVER_NAME" indicates the name of the server, and "SERVER_PORT" indicates the port of the server.
[0135] exist Figure 2 In the illustrated embodiment, the protocol parsing process common to multiple types of business requests is configured as a first main process, and the first main process is decomposed into multiple first sub-processing logics. When a business request is parsed, the specific implementation of the first sub-processing logic can be determined, so that the protocol parsing process for the business request can be completed according to the respective implementation strategies of the multiple first sub-processing logics. In this way, CGI can perform protocol parsing on business requests corresponding to multiple network protocols, thereby improving the reusability of CGI. Moreover, when developing CGI, there is no need to configure complex code, which reduces the workload of CGI code development and the difficulty of developing CGI. Moreover, when it is necessary to add a protocol processing function for a certain network protocol, the implementation strategy of the sub-processing logic involved in the network protocol processing process can be increased, so that the protocol processing process for the newly added network protocol can be implemented, thereby improving the scalability of CGI.
[0136] exist Figure 2 Based on the embodiment shown, the following Figure 2 In one possible embodiment, the following examples are given for each step. Figure 2 The execution method of S21 in the embodiment may include any one of the following methods.
[0137] Method 1 to determine the target network protocol:
[0138] CGI determines the target network protocol of the target service request based on the packet header in the target service request.
[0139] The target service request generally includes a packet header and a packet body, and different network protocols have different formats of the packet body in the corresponding service request. The server or CGI may pre-store a first correspondence between each network protocol and the format of the packet header corresponding to the network protocol. After receiving the target service request, the CGI may call the first correspondence and determine the network protocol corresponding to the packet body of the target service request from the first correspondence.
[0140] For example, the format of the packet header corresponding to the service request using the HTTP protocol is: GET / xxxHTTP / 1.1. CGI determines that the format of the packet header of the target service request conforms to the format of the packet header corresponding to the HTTP protocol, thereby determining that the target network protocol of the target service request is the HTTP protocol.
[0141] Method 2 to determine the target network protocol:
[0142] Obtain the target network protocol of the target service request from the intermediate device.
[0143] The client forwards the target service request to the CGI through the intermediate device. When receiving the target service request, the intermediate device can determine the target network protocol of the target service request and send the target service request and the target network protocol to the CGI. The method for the intermediate device to determine the target network protocol can refer to the method for CGI to determine the target network protocol.
[0144] In order to more clearly understand the multiple first sub-processing logics, Figure 3A The example diagram of the main processing logic shown is an example introduction to multiple first sub-processing logics.
[0145] Please refer to Figure 3A The main processing logic includes a first main process corresponding to the arrow direction where the request input is located, and a second main process corresponding to the arrow direction where the data output is located.
[0146] As an embodiment, the first main process includes a first unified package conversion sub-process (corresponding to the construction package in FIG. 3 ), a session verification sub-process (corresponding to Figure 3A Session verification in), decompression sub-process (corresponding to Figure 3A decompression) and deserialization subprocess (corresponding to Figure 3A The deserialization sub-process can also be called the deserialization sub-process.
[0147] As an embodiment, the first main process and the second main process are opposite processes, and it can be understood that each first sub-processing logic has a corresponding and opposite second sub-processing logic.
[0148] Specifically, take the first main process as Figure 3AAs shown in the example, the second main process includes a serialization sub-process (corresponding to Figure 3A Serialization in), compression subprocess (corresponding to Figure 3A Compression in), session signature sub-process (corresponding to Figure 3A Session signature in) and the second unified package conversion sub-process (corresponding to Figure 3A in the protocol package).
[0149] Furthermore, the first main process and the second main process may actually be opposite processes. In order to simplify the CGI code development, a set of opposite sub-processing logics involved in the first main process and the second main process may be defined as an abstract layer in the embodiment of the present application. The abstract layer here may be understood as an abstract interface or an abstract class. In other words, the abstract layer here is not related to the CGI code. Figure 1A The so-called layers in the network are not the same concept. In the embodiment of the present application, a group of opposite sub-processing logics is defined as an abstract layer, so that the group of opposite sub-processing logics can directly inherit the abstract layer in the subsequent execution process to implement the corresponding sub-processing logic.
[0150] For details, please refer to Figure 3A The main processing logic specifically includes an access protocol abstraction layer, a session abstraction layer, a compression abstraction layer, and a serialization abstraction layer. Among them, the access protocol abstraction layer, the session abstraction layer, the compression abstraction layer, and the serialization abstraction layer can realize heterogeneous protocol adaptation, and specifically can realize the first main process and the second main process.
[0151] The access protocol abstraction layer is used to implement the first unified package conversion sub-process and the second unified package conversion sub-process; the session abstraction layer is used to implement the session verification sub-process and the session signature sub-process; the compression abstraction layer is used to implement the decompression sub-process and the compression sub-process; the serialization abstraction layer implements the serialization sub-process and the deserialization sub-process.
[0152] Furthermore, the main processing logic also includes a business abstraction layer, which can encapsulate common business processing logic and is also equivalent to an abstract class or abstract interface. When the business logic is subsequently executed, the business abstraction layer can be inherited to implement the corresponding business logic.
[0153] After determining the target network protocol, the CGI may execute S22, that is, based on the target network protocol, determine the first implementation strategy of each of the plurality of first sub-processing logics in the main processing logic. The following takes determining the first implementation strategy corresponding to a first sub-processing logic as an example to introduce an example of the method of determining the first implementation strategy involved in S22.
[0154] The first implementation strategy is determined by:
[0155] CGI can determine the first implementation strategy corresponding to the first sub-processing logic from the second corresponding relationship based on the target network protocol, wherein the second corresponding relationship includes the association relationship between the first sub-processing logic and the first implementation strategy corresponding to the first sub-processing logic for each network protocol.
[0156] Specifically, the server or CGI may pre-store an implementation strategy set, each implementation strategy in the implementation strategy set is associated with a first sub-processing logic corresponding to a network protocol that can be processed. The implementation strategy set here may be regarded as an example of a second corresponding relationship. After obtaining the target network protocol, the CGI may determine the first implementation strategy corresponding to the sub-processing logic in the target network protocol from the implementation strategy set according to the target network protocol.
[0157] For example, the first sub-processing logic includes a deserialization sub-process and a decompression sub-process, and the second corresponding relationship is specifically shown in Table 1 below.
[0158] Table 1 Second correspondence
[0159] HTTP MQTT Protocol Deserialization subprocess JSON ProtoBuf Unzip subprocess LZ4 Zlib or Zlib
[0160] For example, please refer to Table 1. The first implementation strategy of the deserialization subprocess under the HTTP protocol is JSON, and the first implementation strategy under the MQTT protocol is ProtoBuf; the first implementation strategy of the decompression subprocess under the HTTP protocol is LZ4, and the first implementation strategy under the MQTT protocol is Zlib. If CGI determines that the target network protocol corresponding to the target business request is the HTTP protocol, it can be determined that the first implementation strategy of the deserialization subprocess is JSON; the first implementation strategy of the decompression subprocess is LZ4.
[0161] Furthermore, in the second corresponding relationship, the first sub-processing logic may have multiple implementation strategies corresponding to a certain network protocol. For the sake of convenience of description, these multiple implementation strategies are referred to as multiple candidate implementation strategies. This involves the need for CGI to screen out the first implementation strategy from multiple candidate implementation strategies. In the embodiment of the present application, CGI can randomly select an implementation strategy from multiple candidate implementation strategies as the first implementation strategy of the first sub-processing logic.
[0162] Alternatively, the CGI may determine the first implementation strategy corresponding to the first sub-processing logic from a plurality of candidate implementation strategies according to the business information of the target business request. The business information of the target business request refers to information related to the business corresponding to the target business request, such as the business type or business scenario of the target business request, such as business type for public business, private business, etc., and business scenario for social business, content service business, etc.
[0163] In the first method for determining the first implementation strategy, CGI can directly select the corresponding first implementation strategy from the second corresponding relationship according to the target network protocol, and the method for determining the first implementation strategy is simple and fast.
[0164] The first implementation strategy is determined by the second method:
[0165] CGI can determine the first implementation strategy corresponding to the first sub-processing logic from the third correspondence relationship based on the target network protocol and the target business request, wherein the third correspondence relationship includes the association relationship between the first sub-processing logic and the first implementation strategy corresponding to the first sub-processing logic under each network protocol and corresponding business information.
[0166] The CGI can determine the first implementation strategy corresponding to the first sub-processing logic according to the target network protocol and the business information in the target business request. For example, each implementation strategy set in the implementation strategy set is associated with the corresponding business information and the corresponding network protocol. In this case, the implementation strategy set can be understood as an example of the third corresponding relationship, wherein the meaning of the business information can refer to the above text.
[0167] For example, the business information indicates a first implementation strategy corresponding to a first sub-processing logic, so the CGI can combine the indication information and the target network protocol to determine the first implementation strategy corresponding to the first sub-processing logic.
[0168] In the above second method for determining the first implementation strategy, CGI may not only rely on the target network protocol but also rely on business information to determine the first implementation strategy, so that the determined first implementation strategy can meet business requirements.
[0169] As an embodiment, CGI may combine the first implementation strategy determination method 1 and the first implementation strategy determination method 2 to determine the first implementation strategy of each of the plurality of first sub-processing logics.
[0170] For example, CGI adopts the first implementation strategy determination method 1 to determine the first implementation strategy corresponding to part of the first sub-processing logic, and adopts the first implementation strategy determination method 2 to determine the first implementation strategy for another part of the first sub-processing logic.
[0171] It should be noted that the first implementation strategy determining method 1 and the first implementation strategy determining method 2 are examples of determining the implementation strategy determining method, and do not limit the method for determining the first implementation strategy.
[0172] In order to more clearly illustrate the first implementation strategy, the following takes multiple first sub-processing logics as an example. Figure 3ATaking the first sub-processing logics shown as examples, correspondingly, multiple first implementation strategies include: a first package conversion method corresponding to the unified package conversion sub-process, a session verification method corresponding to the session verification sub-process, a decompression method corresponding to the decompression sub-process, and a deserialization method corresponding to the deserialization sub-process.
[0173] The first package conversion method may include: Figure 3A A package conversion method corresponding to the MQTT protocol, a package conversion method corresponding to the COAP protocol, a package conversion method corresponding to the MMPkg protocol, a package conversion method corresponding to the WPkg protocol, and a package conversion method corresponding to other protocols are shown in the figure.
[0174] Session verification methods can include Figure 3A The session information verification method, token information verification method, and a verification method corresponding to other verification information shown in the figure, the session information verification method refers to verification using session information, and the token information verification method refers to verification using token information.
[0175] Decompression methods can include Figure 3A A decompression method corresponding to LZ4, a decompression method corresponding to Zlib, and a decompression method corresponding to other compression algorithms shown in .
[0176] Deserialization methods can include Figure 3A A deserialization method corresponding to ProtoBuf, a deserialization method corresponding to JSON, and a deserialization method corresponding to other serialization algorithms shown in .
[0177] In a possible embodiment, the CGI may determine a first execution mode corresponding to the target service request.
[0178] Specifically, the first main process is a common process for parsing multiple types of business requests, but in fact some sub-processes in the first main process may not be necessary for some parsed business requests. Therefore, in the embodiment of the present application, CGI can determine the first execution mode corresponding to the target business request, that is, determine at least one first sub-processing logic belonging to a non-empty implementation in the first main process, and at least one first sub-processing logic belonging to an empty implementation. The meaning of the empty implementation can be referred to the previous discussion, which will not be repeated here.
[0179] The CGI may determine the first execution mode corresponding to the target service request from the execution mode set. For example, the CGI may determine the first execution mode corresponding to the target service request from the execution mode set according to the request context corresponding to the target service request.
[0180] It should be noted that when processing certain business requests, the corresponding first execution mode may be that all first sub-processing logics are non-empty implementations. In other words, when parsing the business request, all first sub-processing logics in the first main process need to adopt non-empty implementations.
[0181] Furthermore, when the CGI determines the first execution mode, it can determine the first implementation strategies corresponding to each of the plurality of first sub-processing logics in combination with the first execution mode and the target network protocol.
[0182] Specifically, if a certain first sub-processing logic is empty implementation, then the first implementation strategy corresponding to the first sub-processing logic is used to empty implement the first sub-processing logic. In other words, empty implementation belongs to an implementation strategy.
[0183] In the embodiment of the present application, an execution mode is introduced, and the first sub-processing logic that needs to be empty is determined according to the execution mode. CGI does not need to skip the corresponding first sub-processing logic in the first main process according to the business request, so that CGI can be strictly executed according to the first main process, making the code run more smoothly. Moreover, CGI can determine in advance which sub-processing logics belong to empty implementation, so as to select the first implementation strategy that is suitable.
[0184] In another possible embodiment, the CGI may determine whether the first sub-processing logic requires an empty implementation when executing the first sub-processing logic.
[0185] Specifically, the main processing logic also defines a judgment logic corresponding to each sub-processing logic, and each judgment logic is used to judge whether the sub-processing logic needs to be empty implemented.
[0186] In an embodiment of the present application, CGI does not need to determine the execution mode corresponding to the target business request in advance, but determines whether to implement the corresponding first sub-processing logic based on actual conditions. This eliminates the need to store the execution policy set and reduces the data storage capacity of CGI or the server.
[0187] After determining the first implementation strategies of the plurality of first sub-processing logics, the CGI may execute S23. The following is an example of the manner of executing the first main process in S23.
[0188] The CGI executes the first main process, which is equivalent to executing a plurality of first sub-processing logics. The following is an explanation of the method of executing a plurality of first sub-processing logics.
[0189] For example, CGI may adopt a first implementation strategy of a first sub-processing logic to execute the first sub-processing logic. Similarly, CGI may execute multiple first sub-processing logics.
[0190] Furthermore, in addition to the plurality of first sub-processing logics, the first main process may also include a first execution order of the plurality of first sub-processing logics. When executing the first main process, the CGI may sequentially execute the plurality of first sub-processing logics according to the execution order.
[0191] Of course, the multiple first sub-processing logics may not have an execution order, that is, the multiple first sub-processing logics may not have a strict execution order, so CGI can execute the multiple first sub-processing logics in any order.
[0192] Please continue to refer to Figure 3A The main processing logic can be encapsulated as a base class, or it can be understood that the main processing logic is represented by a base class, and a first sub-processing logic corresponds to a first class in the base class. For example, Figure 3A An abstract layer in, when determining a first implementation strategy of a first sub-processing logic, is equivalent to constructing an instance of the second class inherited from the first class, so CGI can call the method of the instance through the base class to execute the first sub-processing logic.
[0193] In order to more clearly illustrate the relationship between the base class, the first class and the second class, the following Figure 3B The base class, the first class and the second class are introduced by means of the schematic diagrams shown.
[0194] Please refer to Figure 3B The main processing logic includes a first main process, which includes Figure 3B The decompression subprocess shown in the figure is specifically implemented as the first implementation strategy. Correspondingly, the main processing logic corresponds to the base class, which includes the first class, the second class inherits from the first class, the second class corresponds to the decompression subprocess, and the instance corresponding to the second class corresponds to the first implementation strategy of the decompression subprocess. Figure 3B The dotted line in the middle indicates that there is a corresponding relationship between two concepts. For example, the dotted line between the main processing logic and the base class indicates that the base class represents the main processing logic, or it can be understood that the base class corresponds to the main processing logic.
[0195] In order to more clearly illustrate the method of executing the first main process, the following takes multiple first sub-processing logics including a first unified package conversion sub-process, a decryption sub-process, a decompression sub-process and a deserialization sub-process, and multiple first implementation strategies including a first package conversion method corresponding to the unified package conversion sub-process, a session verification method corresponding to the session verification sub-process, a decompression method corresponding to the decompression sub-process and a deserialization method corresponding to the deserialization sub-process as an example, combined with Figure 4 The flowchart of the method for executing the first main process is shown as an example.
[0196] S41. According to the first packet conversion method, a first unified packet conversion sub-process is executed on the target network protocol and the target service request to obtain a unified packet that complies with preset rules.
[0197] The target service request can be understood as the original input of the client, which may not belong to a structure that the program can understand. Therefore, in S41, CGI can convert the original input target service request into a package body that conforms to preset rules, such as a structure that the program can understand, or a format that conforms to one or more of the set formats. The preset rules can be set according to demand, and this application does not limit this.
[0198] As an example, CGI can be Figure 3A The access protocol abstraction layer in constructs a packet processor according to the target service request. The packet processor can be understood as inheriting from Figure 3A The second class of the access protocol abstraction layer in the base class, determining the first package conversion method is equivalent to constructing an instance of the second class, so the method of the instance can be called through the base class to unpack and package the target service request, thereby obtaining a unified package that complies with the preset rules. Among them, unpacking can be converting the target service request into a structure in the program, and packaging can be composing the structure and the target network protocol into a package that complies with the preset rules.
[0199] In a possible embodiment, if the construction of the unified package session is successful, then the CGI can execute the subsequent first sub-processing logic. If the construction of the unified package session fails, it means that the target business request may be illegal or the CGI may not be able to process the target business request. Therefore, the CGI can stop performing the subsequent first sub-processing logic on the unified package and feedback abnormal prompt information to the client. The abnormal prompt information is used to prompt that the target business request is abnormal. Further, the abnormal prompt information may include the first sub-processing logic that failed to process. For example, the abnormal prompt information is "failed to construct the unified package, and the business request processing failed." This makes it easy for the client to find the cause of the abnormality.
[0200] S42. Based on the session verification method, execute the session verification sub-process on the unified package body.
[0201] In order to reduce illegal service requests, in the embodiment of the present application, CGI can use a session verification method to perform session verification on the unified package, which is equivalent to performing a legitimacy verification on the session corresponding to the target service request corresponding to the unified package, for example, whether the session sending the target service request is legal, or whether the session sends the target service request within the session validity period. The session verification method can, for example, use the session information corresponding to the target service request to perform session verification on the unified package, which process can also be called session information verification, or use token information to perform session verification, which process can also be called token information verification.
[0202] As an example, CGI can be Figure 3A The session abstraction layer in the , constitutes the session processor (SessionProcessor), which can be understood as inheriting from Figure 3A A second class in the session abstraction layer. Determining the session verification method is equivalent to constructing an instance of the session handler. CGI calls the method of the instance through the base class, which is equivalent to implementing the process of session verification on the unified package.
[0203] Among them, when performing session verification on the unified package, it involves how to obtain verification information for session verification, such as session information or token information, etc. For example, the verification information can be carried in the unified package, and CGI can obtain the verification information from the unified package, or CGI can obtain the verification information from the client. For example, the client sends the target service request and the verification information to CGI at the same time, and CGI obtains the verification information at the same time as obtaining the target service request.
[0204] In a possible embodiment, if the unified package session verification is successful, then CGI can execute the subsequent first sub-processing logic. If the unified package session verification fails, it means that the target business request may be illegal. Therefore, CGI can stop the subsequent first sub-processing logic for the unified package and feedback abnormal prompt information to the client. The meaning of the abnormal prompt information can refer to the content discussed in the previous article and will not be repeated here.
[0205] As an example, the plurality of first sub-processing logics may further include a decryption sub-process.
[0206] For example, the decryption sub-process may be after the session verification sub-process.
[0207] Specifically, if the CGI determines that the unified package session verification is successful, it can execute a decryption sub-process on the unified package to obtain information in the unified package, and the information in the unified package includes information of the package in the target service request and the target network protocol. For example, the CGI can determine the first implementation strategy corresponding to the decryption sub-process according to the target network protocol. The first implementation strategy of the decryption sub-process can be understood as a decryption method, and the CGI can use the decryption method to decrypt the unified package.
[0208] As a possible embodiment, the decryption sub-process may correspond to a decryption abstract layer, which may be understood as an abstract interface or an abstract class. CGI may construct a decryption processor through the decryption abstract layer. The decryption processor is equivalent to the second class inherited from the decryption layer. Determining the first implementation strategy corresponding to the decryption sub-process is equivalent to constructing an instance of the decryption processor. CGI may call the method of the instance through the base class, which is equivalent to decrypting the unified package.
[0209] Of course, in some cases, if the target business request is not generated through encryption, it can be understood that data is transmitted transparently between the client and the server, and CGI does not need to perform a decryption sub-process on the unified package body afterwards.
[0210] S43. Based on the decompression method, a decompression sub-process is executed on the result after executing the session verification sub-process.
[0211] The unified package body mentioned above, the result after executing the session verification sub-process, or the result after executing the decryption sub-process can actually be understood as a compressed package body. In order to obtain the specific information in the compressed package body, in an embodiment of the present application, CGI can adopt a corresponding decompression method to decompress the compressed package body to obtain the information in the unified package body.
[0212] For example, CGI can be Figure 3A The compression abstract layer in the compression processor (Compress Processor) is constructed according to the unified package. The compression processor is equivalent to a second class inherited from the compression abstract layer. Determining the compression method corresponding to the compression processor is equivalent to constructing an instance of the compression processor. Calling the method of the instance through the base class is equivalent to decompressing the compressed package.
[0213] S44, based on the deserialization method, executing a deserialization processing sub-process on the result after executing the decompression sub-process.
[0214] In order to facilitate the subsequent processing of the information in the target business request, in S44, CGI can deserialize the result after executing the decompression sub-process, which is equivalent to converting the result after the decompression sub-process into an object in the program, so that CGI can subsequently directly execute the corresponding business logic on the converted object.
[0215] As an example, CGI can be Figure 3A The serialization abstract layer in step 1.3 constructs a serialization processor according to the result of the decompression sub-process. The serialization processor is equivalent to a second class inherited from the serialization abstract layer. Determining the deserialization method corresponding to the serialization processor is equivalent to constructing an instance of the serialization processor. Calling the method of the instance through the base class is equivalent to deserializing the result after the decompression sub-process.
[0216] Figure 4 The embodiment shown provides a method for executing a first main process. Figure 4 In the embodiment shown, CGI can be used Figure 4 The steps shown execute the first main process to implement the protocol parsing process for the target service request. This embodiment can be applied to parse any type of service request, thereby improving the reusability of CGI and expanding the scope of application.
[0217] It should be noted that Figure 4 This is an example introduction to the way of executing the first main process in the embodiment of the present application, but it does not actually limit the multiple first sub-processing logics that may be included in the first main process, and the method of executing the first main process.
[0218] After executing S21 to S23 above, CGI has completed the protocol parsing process for the target service request, and can obtain the parsing result corresponding to the target service request. The parsing result can be understood as the result of performing protocol parsing on the target service request.
[0219] The CGI may execute S24 based on the parsing result. The following is an example of how S24 is executed.
[0220] First way:
[0221] CGI can directly execute the corresponding business logic according to the analysis results to obtain the business processing results.
[0222] Specifically, CGI has converted the target business request into an object that can be understood by the program through the steps S21-S23 in the above text, so CGI can use the corresponding program to execute the corresponding business logic on the parsing result to obtain the business processing result. Among them, the business logic can be set according to the requirements of the target business request, and this application does not limit this.
[0223] In the first method, the part of CGI that executes the business logic is independent of the part that parses the target business request, which reduces the impact between the two parts.
[0224] Second way:
[0225] By inheriting the third class from the base class, the corresponding business logic is executed to obtain the business processing result.
[0226] Specifically, the third category can also be called a business class, which can be a specific class that inherits from a base class. The base class can refer to the previous text, for example, inherited from Figure 3A A specific class of the business abstraction layer in . The corresponding business logic can be executed through this third class to obtain the business processing results.
[0227] In the embodiment of the present application, since the base class is common to multiple types of business requests, the third class can inherit the base class regardless of the type of business request, and execute business logic for multiple types of business requests without inheriting the base class of each type of business request, which simplifies the workload of business code development and reduces the difficulty of business code development. Moreover, the base class can directly obtain the business processing result.
[0228] The third way:
[0229] The corresponding business logic is executed through the fourth class to obtain the business processing results and register the callback function with the base class.
[0230] The fourth category can be understood as an independent specific class, that is, it does not need to inherit from the base class. In the embodiment of the present application, the business class does not need to inherit from the base class, which simplifies the development of the business code. Instead, it runs independently, executes the business logic, and registers a callback function to the base class, such as DoProcess. Moreover, the base class can directly obtain the business processing result through the callback function.
[0231] After obtaining the service processing result, CGI can use the service processing result as service return packet data. The encapsulation method of the service return packet data complies with the encapsulation method specified by the target network protocol. The encapsulation method can be understood as the encapsulation format of the data specified by the protocol. Alternatively, CGI can also perform protocol encapsulation on the service processing result to obtain service return packet data. After obtaining the service return packet data, CGI can feed back the service return packet data to the client.
[0232] This involves how CGI performs protocol encapsulation on business processing results, which is introduced with an example below.
[0233] Protocol encapsulation method 1:
[0234] The server or CGI can pre-store protocol encapsulation methods corresponding to various network protocols. After obtaining the service processing result, CGI can call the protocol encapsulation method corresponding to the target network protocol, use the protocol encapsulation method corresponding to the target network protocol, encapsulate the service processing result, and obtain the service return packet data.
[0235] Protocol encapsulation method 2:
[0236] CGI can execute the second main process on the business processing result based on the second implementation strategy corresponding to each of the multiple second sub-processing logics to obtain business packet return data. The meaning of the second main process can refer to the previous text.
[0237] CGI can use a second main process encapsulated by a pre-stored general protocol to encapsulate the business processing result, determine the second implementation strategy of each second sub-processing logic in the second main process, and then use the obtained multiple second implementation strategies to execute the second main process on the business processing result, thereby obtaining business return packet data.
[0238] The way in which CGI determines the second implementation strategy may refer to the way in which the first implementation strategy is determined as described above.
[0239] Alternatively, since the first main process and the second main process are actually opposite processing processes, in the embodiment of the present application, the CGI can also determine the second implementation strategy of the second sub-processing logic corresponding to the first sub-processing logic according to the first implementation strategy of the first sub-processing logic. For example, the first sub-processing logic is a decompression sub-process, and the second sub-processing logic corresponding to the first sub-processing logic is a compression sub-process. The CGI determines that the first implementation strategy of the decompression sub-process is the decompression method corresponding to LZ4, and the corresponding CGI can determine that the first implementation strategy of the compression sub-process is the LZ4 compression method.
[0240] In an embodiment of the present application, CGI can determine the second implementation strategy corresponding to the first implementation strategy, simplify the method of determining the second implementation strategy, and adopt a method corresponding to the target business request to perform protocol encapsulation on the business processing results, so that the client can adopt the corresponding method of generating the target business request and smoothly parse the business return packet data.
[0241] As an embodiment, the order in which CGI determines the second implementation strategy and determines the first implementation strategy can be arbitrary, and the present application does not limit this. For example, CGI can first determine the first implementation strategy and then determine the second implementation strategy, or CGI can determine the first implementation strategy and the second implementation strategy at the same time.
[0242] As an embodiment, the base class includes multiple fourth classes, each fourth class corresponds to a second sub-processing logic, and each second sub-processing logic is represented by a fifth class inherited from the corresponding fourth class. When executing the second main process, it specifically includes:
[0243] constructing a plurality of instances of the fifth class respectively, wherein each of the plurality of fifth classes corresponds to a second sub-processing logic of the plurality of second sub-processing logics;
[0244] Through the base class, the method of the instance corresponding to each first sub-processing logic in the multiple second sub-processing logics is called to execute the corresponding second sub-processing logic, thereby completing the execution process of the second main flow.
[0245] Furthermore, the fourth category may be the same category as the first category in the preceding text, which may further simplify code development.
[0246] In a possible embodiment, the CGI may also determine a third execution mode of the second main process.
[0247] Specifically, the meaning of the execution mode can refer to the previous text. CGI can determine the third execution mode of the second main process based on the target network protocol, or CGI determines the third execution mode corresponding to the first execution mode. The third execution mode corresponding to the first execution mode means that the second sub-processing logic corresponding to the first sub-processing logic that belongs to the empty implementation in the first execution mode also belongs to the empty implementation in the third execution mode, and the second sub-processing logic corresponding to the first sub-processing logic that belongs to the non-empty implementation in the first execution mode also belongs to the non-empty implementation in the third execution mode.
[0248] As an embodiment, the order in which the CGI determines the first execution mode of the first main process and determines the third execution mode of the second main process may be arbitrary. For example, the CGI may determine the first execution mode first and then determine the third execution mode.
[0249] As an embodiment, while determining the first execution mode, the first sub-processing logic belonging to the empty implementation in the first main process has been determined. Therefore, CGI does not need to determine the third execution mode, but can directly refer to the first execution mode to determine the second sub-processing logic corresponding to the first sub-processing logic belonging to the empty implementation as an empty implementation, and determine the second sub-processing logic corresponding to the first sub-processing logic of the non-empty implementation as a non-empty implementation.
[0250] As an example, continue to refer to Figure 3A The plurality of second sub-processing logics include a serialization sub-process, a compression sub-process, a session signature sub-process, and a second unified package body conversion sub-process. The plurality of second implementation strategies include a serialization method corresponding to the serialization sub-process, a compression method corresponding to the compression sub-process, a session signature method corresponding to the session signature sub-process, and a second package body conversion method corresponding to the second unified package body conversion sub-process.
[0251] It should be noted that the first unified packet conversion sub-process in the above text refers to converting the target business request into a unified packet that complies with preset rules, and the second unified packet conversion sub-process refers to encapsulating the business processing results into business return packet data that meets the target network protocol.
[0252] In order to more clearly illustrate the execution process of the second main process, the following takes multiple second sub-processing logics including a serialization sub-process, a compression sub-process, a session signature sub-process and a second unified package conversion sub-process, and multiple second implementation strategies including a serialization method corresponding to the serialization sub-process, a compression method corresponding to the compression sub-process, a session signature method corresponding to the session signature sub-process, and a second package conversion method corresponding to the second unified package conversion sub-process as an example, combined with Figure 5 The flowchart of the method for executing the second main process shown is used as an example.
[0253] S51, based on the serialization method, execute the serialization sub-process for the business processing result.
[0254] Serialization is the opposite process of deserialization mentioned above. In computer science data processing, serialization refers to the process of converting data structures or object states into a usable format so that they can be restored to their original state in the same or another computer environment.
[0255] As an example, CGI can be implemented by Figure 3A The serialization abstract layer in the serialization abstract layer can be understood as a first class, or a fourth class. Constructing a serialization processor, which can be understood as a second class, or a fifth class, determining the serialization method is equivalent to constructing another instance of the serialization processor. Calling the method of the instance through the base class is equivalent to executing a serialization sub-process on the business processing result.
[0256] S52, based on the compression method, executing a compression sub-process on the result after executing the serialization sub-process.
[0257] The compression sub-process is the opposite of the decompression sub-process mentioned above.
[0258] As an example, CGI can be Figure 3AThe compression abstract layer in the compression abstract layer can be understood as a first class, or a fourth class, constituting a compression processor, which can be understood as a second class, or a fifth class. Determining the compression method is equivalent to constructing another instance of the compression processor. Calling the method of the instance through the base class is equivalent to executing the compression sub-process.
[0259] S53, based on the session signature method, executing the session signature sub-process on the result after executing the compression sub-process.
[0260] The session signature sub-process is the opposite of the session verification sub-process mentioned above.
[0261] As an example, CGI can be Figure 3A The session abstraction layer in the session abstraction layer can be understood as a first class, or a fourth class. Constructing a session processor (Session Processor), which can be understood as a second class, or a fifth class, determining the session verification method is equivalent to constructing another instance of the session processor. Calling the method of the instance through the base class is equivalent to executing the session signature sub-process.
[0262] As an embodiment, the plurality of second sub-processing logics may further include an encryption sub-process.
[0263] The encryption sub-process is the opposite of the decryption sub-process mentioned above.
[0264] Specifically, after performing a session signature on the result after executing the compression sub-process, CGI can determine the second implementation strategy corresponding to the encryption sub-process based on the target network protocol. The second implementation strategy can be specifically understood as an encryption method, which is used to encrypt the result after executing the session signature sub-process.
[0265] As an embodiment, the encryption sub-process may correspond to the decryption abstract layer in the foregoing text. The meaning of the decryption abstract layer may refer to the foregoing text. CGI may construct a decryption processor through the decryption abstract layer. The meaning of the decryption processor may refer to the foregoing text. The second implementation strategy corresponding to the encryption sub-process is determined, which is equivalent to constructing another instance of the decryption processor. CGI may call the method of the instance through the base class, which is equivalent to encrypting the result after executing the session signature sub-process.
[0266] S54, based on the second unified package conversion method, executing the second unified package conversion sub-process on the result after executing the session signature sub-process.
[0267] The second unified package conversion sub-process is the opposite process to the first unified package conversion sub-process. The meaning of the second unified package conversion sub-process can be referred to in the previous text.
[0268] As an example, CGI can be Figure 3A The access protocol abstraction layer in the access protocol abstraction layer can be understood as a first class, or a fourth class, constructing a packet processor (Pack Processor), which can be understood as a second class, or a fifth class. Determining the second unified packet conversion method is equivalent to constructing another instance of the packet processor. Calling the method of the instance through the base class is equivalent to executing the second unified packet conversion sub-process, so that the business can return packet data.
[0269] exist Figure 5 In the embodiment shown, the main processing logic further defines a second main process, and the first sub-processing logics in the first main process and the second sub-processing logics in the second main process can be controlled by Figure 3A The various abstract layers defined in are implemented, so that CGI can use a unified process to implement protocol parsing and protocol encapsulation for multiple types of network protocols. This not only improves the reusability of CGI, but also simplifies the code development of CGI. Subsequent business logic can inherit a base class, simplifying the development of business code corresponding to the business logic.
[0270] As the types of network protocols continue to increase, it may be necessary to expand the network protocols adapted by CGI, that is, it is necessary to add a protocol processing function to CGI to adapt to a new type of network protocol. In this case, CGI can write the second execution mode of the new type of business request into the execution mode set, where the meaning of the second execution mode can be referred to in the previous text. The second execution mode is the execution mode of the first main process corresponding to the new type of business request.
[0271] Similarly, CGI can also write the fourth execution mode of the second main process corresponding to the newly added type of network protocol into the execution mode set. The fourth execution mode is the execution mode of the second main process corresponding to the newly added type of service request.
[0272] Specifically, the CGI architecture is as follows Figure 1C Taking the shown architecture as an example, the CGI may configure one or both of the second execution mode and the fourth execution mode to the processor factory.
[0273] When a new type of network protocol is added, a sub-processing logic may have a new implementation strategy, or a sub-processing logic may have a new implementation strategy. In these cases, CGI can write the new implementation strategy into the strategy set. For example, CGI can write a new first implementation strategy corresponding to a first sub-processing logic into the strategy set, and CGI can also write a new second implementation strategy corresponding to a second sub-processing logic into the strategy set.
[0274] Specifically, the CGI architecture is as follows Figure 1C As an example of the architecture shown in the figure, CGI can write one or both of the newly added implementation strategy and the second implementation strategy into Figure 1C The implementation strategy in is centralized.
[0275] In an embodiment of the present application, when CGI needs to expand the protocol processing function corresponding to a new type of network protocol, the corresponding execution mode or implementation strategy of the network protocol can be configured accordingly. The method of expanding the function of CGI is simple and fast, and there is no need to change the main processing logic, and the code changes are relatively small.
[0276] In order to more clearly illustrate the service request processing method in the embodiment of the present application, Figure 1B As an example, the client and server in the embodiment cooperate to execute the service request processing method. Figure 6 The interaction diagram between the client and the server is shown as an example. Figure 6 , the interaction process specifically includes the following steps.
[0277] S61, the client sends a target service request to the server.
[0278] The method for the client to generate the target service request and the meaning of the target service request can be referred to in the previous text.
[0279] S62: The server obtains a target network protocol corresponding to the target service request.
[0280] The method for determining the target network protocol can refer to the content discussed above.
[0281] S63: The server determines a first implementation strategy for each of the plurality of first sub-processing logics in the main processing logic based on the target network protocol.
[0282] The manner of determining the first implementation strategy, the meaning of the main processing logic, and the meaning of the first sub-processing logic may refer to the foregoing text.
[0283] S64: The server executes the first main process on the target business request based on the obtained multiple first implementation strategies to obtain a parsing result of the target business request.
[0284] The method of executing the first main process and the meaning of the analysis results can be referred to in the previous text.
[0285] S65, based on the analysis result, the target service request is processed accordingly to obtain service response data.
[0286] The corresponding processing method for the target service request and the meaning of the service response data can refer to the previous text.
[0287] S66: The server feeds back the service response data to the client.
[0288] After obtaining the service packet data, the client can parse the service packet data and then display the corresponding data fed back by the server.
[0289] For example, see Figure 7 , which is an example of the client interface changes during the business request processing. Figure 7 In (1), the search keyword "what is healthy fruit" is input, and the client generates a service request based on the search keyword. The service request is as follows: Figure 7 The client then sends the service request to the server, which processes the service request and obtains the service response data. The client then displays the service response data as shown in (2). Figure 7 The search result shown in (2) is, for example, "Top 10 healthy fruits, apple is ranked first".
[0290] Based on the same inventive concept, the embodiment of the present application provides a service request processing device, which can realize the function of the server, the function of the terminal device, or the function of CGI in the above text, please refer to Figure 8 , the service request processing device comprises:
[0291] The protocol acquisition module 801 is used to obtain the target network protocol corresponding to the target service request;
[0292] A strategy determination module 802 is used to determine, based on a target network protocol, a first implementation strategy of each of a plurality of first sub-processing logics in a main processing logic, wherein the main processing logic includes a first main process commonly used when performing protocol parsing on multiple types of service requests, the first main process includes a plurality of first sub-processing logics, and the main processing logic is pre-configured, and one type of service request among the multiple types of service requests corresponds to one network protocol;
[0293] A process execution module 803 is used to execute a first main process on a target business request based on the obtained multiple first implementation strategies to obtain a parsing result of the target business request;
[0294] The service execution module 804 is used to process the target service request accordingly based on the analysis result.
[0295] In a possible embodiment, the policy determination module 802 is specifically configured to:
[0296] Determine a first execution mode corresponding to the target business request from the execution mode set, wherein each execution mode in the execution mode set represents at least one first sub-processing logic with non-empty implementation and at least one first sub-processing logic with empty implementation among multiple first sub-processing logics when parsing a type of business request, and the empty-implemented first sub-processing logic means that an input when executing the first sub-processing logic is the same as an output after executing the first sub-processing logic;
[0297] Based on the target network protocol, the first implementation strategy for the first sub-processing logic of each non-empty implementation and the first implementation strategy for the first sub-processing logic of each empty implementation are determined from the implementation strategy set, wherein each implementation strategy in the implementation strategy set is an implementation method of a sub-processing logic, and the first implementation strategy corresponding to the first sub-processing logic of each empty implementation is used for the first sub-processing logic corresponding to the empty implementation.
[0298] In a possible embodiment, the device further includes a writing module 805, wherein the writing module 805 is specifically configured to:
[0299] Writing a second execution mode of the newly added type of business request into the execution mode set, the second execution mode including at least one first type of sub-processing logic with non-empty implementation and at least one second type of sub-processing logic with empty implementation among the multiple sub-processing logics when parsing the newly added type of business request;
[0300] The newly added implementation strategy is written into the implementation strategy set, wherein the newly added implementation strategy is a newly added implementation method of a sub-processing logic.
[0301] In a possible embodiment, the main processing logic further includes an execution order of multiple first sub-processing logics, the multiple first sub-processing logics include a first unified package conversion sub-process, a session verification sub-process, a decompression sub-process and a deserialization sub-process, and the multiple first implementation strategies include a first package conversion method corresponding to the unified package conversion sub-process, a session verification method corresponding to the session verification sub-process, a decompression method corresponding to the decompression sub-process and a deserialization method corresponding to the deserialization sub-process; the process execution module 803 is specifically used to:
[0302] Based on multiple first implementation strategies, the following multiple sub-processing logics are executed for the business request in the order of execution:
[0303] Based on the first packet conversion method, a first unified packet conversion sub-process is executed on the target network protocol and the target service request to obtain a unified packet that complies with preset rules;
[0304] Based on the session verification method, the session verification sub-process is executed on the unified package body;
[0305] Based on the decompression method, a decompression sub-process is executed on the result after executing the session verification sub-process;
[0306] Based on the deserialization method, a deserialization processing sub-process is performed on the result after executing the decompression sub-process.
[0307] In a possible embodiment, the main processing logic is represented by a base class, the base class includes a plurality of first classes, each first class corresponds to a first sub-processing logic, and each first sub-processing logic is represented by a second class inherited from the corresponding first class;
[0308] A policy determination module 802 is specifically configured to construct a plurality of respective instances of the second class based on a target network protocol, wherein each of the plurality of second classes corresponds to a first sub-processing logic of the plurality of first sub-processing logics;
[0309] The process execution module 803 is specifically used to call the method of the instance corresponding to each first sub-processing logic in the multiple first sub-processing logics through the base class to execute the corresponding first sub-processing logic.
[0310] In a possible embodiment, the main processing logic further includes a second main process commonly used when performing protocol encapsulation on multiple types of business processing results, and the second main process includes multiple second sub-processing logics; the business execution module 804 is specifically used to:
[0311] Based on the analysis results, execute the business logic corresponding to the target business request to obtain the business processing results;
[0312] Based on the second implementation strategies corresponding to each of the multiple second sub-processing logics, the second main process is executed on the business processing results to obtain business packet return data, wherein the business packet return data is data that meets the target network protocol, wherein each second implementation strategy is determined based on the target network protocol and is an implementation method of a second sub-processing logic.
[0313] In a possible embodiment, the plurality of second sub-processing logics include a serialization sub-process, a compression sub-process, a session signature sub-process, and a second unified package body conversion sub-process, and the second implementation strategies corresponding to the plurality of second sub-processing logics respectively include a serialization method corresponding to the serialization sub-process, a compression method corresponding to the compression sub-process, a session signature method corresponding to the session signature sub-process, and a second package body conversion method corresponding to the second unified package body conversion sub-process; the business execution module 804 is specifically used to:
[0314] Based on the serialization method, the serialization sub-process is executed for the business processing results;
[0315] Based on the compression method, a compression sub-process is executed on the result after executing the serialization sub-process;
[0316] Based on the session signature method, a session signature sub-process is executed on the result after executing the compression sub-process;
[0317] Based on the second unified package conversion method, the second unified package conversion sub-process is executed on the result after executing the session signature sub-process.
[0318] In a possible embodiment, the main processing logic is represented by a base class; the service execution module 804 is specifically used for:
[0319] Through the third class inherited from the base class, the business logic is executed based on the parsing results to obtain the business processing results.
[0320] In a possible embodiment, the main processing logic is represented by a base class, the base class includes multiple fourth classes, each fourth class corresponds to a second sub-processing logic, and each second sub-processing logic is represented by a fifth class inherited from the corresponding fourth class; the business execution module 804 is specifically used to:
[0321] constructing a plurality of instances of the fifth class respectively, wherein each of the plurality of fifth classes corresponds to a second sub-processing logic of the plurality of second sub-processing logics;
[0322] Through the base class, a method of an instance corresponding to each first sub-processing logic in a plurality of second sub-processing logics is called to execute the corresponding second sub-processing logic.
[0323] Based on the same inventive concept, the embodiment of the present application provides a computer device, which can realize the functions of the terminal device, the server or the CGI mentioned above. Please refer to Fig. 9 , the computer device includes a processor 901 and a memory 902.
[0324] The processor 901 may be a central processing unit (CPU) or a digital processing unit, etc. The specific connection medium between the memory 902 and the processor 901 is not limited in the embodiment of the present application. Fig. 9 In the embodiment, the memory 902 and the processor 901 are connected via a bus 903. The bus 903 is connected to the processor 901 via a bus 903. Fig. 9 The connections between other components are shown in bold lines, which are only for illustration and are not intended to be limiting. Bus 903 can be divided into address bus, data bus, control bus, etc. For ease of illustration, Fig. 9 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0325] The memory 902 may be a volatile memory, such as a random-access memory (RAM); the memory 902 may also be a non-volatile memory, such as a read-only memory, a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD), or the memory 902 may be any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 902 may be a combination of the above memories.
[0326] The processor 901 is configured to execute any of the service request processing methods discussed above when calling the computer program stored in the memory 902 .
[0327] Based on the same inventive concept, an embodiment of the present application provides a computer storage medium, which stores computer instructions. When the computer instructions are executed on a computer, the computer executes any of the business request processing methods discussed above.
[0328] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0329] Based on the same inventive concept, an embodiment of the present application provides a computer program product, which includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes any of the above-mentioned service request processing methods.
[0330] A person skilled in the art can understand that: all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium includes: mobile storage devices, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), disks or optical disks, etc. Various media that can store program codes.
[0331] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiment of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, magnetic disks or optical disks.
[0332] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A method for processing a business request, characterized in that: include: Obtaining a target network protocol corresponding to a target service request; Based on the target network protocol, determining first implementation strategies of the plurality of first sub-processing logics in the main processing logic, wherein the main processing logic includes a first main process commonly used when performing protocol parsing on multiple types of service requests, the first main process includes the plurality of first sub-processing logics, and the main processing logic is pre-configured, and one type of service request among the multiple types of service requests corresponds to one network protocol; Based on the obtained multiple first implementation strategies, executing the first main process on the target business request to obtain a parsing result of the target business request; Based on the analysis result, the target service request is processed accordingly; Wherein, based on the target network protocol, determining the first implementation strategy of each of the plurality of first sub-processing logics in the main processing logic includes: Determine a first execution mode corresponding to the target business request from an execution mode set, wherein each execution mode in the execution mode set indicates that when parsing a type of business request, at least one first sub-processing logic among the multiple first sub-processing logics is implemented as non-empty, and at least one first sub-processing logic is implemented as empty, and the empty-implemented first sub-processing logic means that an input when executing the first sub-processing logic is the same as an output after executing the first sub-processing logic; Based on the target network protocol, the first implementation strategy for the first sub-processing logic of each non-empty implementation and the first implementation strategy for the first sub-processing logic of each empty implementation are determined from the implementation strategy set, wherein each implementation strategy in the implementation strategy set is an implementation method of a sub-processing logic, and the first implementation strategy corresponding to the first sub-processing logic of each empty implementation is used for the first sub-processing logic corresponding to the empty implementation.
2. The method according to claim 1, characterized in that The method further comprises at least one of the following: Writing a second execution mode of a newly added type of business request into the execution mode set, wherein the second execution mode includes at least one first type of sub-processing logic with a non-empty implementation and at least one second type of sub-processing logic with an empty implementation among the multiple first sub-processing logics when parsing the newly added type of business request; The newly added implementation strategy is written into the implementation strategy set, wherein the newly added implementation strategy is a newly added implementation method of a sub-processing logic.
3. The method according to claim 1, characterized in that The main processing logic also includes the execution order of the multiple first sub-processing logics, the multiple first sub-processing logics include a first unified package conversion sub-process, a session verification sub-process, a decompression sub-process and a deserialization sub-process, and the multiple first implementation strategies include a first package conversion method corresponding to the first unified package conversion sub-process, a session verification method corresponding to the session verification sub-process, a decompression method corresponding to the decompression sub-process and a deserialization method corresponding to the deserialization sub-process; Based on the obtained multiple first implementation strategies, executing the first main process for the target service request includes: Based on the multiple first implementation strategies and in the execution order, the following multiple first sub-processing logics are executed on the service request: Based on the first packet conversion method, the first unified packet conversion sub-process is executed on the target network protocol and the target service request to obtain a unified packet that complies with preset rules; Based on the session verification method, executing a session verification sub-process on the unified package; Based on the decompression method, a decompression sub-process is executed on the result after executing the session verification sub-process; Based on the deserialization method, a deserialization processing sub-process is performed on the result after the decompression sub-process is executed.
4. The method according to claim 1, characterized in that The main processing logic is represented by a base class, the base class includes a plurality of first classes, each first class corresponds to a first sub-processing logic, and each first sub-processing logic is represented by a second class inherited from the corresponding first class; Based on the target network protocol, determining first implementation strategies of each of the plurality of first sub-processing logics in the main processing logic includes: Based on the target network protocol, constructing a plurality of respective instances of the second class, wherein each second class in the plurality of second classes corresponds to a first sub-processing logic in the plurality of first sub-processing logics; Based on the obtained multiple first implementation strategies, executing the first main process for the target service request includes: The method of the instance corresponding to each first sub-processing logic in the multiple first sub-processing logics is called through the base class to execute the corresponding first sub-processing logic.
5. The method according to any one of claims 1 to 4, characterized in that: The main processing logic also includes a second main process commonly used when performing protocol encapsulation on multiple types of business processing results, and the second main process includes multiple second sub-processing logics; Based on the analysis result, the target service request is processed accordingly, including: Based on the analysis result, executing the business logic corresponding to the target business request to obtain a business processing result; Based on the second implementation strategies corresponding to each of the multiple second sub-processing logics, the second main process is executed on the business processing result to obtain business packet return data, wherein the business packet return data is data that satisfies the target network protocol, wherein each second implementation strategy is determined based on the target network protocol and is an implementation method of a second sub-processing logic.
6. The method according to claim 5, characterized in that The multiple second sub-processing logics include a serialization sub-process, a compression sub-process, a session signature sub-process, and a second unified package body conversion sub-process, and the second implementation strategies corresponding to each of the multiple second sub-processing logics include a serialization method corresponding to the serialization sub-process, a compression method corresponding to the compression sub-process, a session signature method corresponding to the session signature sub-process, and a second package body conversion method corresponding to the second unified package body conversion sub-process; Based on the second implementation strategies respectively corresponding to the plurality of second sub-processing logics, executing the second main process on the business processing result includes: Based on the serialization method, executing the serialization sub-process on the business processing result; Based on the compression method, a compression sub-process is executed on the result after executing the serialization sub-process; Based on the session signature method, executing the session signature sub-process on the result after executing the compression sub-process; Based on the second package conversion method, the second unified package conversion sub-process is executed on the result after executing the session signature sub-process.
7. The method according to claim 5, characterized in that The main processing logic is represented by a base class; Based on the analysis result, executing the business logic corresponding to the target business request to obtain the business processing result includes: The business logic is executed based on the parsing result through the third class inherited from the base class to obtain the business processing result.
8. The method according to claim 5, characterized in that The main processing logic is represented by a base class, the base class includes a plurality of fourth classes, each fourth class corresponds to a second sub-processing logic, and each second sub-processing logic is represented by a fifth class inherited from the corresponding fourth class; Based on the second implementation strategies respectively corresponding to the plurality of second sub-processing logics, executing the second main process on the business processing result includes: constructing a plurality of instances of the fifth class respectively, wherein each of the plurality of fifth classes corresponds to a second sub-processing logic in the plurality of second sub-processing logics; Through the base class, a method of an instance corresponding to each first sub-processing logic in the plurality of second sub-processing logics is called to execute the corresponding second sub-processing logic.
9. A service request processing device, characterized in that: include: A protocol acquisition module, used to obtain a target network protocol corresponding to a target service request; a strategy determination module, configured to determine, based on the target network protocol, a first implementation strategy of each of a plurality of first sub-processing logics in the main processing logic, wherein the main processing logic includes a first main process commonly used when performing protocol parsing on multiple types of service requests, the first main process includes the multiple first sub-processing logics, and the main processing logic is pre-configured, and one type of service request among the multiple types of service requests corresponds to one network protocol; A process execution module, configured to execute the first main process on the target business request based on the obtained multiple first implementation strategies, and obtain a parsing result of the target business request; A service execution module, used for processing the target service request accordingly based on the analysis result; Wherein, based on the target network protocol, determining the first implementation strategy of each of the plurality of first sub-processing logics in the main processing logic includes: Determine a first execution mode corresponding to the target business request from an execution mode set, wherein each execution mode in the execution mode set indicates that when parsing a type of business request, at least one first sub-processing logic among the multiple first sub-processing logics is implemented as non-empty, and at least one first sub-processing logic is implemented as empty, and the empty-implemented first sub-processing logic means that an input when executing the first sub-processing logic is the same as an output after executing the first sub-processing logic; Based on the target network protocol, the first implementation strategy for the first sub-processing logic of each non-empty implementation and the first implementation strategy for the first sub-processing logic of each empty implementation are determined from the implementation strategy set, wherein each implementation strategy in the implementation strategy set is an implementation method of a sub-processing logic, and the first implementation strategy corresponding to the first sub-processing logic of each empty implementation is used for the first sub-processing logic corresponding to the empty implementation.
10. A computer device, characterized in that: include: at least one processor, and a memory communicatively coupled to the at least one processor; The memory stores instructions that can be executed by the at least one processor, and the at least one processor implements the method according to any one of claims 1 to 8 by executing the instructions stored in the memory.
11. A computer storage medium, characterized in that: The computer storage medium stores computer instructions, and when the computer instructions are executed on a computer, the computer is enabled to execute the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Common gateway interface request processing method, device and memory medium
CN108023966A
Task processing method and device, electronic equipment and storage medium
CN111176802A