CN115550468A - Service request processing method, device, equipment and medium - Google Patents

Service request processing method, device, equipment and medium Download PDF

Info

Publication number
CN115550468A
CN115550468A CN202110725546.3A CN202110725546A CN115550468A CN 115550468 A CN115550468 A CN 115550468A CN 202110725546 A CN202110725546 A CN 202110725546A CN 115550468 A CN115550468 A CN 115550468A
Authority
CN
China
Prior art keywords
sub
processing
processing logic
service request
implementation
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110725546.3A
Other languages
Chinese (zh)
Inventor
申彬
张东何
邓锦福
吴敦为
张文瑞
范亮亮
李子珏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202110725546.3A priority Critical patent/CN115550468A/en
Publication of CN115550468A publication Critical patent/CN115550468A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/18Multiprotocol handlers, e.g. single devices capable of handling multiple protocols

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer And Data Communications (AREA)

Abstract

The application provides a method, a device, equipment and a medium for processing a service request, relates to the technical field of computers, and is used for improving the reusability of a CGI. The method comprises the following steps: the method comprises the steps of pre-configuring a general main processing logic for processing various types of service requests, after receiving a target service request, determining respective first implementation strategies of each first sub-processing logic in the main processing logic according to a target network protocol of the target service request, and analyzing the target service request based on a plurality of first implementation strategies, namely, each CGI can define the general main processing logic, and when processing a certain type of service request, selecting a corresponding implementation strategy according to the service request, so that each CGI can process any type of service request, and the reusability of the CGI is improved.

Description

Service request processing method, device, equipment and medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a medium for processing a service request.
Background
Common Gateway Interface (CGI) generally refers to an Application Programming Interface (API) provided by a server to an external device, such as a mobile phone or an internet of things device. Different external devices may access the server using different network protocols, such as hypertext transfer protocol (HTTP) or message queue telemetry (MQTT) protocol, which requires some compatibility of the server.
Currently, a server generally creates a plurality of CGIs, each CGI is used for adapting to a corresponding network protocol, so that the server can be compatible with more network protocols, but each CGI can only process the network protocol corresponding to the CGI, i.e. the reusability of a single CGI is poor.
Disclosure of Invention
Embodiments of the present application provide a method, an apparatus, a device, and a medium for processing a service request, which are used to improve reusability of a CGI.
In one aspect, a method for processing a service request is provided, including:
acquiring a target network protocol corresponding to the target service request;
determining a first implementation strategy of each of a plurality of first sub-processing logics in a main processing logic based on the target network protocol, wherein the main processing logic comprises a first main flow which is common when a plurality of types of service requests are subjected to protocol analysis, the first main flow comprises the plurality of first sub-processing logics, the main processing logic is pre-configured, and one type of service request in the plurality of types of service requests corresponds to one network protocol;
executing the first main flow to the target service request based on the obtained multiple first implementation strategies to obtain an analysis result of the target service request;
and correspondingly processing the target service request based on the analysis result.
An embodiment of the present application provides a service request processing apparatus, including:
the protocol obtaining module is used for obtaining a target network protocol corresponding to the target service request;
a policy determining module, configured to determine, based on the target network protocol, a first implementation policy of each of a plurality of first sub-processing logics in a main processing logic, where the main processing logic includes a first main flow that is common when performing protocol parsing on multiple types of service requests, the first main flow includes the plurality of first sub-processing logics, and the main processing logic is preconfigured, and one type of service request in the multiple types of service requests corresponds to one network protocol;
the process execution module is used for executing the first main process to the target service request based on the obtained multiple first implementation strategies to obtain an analysis result of the target service request;
and the service execution module is used for carrying out corresponding processing on the target service request based on the analysis result.
In a possible embodiment, the policy determination module is specifically configured to:
determining a first execution mode corresponding to the target service request from an execution mode set, wherein each execution mode in the execution mode set represents at least one first sub-processing logic which is not implemented in a null mode and at least one first sub-processing logic which is implemented in a null mode in the plurality of first sub-processing logics when one type of service request is analyzed, and the first sub-processing logic implemented in the null mode refers to the same input when the first sub-processing logic is executed and the same output after the first sub-processing logic is executed;
and respectively determining a first implementation policy of the first sub-processing logic of each non-null implementation and a first implementation policy of the first sub-processing logic of each null implementation from an implementation policy set based on the target network protocol, wherein each implementation policy in the implementation policy set is an implementation manner of one sub-processing logic, and the first implementation policy corresponding to the first sub-processing logic of each null implementation is used for implementing the corresponding first sub-processing logic in the null implementation.
In a possible embodiment, the apparatus further includes a writing module, where the writing module is specifically configured to:
writing a second execution mode of the newly added service request into the execution mode set, wherein the second execution mode comprises at least one first type sub-processing logic which is realized in a non-null mode and at least one second type sub-processing logic which is realized in a null mode in the plurality of sub-processing logics when the newly added service request is analyzed;
and writing the newly added implementation strategy into the implementation strategy set, wherein the newly added implementation strategy is a newly added implementation mode of the sub-processing logic.
In one possible embodiment, the main processing logic further includes an execution order of the plurality of first sub-processing logics, the plurality of first sub-processing logics includes a first unified packet body conversion sub-flow, a session check sub-flow, a decompression sub-flow, and a deserialization sub-flow, and the plurality of first implementation policies includes a first packet body conversion method corresponding to the unified packet body conversion sub-flow, a session check method corresponding to the session check sub-flow, a decompression method corresponding to the decompression sub-flow, and a deserialization method corresponding to the deserialization sub-flow; the flow executing module is specifically configured to:
based on the plurality of first implementation strategies, executing the following plurality of sub-processing logics for the service request according to the execution sequence:
based on the first packet body conversion method, executing the first unified packet body conversion sub-process on the target network protocol and the target service request to obtain a unified packet body which accords with a preset rule;
based on the session check method, executing a session check sub-process on the unified packet body;
based on the decompression method, executing a decompression sub-process on a result obtained after the session check sub-process is executed;
and executing the deserialization sub-process on the result of executing the decompression sub-process based on the deserialization method.
In a possible embodiment, the main processing logic is represented by a base class, where 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;
the policy determining module is specifically configured to construct respective instances of a plurality of second classes based on the target network protocol, where each of the plurality of second classes corresponds to one of the plurality of first sub-processing logics;
the process execution module is specifically configured to invoke, through the base class, a method of an instance corresponding to each of the plurality of first sub-processing logics, and execute the corresponding first sub-processing logic.
In a possible embodiment, the main processing logic further includes a second main flow common in performing protocol encapsulation on multiple types of service processing results, and the second main flow includes multiple second sub-processing logics; the service execution module is specifically configured to:
based on the analysis result, executing a service logic corresponding to the target service request to obtain a service processing result;
and executing the second main process on the service processing result based on second implementation strategies corresponding to the second sub-processing logics respectively to obtain service packet data, wherein the service packet data is data meeting the target network protocol, and each second implementation strategy is determined based on the target network protocol and is an implementation manner of one second sub-processing logic.
In a possible embodiment, the second implementation policies corresponding to the second sub-processing logics include a serialization sub-process, a compression sub-process, a session signature sub-process, and a second unified body conversion sub-process, and the second implementation policies corresponding to the 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 body conversion method corresponding to the second unified body conversion sub-process; the service execution module is specifically configured to:
based on the serialization method, the serialization sub-process is executed for the service processing result;
executing a compression sub-process on a result after the serialization sub-process is executed based on the compression method;
executing the session signature sub-process on the result of executing the compression sub-process based on the session signature method;
and executing the second unified bag body conversion sub-process on the result after the session signature sub-process is executed based on the second unified bag body conversion method.
In one possible embodiment, the main processing logic is represented by a base class; the service execution module is specifically configured to:
and executing the service logic based on the analysis result through a third class inherited to the base class to obtain a service processing result.
In a possible embodiment, the main processing logic is represented by a base class, where 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; the service execution module is specifically configured to:
constructing respective instances of a plurality of fifth classes, wherein each of the plurality of fifth classes corresponds to one of the plurality of second sub-processing logics;
and calling the method of the corresponding instance of each first sub-processing logic in the plurality of second sub-processing logics through the base class, and executing the corresponding second sub-processing logic.
An embodiment of the present application provides a computer device, including:
at least one processor, and a memory communicatively coupled to the at least one processor;
wherein the memory stores instructions executable by the at least one processor, the at least one processor implementing the method as any one of the service request processing methods discussed above by executing the instructions stored by the memory.
Embodiments of the present application provide a computer storage medium storing computer instructions, which when executed on a computer, cause the computer to perform the method as in any one of the service request processing methods discussed above.
Due to the adoption of the technical scheme, the embodiment of the application has at least the following technical effects:
in the embodiment of the application, a first main flow common to multiple types of service requests is configured in advance, when a certain service request is analyzed, a network protocol corresponding to the service request is determined first, then a first implementation policy of each first sub-processing logic in the first main flow is determined according to the network protocol, that is, a specific implementation of each first sub-processing logic is determined, so that the service request is analyzed according to each first implementation policy. Moreover, for analyzing service requests of different network protocols, only the first implementation strategy of the respective first sub-processing logic of each network protocol needs to be defined, and the first main flow does not need to be changed, so that the workload and the difficulty of developing codes corresponding to the protocol analysis process can be reduced.
Drawings
Fig. 1A is a schematic diagram of a network architecture to which the service request processing method according to the embodiment of the present application is applied;
fig. 1B is a schematic view of a scenario to which the service request processing method provided in the embodiment of the present application is applied;
fig. 1C is a schematic diagram of a framework for fusing CGI according to an embodiment of the present application;
fig. 2 is a schematic flowchart of a service request processing method according to an embodiment of the present application;
FIG. 3A is a schematic diagram of main processing logic provided in accordance with an embodiment of the present application;
FIG. 3B is a diagram illustrating a base class, a first class, and a second class provided by an embodiment of the present application;
fig. 4 is a schematic flowchart of a first main process executed according to an embodiment of the present application;
fig. 5 is a schematic flow chart illustrating a second main flow executed according to an embodiment of the present application;
FIG. 6 is a schematic diagram of an interaction between a client and a server in FIG. 1B according to an embodiment of the present application;
fig. 7 is a schematic diagram of an interface change in a service request processing process according to an embodiment of the present application;
fig. 8 is a schematic structural diagram of a service request processing apparatus according to an embodiment of the present application;
fig. 9 is a schematic structural diagram of a computer device according to an embodiment of the present application.
Detailed Description
In order to better understand the technical solutions provided by the embodiments of the present application, the following detailed description is made with reference to the drawings and specific embodiments.
To facilitate better understanding of the technical solutions of the present application for those skilled in the art, the following terms related to the present application are introduced.
1. Common Gateway Interface (CGI): in the computer field, CGI assists web services in executing programs similar to console applications (also referred to as command-line interfaces programs), which are a common protocol for implementing dynamic page provisioning on a server, and are referred to as CGI scripts. Typically, a request corresponds to the execution of one CGI script at a time, and a web page is generated. In short, a service request sends data from a client to a CGI program via standard input, which may be regarded as a CGI service, or CGI for short, and may carry other data, such as a Uniform Resource Locator (URL) path, a hypertext transfer protocol (HTTP) header, or one or more of environment variables converted into a process, in addition to the standard input. In other words, the interaction between the client and the server can be accomplished through the CGI, such as sending a message, searching for a good, adding a friend, and the like. The client in the embodiment of the present application generally refers to an application program, an applet, a web page, or the like, which is not limited in the present application.
2. Fusion common gateway interface (Fusion CGI): the CGI refers to a CGI that can process service requests of multiple network protocols, and the CGI provided in the embodiment of the present application belongs to a converged CGI. Fused CGI is, for example, ILInkFUSION BaseCGi.
3. Network protocol: the internet of things device refers to a network protocol between a client and a server, and specifically refers to a network application layer protocol, for example, the client and the server interact with each other by using an http protocol, and the internet of things device interacts with the server by using a queue telemetry transport (MQTT) protocol.
4. The main processing logic: the main processing logic may be referred to as a main logic, or may also be referred to as a CGI processing main flow, and refers to a main flow that is common to perform protocol processing on multiple types of network protocols, where the protocol processing includes two parts, i.e., protocol parsing and protocol encapsulation, and thus the main processing logic may specifically include a first main flow that is common to perform protocol parsing on multiple types of service requests. Each type of service request corresponds to a type of network protocol. The first main flow specifically includes a plurality of first sub-processing logics, in other words, the plurality of first sub-processing logics are common for resolving multiple types of service requests, and each first sub-processing logic can be understood as a sub-flow for resolving the service request.
The main processing logic may further include an execution order of the plurality of first sub-processing logic, and the execution order may be understood as a sequential order of executing the plurality of first sub-processing logic. In addition, the main processing logic may further include a second main flow commonly used when performing protocol encapsulation on the multiple types of service processing results. Each type of service processing result corresponds to a type of network protocol, or can be understood as a processing result of a service request of a type of network protocol. The second main flow specifically includes a plurality of second sub-processing logics, and each of the second sub-processing logics can be understood as one sub-flow in the business processing result. The second main flow may further comprise an execution order of the plurality of second sub-processing logic.
For convenience of distinction, the execution order of the plurality of first sub-processing logic is hereinafter referred to as a first execution order, and the execution order of the plurality of second sub-processing logic is hereinafter referred to as a second execution order.
5. And (3) realizing a strategy: for example, the second sub-processing logic is a compression sub-process, and the compression sub-process may adopt an LZ4 compression algorithm or a Zlib compression algorithm, that is, both the LZ4 compression algorithm and the Zlib compression algorithm are regarded as two implementation strategies of the second sub-processing logic.
For convenience of differentiation, in the embodiment of the present application, an implementation policy corresponding to a first sub-processing logic is referred to as a first implementation policy, and an implementation policy corresponding to a second sub-processing logic is referred to as a second implementation policy.
6. The execution mode comprises the following steps: for convenience of distinction, in the embodiment of the present application, an execution mode of a first main flow corresponding to a target service request is referred to as a first execution mode, an execution mode of a first main flow corresponding to a newly added service request is referred to as a second execution mode, and an execution mode of a second main flow is referred to as a third execution mode. The first execution mode may be understood as a first sub-processing logic belonging to a non-null implementation and a first sub-processing logic belonging to a null implementation in the plurality of first sub-processing logics when the target service request is parsed. The null-implemented sub-processing logic means that the input when the sub-processing logic is executed is the same as the output after the sub-processing logic is executed, that is, the sub-processing logic is executed, but the execution result, that is, the output of the sub-processing logic has no influence on the final main processing logic. The meaning of the second execution mode may refer to the meaning of the first execution mode. The third execution mode may be understood as a second sub-processing logic belonging to a non-null implementation and a second sub-processing logic belonging to a null implementation in the plurality of second sub-processing logics when a service processing result corresponding to the one class of service request is encapsulated.
7. Request context: a request context may be understood as holding the location of a resource, e.g. one or both of a variable or a function, required in the processing of a service request. A life cycle of a request context is a time period for processing a service request, for example, a flash request is an example of a request context, a flash request is created when a service request is received, and the flash request is destroyed after the service request processing is completed.
8. Class (c): in object-oriented programming, a construct of an object-oriented computer programming language is created which is a blueprint of objects describing the common properties and methods of the created objects. The class may include a base class, an abstract class, and a concrete class, and it should be noted that the base class, the abstract class, and the concrete class may have three independent concepts and may also have an attribution relationship with each other, for example, the concrete class is a derivative of the base class, and the concrete class is a derivative of the abstract class, which is not specifically limited in this application. The three types will be described below.
(1) Base class: also called parent class or super class, refers to the class that is inherited, and the base class defines the class of pure virtual member functions. The class inherited to the base class can also be called a derived class or a subclass, the derived class contains all members of the base class and also contains own specific members, the derived class and the derived class object can be directly used as if accessing the members in the base class, no operation character is added, but the derived class still cannot access the private members in the base class, and the derived class can belong to a specific class.
(2) Abstract class: are defined as objects that cannot, and cannot, be instantiated as concrete objects. Abstract classes are often defined at upper levels in the inheritance relationships of classes. In practical activities of programming, abstract classes exist similarly to interfaces, i.e., abstract classes are more heavily weighted towards specifying common methods and properties. A significant difference from interfaces is that abstract classes often provide an implementation of an interface when specifying a common method and property. The abstract interfaces mentioned in the embodiments of the present application are equivalent to abstract classes.
(3) The concrete classes are as follows: can be instantiated as concrete objects, can be abstract classes or derivatives of base classes.
In order to understand the above concept more clearly, the following examples are given for the purpose of illustrating the real world objects. For example, "fruit" may be counted as an abstract class, and "apple" and "banana" may be counted as derivatives of the abstract class. The difference is that "fruit" is a concept, which has no examples, but "apple" and "banana" have corresponding examples.
The first class and the fourth class mentioned below may be abstract classes defined in a base class, the second class may be a concrete class derived from the first class, the third class may be a concrete class inherited from the base class, and the fifth class may be a concrete class derived from the fourth class, and the first class and the fourth class may be the same or different.
In the embodiments of the present invention, "at least one" means one or more, "a plurality of" means two or more, "and" first "," second ", and" third "are merely distinguished without particular description, and do not limit the order of precedence, etc.
With the rapid development of internet technology and internet of things technology, the types of terminal devices are increasing, such as mobile phones or internet of things devices. Different kinds of terminals may access the server using different network protocols, such as HTTP, MQTT or other proprietary protocols. However, the service logic of a CGI is not changed due to the change of the network protocol, for example, a CGI used for implementing a voice Recognition (ASR) function, and the CGI uses the same processing logic to process service requests of different network protocols.
At present, in order to make a server compatible with a heterogeneous network protocol, a plurality of CGIs are generally externally provided for the same service logic, and each CGI is adapted to a different network protocol, so that the CGI reusability is poor, and a plurality of CGIs need to be developed, which results in complex code development.
For example, the CGI includes an interceptor, which is used for frequency interception, authentication, serialization, and the like of service requests. The service request comprises pre-processing and post-processing, the pre-processing of the service request refers to protocol analysis of the service request, and the post-processing refers to a process of protocol encapsulation of a service processing result. According to the current mode, a pre-processing function PreProcess and a post-processing function PostProcess need to be defined respectively, and correspondingly, an interceptor in the CGI needs to inherit respective subclasses of the pre-processing function and the post-processing function, so that code development of the CGI is complex.
In view of this, an embodiment of the present application provides a method for processing a service request, where the method decomposes protocol processing into specific sub-processing logics, constructs a pipeline architecture common to various service requests by using each sub-processing logic, which is equivalent to pre-configuring a main processing logic, determines an implementation policy of each first sub-processing logic directly according to the service request when analyzing the service request, and can analyze the service request based on the determined implementation policy, so that protocol processing can be performed on service requests of various network protocols in a compatible manner, and reusability of CGI is improved. And because the implementation strategy of each first sub-processing logic does not need to be configured in advance in the code of the CGI, only the main processing logic needs to be configured in advance, thereby simplifying the code development of the CGI.
Fig. 1A is a schematic diagram of a network architecture to which the service request processing method provided in the embodiment of the present application is applied. The network architecture diagram includes a client 111, an access stratum 112, and a business stratum 113.
The specific implementation of the client 111 can refer to the foregoing. The access stratum 112 refers to the portion of the network that is directly connected or accessed towards the user, and the purpose of the access stratum 112 is to allow the client 111 to connect to the network. The service layer 113 is used to parse the corresponding service request and execute the corresponding service logic.
Specifically, the client 111 generates a service request, the access layer 112 forwards the service request to the service layer 113, and the service layer 113 performs protocol parsing on the service request and executes corresponding service logic according to a parsing result, where a process of performing protocol parsing on the service request and executing the service logic will be described below.
As a possible embodiment, the service layer 113 may be deployed with a plurality of CGIs, where each CGI is used to independently implement functions of parsing a service request, executing service logic, and the like.
Referring to fig. 1B, a schematic view of a scenario to which the service request processing method provided in the embodiment of the present application is applied is shown. The scene diagram includes a plurality of terminal devices 110 and a server 120, and each terminal device 110 corresponds to one client 111. Each terminal 110 may communicate with a server 120 over a communication network. Note that fig. 1B illustrates two terminal devices 110 as an example, but the number of terminals 110 is not limited in practice.
The terminal device 110 is an electronic device used by a user, and the electronic device may be a computer device having a certain computing capability and running software or a website, such as a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart speaker, a smart watch, a game device, a smart television, or a smart wearable device.
The server 120 may be deployed with one or more CGIs, the meaning of which can be referred to above. The server 120 may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing basic cloud computing services such as a cloud service, a cloud database, cloud computing, a cloud function, cloud storage, a Network service, cloud communication, a middleware service, a domain name service, a security service, a Content Delivery Network (CDN), a big data and artificial intelligence platform, and the like.
Among them, cloud computing (cloud computing) can be understood as a computing mode that distributes computing tasks over a resource pool formed by a large number of computers, so that various application systems can acquire computing power, storage space, and information services as needed. The network that provides the resources is referred to as the "cloud". Resources in the "cloud" appear to the user as being infinitely expandable and available at any time, available on demand, expandable at any time, and paid for on-demand.
In one possible embodiment, the communication network may be a wired communication network or a wireless communication network, which is not limited in this application.
The interaction between the terminal device 110 and the server 120 is illustrated below.
For example, the 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 according to the access operation, where 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 packet data. The server 120 can also feed back the service loopback data to the client 111 through CGI. The process of the server 120 processing the service request will be described below.
In a possible application scenario, in order to reduce the communication delay, the servers 120 may be deployed in different regions, or in order to balance the load, different servers 120 may respectively serve the regions corresponding to the terminals. The plurality of servers 120 share data through a blockchain, and the plurality of servers 120 correspond to a data sharing system formed by the plurality of servers 120. For example, the terminal 110 is located at a site a and is communicatively connected to the server 120, and the terminal 110 is located at a site b and is communicatively connected to another server 120.
Each server 120 in the data sharing system has a node identifier corresponding to the server 120, and each server 120 in the data sharing system may store node identifiers of other servers 120 in the data sharing system, so that the generated block is broadcast to other servers 120 in the data sharing system according to the node identifiers of other servers 120. Each server 120 may maintain a node identifier list as shown in the following table, and store the name of the server 120 and the node identifier in the node identifier list. The node identifier may be an Internet Protocol (IP) address and any other information that can be used to identify the node.
In a possible application scenario, the service request processing method according to the embodiment of the present application may be widely applied to various specific application scenarios, for example, to various related application scenarios such as smart home, virtual reality, augmented reality, unmanned driving, smart marketing, smart office, smart wearing, smart transportation, smart city, unmanned aerial vehicle, robot, vehicle network, autonomous driving, and smart transportation, which is not limited in this respect.
The CGI in the embodiments of the present application can handle a plurality of network protocols, which is equivalent to providing a converged CGI. In the following, a framework of a CGI in the embodiment of the present application is described by referring to a framework schematic diagram of a fused CGI shown in fig. 1C, or fig. 1C may also be understood as a framework schematic diagram of a CGI in fig. 1A or fig. 1B, or may be understood as a framework schematic diagram of a server in fig. 1B.
Referring to fig. 1C, the schematic diagram of the framework includes main processing logic, a processor factory (processor factory), an implementation policy set, a basic authentication algorithm library, request context management, and request authority management, and the main functions of the components are described below.
1. Main processing logic.
The meaning of the main processing logic can be referred to above.
2. A processor plant.
The processor factory comprises a plurality of processors, wherein a processor is understood to be a virtual processor, rather than a physical processor, which implements a processing function, and the processor factory is configured to determine an execution mode corresponding to a current service request according to the current service request, and the meaning of the execution mode may refer to the foregoing. For example, the processor factory may determine a first execution mode corresponding to the target service request according to the request context of the target service request.
3. A policy set is implemented.
The implementation policy set may also be referred to as a sub-process policy set, and includes a plurality of implementation policies, and specifically may include a plurality of first implementation policies and a plurality of second implementation policies. The meaning of the first implementation strategy and the second implementation strategy can be referred to in the foregoing.
4. A base authentication algorithm library.
And the basic authentication algorithm library comprises a plurality of basic authentication algorithms, and each basic authentication algorithm can be used for authenticating the terminal equipment or the account of the target service request.
5. A request context management module.
The request context management module is configured to implement encapsulation on a request context corresponding to the service request, and the meaning of the request context may refer to the foregoing.
6. And a request authority management module.
The request authority management module is used for providing authority configuration management, for example, configuring whether various service requests require configuration login state and the like.
It should be noted that fig. 1C merely illustrates an architecture of a CGI in the embodiment of the present application, but the architecture of the CGI in the embodiment of the present application is not limited thereto.
As an example, any of the processor factory, implementation policy set, base authentication algorithm library, request context management, and request rights management of FIG. 1C are optional components.
As an example, in addition, fig. 1C may further include a functional module for implementing correspondence of other tangent plane logic, where the tangent plane logic refers to other processing besides the main processing logic, and refers to processing logic of a tangent plane program. For example, the CGI may also include a request masking module, an anti-spam module, and the like. The request shielding module is used for shielding illegal requests, and the anti-garbage module is used for clearing garbage requests and the like.
The service request processing method provided by the exemplary embodiment of the present application is described below with reference to the accompanying drawings in conjunction with the application scenarios described above, and it should be noted that the application scenarios described above are only shown for the convenience of understanding the spirit and principles of the present application, and the embodiments of the present application are not limited in this respect.
The service request processing method in this embodiment may be executed by the service layer in fig. 1A, the CGI deployed in the service layer in fig. 1A, the terminal device in fig. 1B, the server in fig. 1B, the CGI deployed in the server in fig. 1B, or the terminal device and the server in fig. 1B in cooperation, and the like, which is not limited in this application.
The service request processing method will be described below with reference to an example of the CGI implementation in the server 120 in fig. 1B. Fig. 2 is a schematic flow chart of the service request processing method. The service request processing method comprises the following steps.
And S21, acquiring a target network protocol corresponding to the target service request.
The client may generate the service request according to the access operation performed by the user, and the access operation may refer to the foregoing. The client sends the service request to the server, 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, and the target service request is used for requesting corresponding data from the CGI.
In order to facilitate subsequent processing of the target service request, the CGI may determine a target network protocol corresponding to the target service request after obtaining the target service request, and the meaning of the network protocol may refer to the foregoing. The CGI may determine the target network protocol by itself, or may obtain the target network protocol of the target service request from an intermediate device, where the intermediate device is, for example, a network forwarding device or a proxy device, and the application is not limited to this.
For example, the specific examples of the target service request are as follows:
GET/xxxHTTP/1.1/barvar1= value1& var2= with% 20percent%. The target service request is for requesting the execution environment of the server.
S22, determining respective first implementation strategies of a plurality of first sub-processing logics in the main processing logic based on the target network protocol, wherein the main processing logic comprises a first general flow for performing protocol analysis on a plurality of types of service requests.
The first main process comprises a plurality of first sub-processing logics, the main processing logic is pre-configured, and one service request of a plurality of service requests corresponds to one network protocol.
The CGI may pre-store the first main flow, but when analyzing service requests corresponding to different network protocols, implementation policies corresponding to each first sub-processing logic may be different, and therefore in this embodiment of the application, the CGI may determine, based on the target network protocol, a respective first implementation policy of each first sub-processing logic suitable for analyzing the target service request, so as to subsequently adopt the corresponding first implementation policy to execute the corresponding first sub-processing logic on the target service request. For example, the server may pre-store an implementation policy set, and the CGI invokes the implementation policy set based on the target network protocol, and determines, from the implementation policy set, a first implementation policy corresponding to each first sub-processing logic. Or, for example, the set of implementation policies may be pre-stored directly in the CGI.
With continued reference to the target service request exemplified in S21, the CGI may determine that the target network protocol of the target service request is the HTTP protocol.
And S23, executing a first main flow to the target service request based on the obtained plurality of first implementation strategies, and obtaining an analysis result of the target service request.
The CGI may adopt a plurality of first implementation policies, and respectively execute corresponding first sub-processing logics in the plurality of first sub-processing logics, and after the execution of the plurality of first sub-processing logics, that is, the first main process is executed, and an analysis result of the target service request may be correspondingly obtained.
And S24, carrying out corresponding processing on the target service request based on the analysis result.
The CGI may execute a corresponding service logic on the analysis result, which is equivalent to performing corresponding processing on the target service request.
With continuing reference to the target service request exemplified in S21, the CGI may analyze the target service request, and after performing corresponding processing on the target service request, may generate service loopback data, specifically, an operating environment parameter of the server, which specifically includes a name of the server and a port in the server for processing the target service request, where the operating environment parameter of the server is exemplified as follows:
SERVER_NAME="127.0.0.1"
SERVER_PORT="80"。
wherein, "SERVER _ NAME" represents the NAME of the SERVER, and "SERVER _ PORT" represents the PORT of the SERVER.
In the embodiment shown in fig. 2, a common protocol parsing process for multiple types of service requests is configured as a first main flow, the first main flow is decomposed into multiple first sub-processing logics, and when a certain service request is parsed, specific implementation of the first sub-processing logics can be determined, so that the protocol parsing process for the service request is completed according to respective implementation strategies of the multiple first sub-processing logics, and thus, the CGI can perform protocol parsing on service requests corresponding to multiple network protocols, and the reusability of the CGI is improved. And when the CGI is developed, complex codes do not need to be configured, so that the code development workload of the CGI and the difficulty of developing the CGI are reduced. Moreover, when a protocol processing function for a certain network protocol needs to be added, implementation strategies of sub-processing logic involved in the network protocol processing process can be added, so that the protocol processing process for the added network protocol can be realized, and the expansibility of the CGI is improved.
On the basis of the embodiment shown in fig. 2, the following describes an example of possible embodiments of the individual steps in fig. 2. In a possible embodiment, the execution manner of S21 in fig. 2 may include any one of the following manners.
The first mode for determining the target network protocol is as follows:
the CGI determines a target network protocol of the target service request according to a packet header in the target service request.
The target service request generally includes a header and a body, and different network protocols have different formats corresponding to the body in the service request. The server or the CGI may have a first correspondence between each network protocol and a format of a header corresponding to the network protocol. After receiving the target service request, the CGI may invoke the first mapping relationship, and determine, from the first mapping relationship, a network protocol corresponding to the body of the target service request.
For example, the format of the packet header corresponding to the service request using the HTTP protocol is: GET/xxxHTTP/1.1, CGI determines the format of the header of the target service request to be in accordance with the format of the corresponding header of the HTTP protocol, so that the target network protocol of the target service request can be determined to be the HTTP protocol.
The second mode for determining the target network protocol is as follows:
and acquiring the target network protocol of the target service request from the intermediate equipment.
The client forwards the target service request to the CGI through the intermediate device, and the intermediate device can determine a target network protocol of the target service request when receiving the target service request, and send the target service request and the target network protocol to the CGI. The manner in which the intermediate device determines the target network protocol may be determined with reference to the CGI.
To facilitate a clearer understanding of the plurality of first sub-processing logic, the plurality of first sub-processing logic is described as an example below in conjunction with the example diagram of the main processing logic shown in fig. 3A.
Referring to fig. 3A, the main processing logic includes a first main flow corresponding to the direction of the arrow where the request entry is located, and a second main flow corresponding to the direction of the arrow where the data exit is located.
As an embodiment, the first main flow includes a first uniform packet transformation sub-flow (corresponding to the constructed packet in fig. 3), a session check sub-flow (corresponding to the session check in fig. 3A), a decompression sub-flow (corresponding to the decompression in fig. 3A), and a deserialization sub-flow (corresponding to the deserialization in fig. 3A). Wherein, the deserialization sub-process can be also called as deserialization sub-process.
As an embodiment, the first main flow and the second main flow are opposite flows, it is understood that there is a corresponding and opposite second sub-processing logic for each first sub-processing logic.
Specifically, taking the first main flow as shown in fig. 3A as an example, the second main flow includes a serialization sub-flow (corresponding to serialization in fig. 3A), a compression sub-flow (corresponding to compression in fig. 3A), a session signature sub-flow (corresponding to session signature in fig. 3A), and a second unified body conversion sub-flow (corresponding to protocol packaging in fig. 3A).
Further, the first main flow and the second main flow may actually be opposite flows, and in order to simplify code development of the CGI, in this application embodiment, a set of opposite sub-processing logics involved in the first main flow and the second main flow may be defined as an abstraction layer, where the abstraction layer may be understood as an abstraction interface or an abstraction class, in other words, the abstraction layer is not the same concept as what is called in the network in fig. 1A. In the embodiment of the present application, a set of opposite sub-processing logics is defined as an abstraction layer, so that the set of opposite sub-processing logics can directly inherit the abstraction layer in the subsequent execution process, so as to implement the corresponding sub-processing logic.
In particular, with continued reference to FIG. 3A, the main processing logic includes in particular an access protocol abstraction layer, a session abstraction layer, a compression abstraction layer, and a serialization abstraction layer. 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 flow and the second main flow.
The access protocol abstraction layer is used for realizing a first uniform inclusion conversion sub-process and a second uniform inclusion conversion sub-process; the session abstraction layer is used for realizing a session check sub-process and a session signature sub-process; the compression abstract layer is used for realizing the decompression sub-process and the compression sub-process; the serialization abstraction layer implements the serialization sub-process and the deserialization sub-process.
Further, the main processing logic further includes a service abstraction layer, and the service abstraction layer may be encapsulated with common service processing logic, and also corresponds to an abstract class or an abstract interface. When the service logic is executed subsequently, the service abstraction layer can be inherited to realize the corresponding service logic.
After determining the target network protocol, the CGI may perform S22, that is, determine a first implementation policy for each of the plurality of first sub-processing logics in the main processing logic based on the target network protocol. The following describes an exemplary manner of determining the first implementation policy in S22 by taking the determination of the first implementation policy corresponding to one of the first sub-processing logics as an example.
The first implementation strategy determination mode is as follows:
the CGI may determine, based on the target network protocol, the first implementation policy corresponding to the first sub-processing logic from a second correspondence, where the second correspondence includes an association between the first sub-processing logic and the first sub-processing logic between the first implementation policies corresponding to each network protocol.
Specifically, the server or the CGI may pre-store an implementation policy set, where each implementation policy in the implementation policy set is associated with a first sub-processing logic corresponding to a network protocol that can be processed, and the implementation policy set may be regarded as an example of the second correspondence. After obtaining the target network protocol, the CGI may determine, according to the target network protocol, a first implementation policy corresponding to the target network protocol in the sub-processing logic from the implementation policy set.
For example, the first sub-processing logic includes a deserialization sub-process and a decompression sub-process, and the second correspondence is specifically shown in table 1 below.
TABLE 1 second correspondence
HTTP protocol MQTT protocol
Deserialization sub-process JSON ProtoBuf
Decompression sub-process LZ4 Zlib or Zlib
For example, referring to table 1, the first implementation policy corresponding to the deserialization sub-process under the HTTP protocol is JSON, and the first implementation policy under the MQTT protocol is ProtoBuf; the first implementation strategy of the decompression sub-process in the HTTP protocol is LZ4, and the first implementation strategy corresponding to the MQTT protocol is Zlib. If the CGI determines that a target network protocol corresponding to the target service request is an HTTP protocol, a first implementation strategy of the deserialization sub-process is determined to be JSON; the first implementation strategy for the decompression sub-flow is LZ4.
Further, in the second correspondence, there may be a plurality of implementation policies corresponding to a certain network protocol by the first sub-processing logic, and for convenience of description, the plurality of implementation policies are referred to as a plurality of candidate implementation policies, which relates to that the CGI needs to screen out the first implementation policy from the plurality of candidate implementation policies, and in this embodiment, the CGI may randomly select one implementation policy from the plurality of candidate implementation policies as the first implementation policy of the first sub-processing logic.
Or the CGI may determine, according to the service information of the target service request, a first implementation policy corresponding to the first sub-processing logic from a plurality of candidate implementation policies. The service information of the target service request refers to information related to a service corresponding to the target service request, where the service information includes, for example, a service type or a service scenario of the target service request, the service type includes a public service and a private service, and the service scenario includes a social service and a content service.
In the first implementation policy determining mode, the CGI may directly screen out the corresponding first implementation policy from the second correspondence according to the target network protocol, and the mode of determining the first implementation policy is simple and fast.
The first implementation strategy determination mode two:
the CGI may determine, based on the target network protocol and the target service request, a first implementation policy corresponding to the first sub-processing logic from a third corresponding relationship, where the third corresponding relationship includes an association relationship between the first sub-processing logic and the first implementation policy corresponding to the first sub-processing logic under each network protocol and corresponding service information.
The CGI may determine a first implementation policy corresponding to the first sub-processing logic according to the target network protocol and the service information in the target service request. For example, each implementation policy set in the implementation policy set is associated with corresponding service information and corresponding network protocol, and in this case, the implementation policy set may be understood as an example of the third correspondence relationship, where the meaning of the service information may be referred to in the foregoing.
For example, the service information indicates a first implementation policy corresponding to a certain first sub-processing logic, so the CGI may combine the indication information and the target network protocol to determine the first implementation policy corresponding to the first sub-processing logic.
In the second implementation policy determining method, the CGI may determine the first implementation policy depending on the service information in addition to the target network protocol, so that the determined first implementation policy may satisfy the service requirement.
As an embodiment, the CGI may determine, in combination with the first implementation policy determining means and the second implementation policy determining means, a first implementation policy of each of the plurality of first sub-processing logics.
For example, the CGI determines a first implementation policy corresponding to a part of the first sub-processing logic by using the first implementation policy determining means, and determines a first implementation policy of another part of the first sub-processing logic by using the second implementation policy determining means.
It should be noted that, the first implementation policy determining method and the first implementation policy determining method are examples of determining implementation policy determining methods, and the method of determining the first implementation policy is not limited.
To more clearly illustrate the first implementation policy, taking the multiple first sub-processing logics as the respective first sub-processing logics shown in fig. 3A as an example, the multiple first implementation policies correspondingly include: a first packet conversion method corresponding to the unified packet conversion sub-process, a session check method corresponding to the session check sub-process, a decompression method corresponding to the decompression sub-process, and a deserialization method corresponding to the deserialization sub-process.
The first packet conversion method may include a packet conversion method corresponding to the MQTT protocol shown in fig. 3A, a packet conversion method corresponding to the COAP protocol, a packet conversion method corresponding to the MMPkg protocol, a packet conversion method corresponding to the WPkg protocol, and a packet conversion method corresponding to other protocols.
The session verification method may include a session information verification method, a token (token) information verification method, and another verification method corresponding to the other verification information shown in fig. 3A, where the session information verification method refers to performing verification by using session information, and the token information verification method refers to performing verification by using token information.
The decompression method may include a decompression method corresponding to LZ4, a decompression method corresponding to Zlib, and a decompression method corresponding to other compression algorithms shown in fig. 3A.
The deserializing method may include one deserializing method corresponding to ProtoBuf, one deserializing method corresponding to JSON, and other deserializing methods corresponding to the serialization algorithm shown in fig. 3A.
In one possible embodiment, the CGI may determine a first execution mode corresponding to the target service request.
Specifically, the first main flow is a flow common for parsing multiple types of service requests, but actually, some sub-flows in the first main flow may not be necessary for parsing some service requests, so in this embodiment of the present application, the CGI may determine the first execution mode corresponding to the target service request, that is, determine at least one first sub-processing logic belonging to a non-null implementation and at least one first sub-processing logic belonging to a null implementation in the first main flow. The meaning of the null implementation can refer to the foregoing discussion and is not described in detail here.
The CGI may determine, from the execution mode set, a first execution mode corresponding to the target service request, for example, the CGI may determine, from the execution mode set, the first execution mode corresponding to the target service request according to a request context corresponding to the target service request.
It should be noted that, when processing some service requests, the corresponding first execution mode may be that all the first sub-processing logic is implemented in a non-null manner, in other words, when parsing the service request, all the first sub-processing logic in the first main flow needs to be implemented in a non-null manner.
Further, when the CGI determines the first execution mode, the CGI may determine, in combination with the first execution mode and the target network protocol, a first implementation policy corresponding to each of the plurality of first sub-processing logics.
Specifically, if a certain first sub-processing logic is a null implementation, the first implementation policy corresponding to the first sub-processing logic is used for implementing the first sub-processing logic in a null manner, in other words, the null implementation belongs to an implementation policy.
In the embodiment of the application, an execution mode is introduced, a first sub-processing logic which needs to be realized in an idle mode is determined according to the execution mode, and the CGI does not need to skip a corresponding first sub-processing logic in a first main flow according to a service request, so that the CGI can be executed strictly according to the first main flow, and the code operation is smoother. And, the CGI may determine in advance which sub-processing logic belongs to the null implementation in order to select the adapted first implementation policy.
In another possible embodiment, the CGI may determine whether a null implementation is required for the first sub-processing logic when the first sub-processing logic is executed.
Specifically, the main processing logic further defines a judgment logic corresponding to each sub-processing logic, and each judgment logic is used for judging whether the sub-processing logic needs to be implemented in a null mode.
In the embodiment of the present application, the CGI does not need to determine an execution mode corresponding to the target service request in advance, but determines whether to implement the corresponding first sub-processing logic empty according to an actual situation, so that an execution policy set does not need to be stored, and a data storage amount of the CGI or the server is reduced.
After determining the first implementation policy of each of the plurality of first sub-processing logics, the CGI may perform S23, and the manner in which the first main flow is performed in S23 is described as an example below.
The CGI performs a first main process, which is equivalent to executing a plurality of first sub-processing logics. The manner in which the plurality of first sub-processing logic is executed is explained below.
For example, the CGI may employ a first implementation policy of a first sub-processing logic, which is executed. By analogy, the CGI may execute a plurality of first sub-processing logic.
Further, the first main flow may include a first execution order of the plurality of first sub-processing logic in addition to the plurality of first sub-processing logic. The CGI may sequentially execute the plurality of first sub-processing logics in the execution order when executing the first main flow.
Of course, there may be no execution order of the plurality of first sub-processing logics, i.e. the plurality of first sub-processing logics may not have a strict execution order, and the CGI may execute the plurality of first sub-processing logics in an arbitrary order.
With continued reference to fig. 3A, the main processing logic may be encapsulated as a base class, or it may be understood that the main processing logic is represented by the base class, and a first sub processing logic corresponds to a first class in the base class, for example, an abstraction layer in fig. 3A, and when a first implementation policy of the first sub processing logic is determined, it is equivalent to construct an instance of a second class inherited from the first class, so that the CGI may call a method of the instance through the base class to execute the first sub processing logic.
To more clearly illustrate the relationship between the base class, the first class and the second class, the following description is provided with reference to the schematic diagrams of the base class, the first class and the second class shown in fig. 3B.
Referring to fig. 3B, the main processing logic includes a first main flow, the first main flow includes a decompression sub-flow shown in fig. 3B, the decompression sub-flow is specifically implemented as a first implementation policy, correspondingly, the main processing logic corresponds to a base class, the base class includes a first class, a second class inherits from the first class, the second class corresponds to the decompression sub-flow, and an instance corresponding to the second class corresponds to the first implementation policy of the decompression sub-flow. In fig. 3B, the dashed line indicates that there is a correspondence between the two concepts, for example, the dashed line between the main processing logic and the base class indicates that the base class indicates the main processing logic, or it can be understood that the base class corresponds to the main processing logic.
In order to more clearly describe the method for executing the first main flow, the following takes as an example that the plurality of first sub-processing logics include a first uniform packet body conversion sub-flow, a decryption sub-flow, a decompression sub-flow and a deserialization sub-flow, and the plurality of first implementation policies include a first packet body conversion method corresponding to the uniform packet body conversion sub-flow, a session check method corresponding to the session check sub-flow, a decompression method corresponding to the decompression sub-flow and a deserialization method corresponding to the deserialization sub-flow, and the example is described with reference to the flowchart of the method for executing the first main flow shown in fig. 4.
S41, according to the first packet body conversion method, a first unified packet body conversion sub-process is executed on the target network protocol and the target service request, and a unified packet body which accords with a preset rule is obtained.
The target service request may be understood as an original input of the client, and the original input may not belong to a structure that can be understood by the program, so in S41, the CGI may convert the original input target service request into a packet body that conforms to a preset rule, for example, the structure that can be understood by the program, or a format that conforms to one or more of the set formats. The preset rule may be set according to a requirement, and the preset rule is not limited in this application.
As an embodiment, the CGI may construct a packet Processor (Pack Processor) according to the target service request through the access protocol abstraction layer in fig. 3A, where the packet Processor may be understood as a second class inherited from the access protocol abstraction layer in fig. 3A, and determine that the first packet conversion method is equivalent to constructing an instance of the second class, so that the target service request may be unpacked and packaged by calling the method of the instance through the base class, thereby obtaining a unified packet meeting the preset rule. The unpacking may be a structure body that converts the target service request into a program, and the packing may be a bag body that is formed by the structure body and a target network protocol and conforms to a preset rule.
In a possible embodiment, if constructing the unified body session succeeds, the CGI may execute a subsequent first sub-processing logic, and if constructing the unified body session fails, it indicates that the target service request may be illegal or the CGI may not be able to process the target service request, so the CGI may stop performing the subsequent first sub-processing logic on the unified body, and feed back exception prompt information to the client, where the exception prompt information is used to prompt that the target service request is abnormal, and further, the exception prompt information may include the first sub-processing logic that processes the failure, for example, the exception prompt information is "constructing the unified body, processing the service request fails", so that the client may conveniently investigate an exception cause.
And S42, executing a session check sub-process on the unified inclusion based on a session check method.
In order to reduce illegal service requests, in this embodiment of the present application, the CGI may use a session check method to perform session check on the unified inclusion, which is equivalent to performing validity check on a session corresponding to a target service request corresponding to the unified inclusion, for example, whether the session sending the target service request is legal or not, or whether the session sends the target service request within a session validity period. The session check method may, for example, perform session check on the unified packet body by using session information corresponding to the target service request, where this process may also be referred to as session information check, or perform session check by using token (token) information, and this process may also be referred to as token information check.
As an embodiment, the CGI may form a Session Processor (Session Processor) through the Session abstraction layer in fig. 3A, where the Session Processor may be understood as a second class inherited from the Session abstraction layer in fig. 3A, determining that the Session check method is equivalent to constructing an instance of the Session Processor, and calling the method of the instance through the base class is equivalent to implementing a process of performing Session check on the unified body.
When the session check is performed on the unified enclosure, it relates to how to obtain check information for performing the session check, where the check information includes, for example, session information or token information, and the check information may be carried in the unified enclosure, and the CGI may obtain the check information from the unified enclosure, or the CGI may obtain the check information from the client, for example, the client sends the target service request and the check information to the CGI at the same time, and the CGI obtains the check information together with the target service request.
In a possible embodiment, if the session check of the unified body is successful, the CGI may execute a subsequent first sub-processing logic, and if the session check of the unified body is failed, it indicates that the target service request may be illegal, so the CGI may stop performing the subsequent first sub-processing logic on the unified body, and feed back the exception notification information to the client, where the meaning of the exception notification information may refer to the content discussed above and is not described here again.
As one example, the plurality of first sub-processing logic may further include a decryption sub-flow.
For example, the decryption sub-flow may follow the session check sub-flow.
Specifically, if the CGI determines that the session check of the unified packet body is successful, the CGI may execute a decryption sub-process on the unified packet body, so as to obtain information in the unified packet body, where the information in the unified packet body includes information of the packet body in the target service request and the target network protocol. For example, the CGI may determine, according to a target network protocol, a first implementation policy corresponding to the decryption sub-process, where the first implementation policy of the decryption sub-process may be understood as a decryption method, and the CGI may decrypt the unified body using the decryption method.
As a possible embodiment, the decryption sub-process may correspond to a decryption abstraction layer, the decryption abstraction layer may be understood as an abstract interface or an abstract class, the CGI may form a decryption processor through the decryption abstraction layer, the decryption processor is equivalent to a second class inherited from the decryption layer, a first implementation policy corresponding to the decryption sub-process is determined, which is equivalent to constructing an instance of the decryption processor, and the CGI may call a method of the instance through a base class, which is equivalent to decrypting a unified packet.
In some cases, if the target service request is not generated by encryption, it can be understood that data is transparently transmitted between the client and the server, and the CGI does not need to perform a decryption sub-process on the unified packet subsequently.
And S43, based on the decompression method, executing a decompression sub-process on a result obtained after the session check sub-process is executed.
In order to obtain specific information in the compressed packet body, in the embodiment of the present application, the CGI may employ a corresponding decompression method, and may decompress the compressed packet body, so as to obtain the information in the unified packet body.
For example, the CGI may construct a compression Processor (compression Processor) according to the unified body through the compression abstraction layer in fig. 3A, where the compression Processor is equivalent to inheriting a second class of the compression abstraction layer, determine a compression method corresponding to the compression Processor, which is equivalent to constructing an instance of the compression Processor, and call the method of the instance through the base class, which is equivalent to decompressing the compression body.
And S44, based on the deserialization method, deserialization processing sub-processes are executed on the result of the execution of the decompression sub-processes.
In order to facilitate subsequent processing of information in the target service request, in S44, the CGI may deserialize a result after executing the sub-flow decompression, which is equivalent to converting the result after decompressing the sub-flow into an object in a program, so that the CGI may directly execute a corresponding service logic on the converted object subsequently.
As an embodiment, the CGI may construct a serialization Processor (serialization Processor) through the serialization abstraction layer in fig. 3A according to the result after the decompression sub-process is executed in step 1.3, where the serialization Processor is equivalent to a second class inherited from the serialization abstraction layer, determine a deserialization method corresponding to the serialization Processor, and is equivalent to construct an instance of the serialization Processor, and invoking the method of the instance through the base class is equivalent to deserializing the result after the decompression sub-process.
The embodiment shown in fig. 4 provides a manner for executing the first main flow, in the embodiment shown in fig. 4, the CGI may adopt the steps shown in fig. 4 to execute the first main flow, and implement a protocol parsing process for a target service request.
It should be noted that fig. 4 is an exemplary description of a manner of executing the first main flow according to the embodiment of the present application, but actually does not limit a plurality of first sub-processing logics that the first main flow may include, and a method of executing the first main flow.
After the CGI executes the foregoing S21 to S23, that is, the protocol parsing process for the target service request is completed, correspondingly, an parsing result corresponding to the target service request may be obtained, and the parsing result may be understood as a result obtained by performing protocol parsing on the target service request.
The CGI may perform S24 based on the parsing result. Next, an example of the execution manner of S24 will be described.
The first mode is as follows:
the CGI may directly execute a corresponding service logic according to the analysis result, thereby obtaining a service processing result.
Specifically, the CGI converts the target service request into an object that can be understood by the program through the steps of S21 to S23 in the foregoing text, so that the CGI can execute a corresponding service logic on the analysis result by using the corresponding program to obtain a service processing result. The service logic may be set according to the requirement of the target service request, which is not limited in this application.
In the first way, the part of the CGI that executes the service logic is independent from the part that analyzes the target service request, so as to reduce the influence between the two parts.
The second mode is as follows:
and executing corresponding business logic through a third class inherited to the base class, thereby obtaining a business processing result.
Specifically, the third class may also be referred to as a service class, and may be a concrete class inherited to the base class, and the base class may refer to the foregoing, for example, a concrete class inherited to the service abstraction layer in fig. 3A. Through the third class, corresponding service logic can be executed, so that a service processing result is obtained.
In the embodiment of the application, since the base class is universal for the multi-class service requests, no matter which class of service requests is targeted, the third class can inherit the base class, execute the service logic for the multi-class service requests, and need not inherit respective base classes of the multi-class service requests, thereby simplifying the development workload of the service codes and reducing the development difficulty of the service codes. And, the base class can directly obtain the service processing result.
The third mode is as follows:
and executing corresponding service logic through the fourth class to obtain a service processing result, and registering a callback function to the base class.
The fourth class can be understood as a separate concrete class, i.e. without inheritance to the base class. In the embodiment of the application, the service class does not need to inherit the base class, so that the development of the service code is simplified, the service class runs independently, the service logic is executed, and a callback function, such as a DoProcesses, is registered in the base class. And the base class can directly obtain the service processing result through the callback function.
After obtaining the service processing result, the CGI may use the service processing result as service loopback data, where an encapsulation manner of the service loopback data conforms to a specified encapsulation manner of the target network protocol, and the encapsulation manner may be understood as an encapsulation format of data specified by the protocol. Alternatively, the CGI may also perform protocol encapsulation on the service processing result, thereby obtaining service loopback data. After obtaining the service loopback data, the CGI may feed back the service loopback data to the client.
The following description is an example of how the CGI performs protocol encapsulation on a service processing result.
The protocol encapsulation mode is as follows:
the server or the CGI may pre-store protocol encapsulation modes corresponding to various network protocols. After the CGI obtains the service processing result, it may invoke a protocol encapsulation method corresponding to the target network protocol, and encapsulate the service processing result by using the protocol encapsulation method corresponding to the target network protocol, thereby obtaining the service loopback data.
And a second protocol encapsulation mode:
the CGI may execute a second main flow to the service processing result based on a second implementation policy corresponding to each of the plurality of second sub-processing logics, and obtain service loopback data, where the meaning of the second main flow may refer to the foregoing.
The CGI may use a second main flow encapsulated by a pre-stored general protocol, and when encapsulating the service processing result, determine a second implementation policy of each second sub-processing logic in the second main flow, and then use the obtained multiple second implementation policies to execute the second main flow on the service processing result, thereby obtaining the service packet data.
The way in which the CGI determines the second implementation policy may refer to the way in which the first implementation policy is determined.
Or, since the first main flow and the second main flow are actually opposite processing procedures, in the embodiment of the present application, the CGI may also determine, according to a first implementation policy of one first sub-processing logic, a second implementation policy of a second sub-processing logic corresponding to the first sub-processing logic. For example, the first sub-processing logic is a decompression sub-flow, the second sub-processing logic corresponding to the first sub-processing logic is a compression sub-flow, the CGI determines that the first implementation policy of the decompression sub-flow is a decompression method corresponding to LZ4, and the corresponding CGI may determine that the first implementation policy of the compression sub-flow is an LZ4 compression method.
In this embodiment of the present application, the CGI may determine a second implementation policy corresponding to the first implementation policy, may simplify a determination manner of the second implementation policy, and perform protocol encapsulation on a service processing result by using a method corresponding to the target service request, so that the client may smoothly analyze the service loopback data by using a corresponding manner for generating the target service request.
As an embodiment, the sequence of determining, by the CGI, the second implementation policy and the first implementation policy may be arbitrary, which is not limited in this application, for example, the CGI may determine the first implementation policy first and then determine the second implementation policy, or the CGI may determine the first implementation policy and the second implementation policy at the same time.
As an embodiment, the base class includes a plurality of fourth classes, each fourth class corresponds to a second sub-processing logic, each second sub-processing logic is represented by a fifth class inherited from the corresponding fourth class, and when the second main flow is executed, the method specifically includes:
constructing respective instances of a plurality of fifth classes, wherein each fifth class in the plurality of fifth classes corresponds to one of the plurality of second sub-processing logics;
and calling the method of the corresponding instance of each first sub-processing logic in the plurality of second sub-processing logics through the base class, and executing the corresponding second sub-processing logic, thereby completing the execution process of the second main flow.
Further, the fourth class may be the same class as the first class in the foregoing, which may further simplify code development.
In a possible embodiment, the CGI may also determine a third execution mode of the second main flow.
In particular, the meaning of the execution mode can be referred to the above. The CGI may determine a third execution mode of the second main flow based on the target network protocol, or the CGI determines a 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 belonging to the null implementation in the first execution mode also belongs to the null implementation in the third execution mode, and the second sub-processing logic corresponding to the first sub-processing logic belonging to the non-null implementation in the first execution mode also belongs to the non-null implementation in the third execution mode.
As an embodiment, the sequence of determining the first execution mode of the first main flow and determining the third execution mode of the second main flow by the CGI may be arbitrary, for example, the CGI may determine the first execution mode first and then determine the third execution mode.
As an embodiment, while determining the first execution mode, the first sub-processing logic corresponding to the first main flow that belongs to the null implementation is already determined, so the CGI may determine, without determining the third execution mode, to refer to the first execution mode directly, determine the second sub-processing logic corresponding to the first sub-processing logic that belongs to the null implementation as the null implementation, and determine the second sub-processing logic corresponding to the first sub-processing logic that is not the null implementation as the non-null implementation.
With continued reference to fig. 3A, as one embodiment, the plurality of second sub-processing logic includes a serialization sub-flow, a compression sub-flow, a session signature sub-flow, and a second unified body translation sub-flow. 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 packet conversion method corresponding to the second unified packet conversion sub-process.
It should be noted that, the first unified packet body conversion sub-process in the foregoing refers to converting a target service request into a unified packet body meeting a preset rule, and the second unified packet body conversion sub-process refers to encapsulating a service processing result into service loopback data meeting a target network protocol.
In order to more clearly describe the execution process of the second main flow, the following description takes the multiple second sub-processing logics including a serialization sub-flow, a compression sub-flow, a session signature sub-flow, and a second unified body conversion sub-flow, and the multiple second implementation policies including a serialization method corresponding to the serialization sub-flow, a compression method corresponding to the compression sub-flow, a session signature method corresponding to the session signature sub-flow, and a second packet conversion method corresponding to the second unified body conversion sub-flow as an example, and the example is described with reference to the method flowchart for executing the second main flow shown in fig. 5.
And S51, based on the serialization method, executing a serialization sub-process on the service processing result.
Serialization is the reverse process of deserialization as described above. Serialization is the process in computer science of data processing of converting a data structure or object state into an available format for subsequent restoration of the original state in the same or another computer environment.
As an embodiment, the CGI constructs a serialization handler through the serialization abstraction layer in fig. 3A, which may be understood as a first class, or a fourth class, and the serialization handler may be understood as a second class, or a fifth class, determines a serialization method, which is equivalent to constructing another instance of the serialization handler, and calls the method of the instance through the base class, which is equivalent to executing the serialization sub-process on the service processing result.
S52, based on the compression method, executing the compression sub-process on the result after the serialization sub-process is executed.
The compression sub-flow is the reverse process of the decompression sub-flow in the foregoing.
As an embodiment, the CGI may pass through the compression abstraction layer in fig. 3A, where the compression abstraction layer may be understood as a first class, or a fourth class, to form a compression handler, where the compression handler may be understood as a second class, or a fifth class, to determine a compression method, which is equivalent to constructing another instance of the compression handler, and invoking the method of the instance by the base class is equivalent to executing the compression sub-flow.
And S53, executing the session signature sub-process on the result of executing the compression sub-process based on the session signature method.
The session signing sub-flow is the reverse process of the session verifier sub-flow described above.
As an embodiment, the CGI may pass through the Session abstraction layer in fig. 3A, which may be understood as a first class, or a fourth class, to construct a Session handler (Session Processor), which may be understood as a second class, or a fifth class, to determine a Session check method, which is equivalent to constructing another instance of the Session handler, and to invoke the method of this instance through the base class, which is equivalent to executing the Session signature sub-process.
For one embodiment, the plurality of second sub-processing logic may further comprise an encryption sub-flow.
The encryption sub-flow is the reverse process of the decryption sub-flow in the foregoing.
Specifically, after performing session signature on the result obtained after executing the compressed sub-flow, the CGI may determine, according to the target network protocol, a second implementation policy corresponding to the encrypted sub-flow, where the second implementation policy may be specifically understood as an encryption method, and the result obtained after executing the session signature sub-flow is encrypted by using the encryption method.
As an embodiment, the encryption sub-process may correspond to a decryption abstraction layer in the foregoing, the meaning of the decryption abstraction layer may refer to the foregoing, the CGI may form a decryption processor through the decryption abstraction layer, the meaning of the decryption processor may refer to the foregoing, the second implementation policy corresponding to the encryption sub-process is determined, which is equivalent to forming another instance of the decryption processor, and the CGI may call the method of the instance through the base class, which is equivalent to encrypting a result after executing the session signature sub-process.
And S54, based on the second unified bag body conversion method, executing a second unified bag body conversion sub-process on the result after the session signature sub-process is executed.
The second unified inclusion transition sub-flow is the reverse process of the first unified inclusion transition sub-flow, and the meaning of the second unified inclusion transition sub-flow can refer to the above.
As an embodiment, the CGI may pass through an access protocol abstraction layer in fig. 3A, where the access protocol abstraction layer may be understood as a first class, or a fourth class, to construct a packet Processor (Pack Processor), and the packet Processor may be understood as a second class, or a fifth class, and it is determined that the second unified body conversion method is equivalent to construct another instance of the packet Processor, and the method of calling the instance through the base class is equivalent to executing the second unified body conversion sub-process, so as to service the packet data.
In the embodiment shown in fig. 5, the main processing logic further defines a second main flow, and the plurality of first sub-processing logics in the first main flow and the plurality of second sub-processing logics in the second main flow can be implemented by the abstraction layers defined in fig. 3A, so that the protocol processing performed by the CGI on the plurality of types of network protocols can implement the protocol analysis and protocol encapsulation processes by using a unified flow, which not only improves the reusability of the CGI, but also simplifies code development of the CGI, and subsequent service logics can inherit a base class, thereby simplifying development of service codes corresponding to the service logics.
With the increasing variety of network protocols, it may be necessary to expand the network protocol to which the CGI is adapted, that is, to add and adapt a protocol processing function of a new class of network protocol to the CGI.
Similarly, the CGI may also write the fourth execution mode of the second main flow corresponding to the newly added network protocol into the execution mode set. The fourth execution mode is the execution mode of the second main flow corresponding to the newly added service request.
Specifically, taking the architecture of CGI as the one shown in fig. 1C as an example, the CGI may configure one or both of the second execution mode and the fourth execution mode to the processor factory.
When a new type of network protocol is added, the sub-processing logic may have a new implementation policy, or a sub-processing logic may have a new implementation policy. For example, the CGI may write an additional first implementation policy set corresponding to a first sub-processing logic, and the CGI may also write an additional second implementation policy set corresponding to a second sub-processing logic.
Specifically, taking the architecture of the CGI as the architecture shown in fig. 1C as an example, the CGI may write one or both of the newly added implementation policy and the second implementation policy into the implementation policy set in fig. 1C.
In the embodiment of the present application, when the CGI needs to expand a protocol processing function corresponding to a newly added network protocol, an execution mode corresponding to the network protocol may be configured or a policy may be implemented correspondingly, a manner of expanding the CGI function is simple and quick, a primary processing logic does not need to be modified, and code modification is less.
To more clearly describe the service request processing method in the embodiment of the present application, taking the example that the client and the server in fig. 1B cooperatively execute the service request processing method, an example is described below with reference to an interaction diagram between the client and the server shown in fig. 6. Referring to fig. 6, the interaction process specifically includes the following steps.
S61, the client sends the target service request to the server.
The manner in which the client generates the target service request and the meaning of the target service request can refer to the foregoing.
S62, the server obtains a target network protocol corresponding to the target service request.
The method of determining the target network protocol may refer to the foregoing discussion.
S63, the server determines a first implementation strategy of each of a plurality of first sub-processing logics in the main processing logic based on the target network protocol.
The manner in which the first implementation policy is determined, the meaning of the main processing logic, and the meaning of the first sub-processing logic may be referred to above.
And S64, the server executes a first main flow to the target service request based on the obtained plurality of first implementation strategies to obtain an analysis result of the target service request.
The manner of executing the first main flow and the meaning of the analysis result can be referred to above.
And S65, based on the analysis result, correspondingly processing the target service request to obtain service packet data.
The meaning of the service packet data and the manner of processing the target service request accordingly can be referred to above.
And S66, the server feeds back the service return packet data to the client.
After the client obtains the service loopback data, the service loopback data can be analyzed, and then corresponding data fed back by the server is displayed.
For example, referring to fig. 7, which is an exemplary diagram of interface changes of a client during a service request processing process, a user inputs a search keyword of "what is a healthy fruit" in (1) in fig. 7, and the client generates a service request according to the search keyword. The service request is specifically shown as "https:// XXXX" in (2) in fig. 7, and the service request is sent to the server, the server processes the service request to obtain service loopback data, and the client displays a search result shown as (2) in fig. 7 according to the service loopback data, specifically, for example, "healthy fruits are ranked in ten rows, and the first apple".
Based on the same inventive concept, an embodiment of the present application provides a service request processing apparatus, which can implement the function of the server, the function of the terminal device, or the function of the CGI in the foregoing description, with reference to fig. 8, the service request processing apparatus includes:
a protocol obtaining module 801, configured to obtain a target network protocol corresponding to the target service request;
a policy determining module 802, configured to determine, based on a target network protocol, a first implementation policy of each of a plurality of first sub-processing logics in a main processing logic, where the main processing logic includes a first main flow that is common when performing protocol parsing on multiple types of service requests, the first main flow includes the plurality of first sub-processing logics, and the main processing logic is preconfigured, and one type of service request in the multiple types of service requests corresponds to one network protocol;
a process execution module 803, configured to execute a first main process on the target service request based on the obtained multiple first implementation policies, and obtain an analysis result of the target service request;
and the service execution module 804 is configured to perform corresponding processing on the target service request based on the analysis result.
In a possible embodiment, the policy determining module 802 is specifically configured to:
determining a first execution mode corresponding to the target service request from an execution mode set, wherein each execution mode in the execution mode set represents at least one first sub-processing logic which is realized in a non-null mode and at least one first sub-processing logic which is realized in a null mode in the plurality of first sub-processing logics when one type of service requests are analyzed, and the input of the first sub-processing logic which is realized in the null mode is the same as the output of the first sub-processing logic after the first sub-processing logic is executed;
and respectively determining a first implementation strategy of the first sub-processing logic of each non-null implementation and a first implementation strategy of the first sub-processing logic of each null implementation from an implementation strategy set based on a target network protocol, wherein each implementation strategy in the implementation strategy set is an implementation mode of one sub-processing logic, and the first implementation strategy corresponding to the first sub-processing logic of each null implementation is used for implementing the corresponding first sub-processing logic in the null implementation.
In a possible embodiment, the apparatus further includes a writing module 805, where the writing module 805 is specifically configured to:
writing a second execution mode of the newly added service request into an execution mode set, wherein the second execution mode comprises at least one first type sub-processing logic which is realized for non-null in the plurality of sub-processing logics and at least one second type sub-processing logic which is realized for null when the newly added service request is analyzed;
and writing the newly added implementation strategy into the implementation strategy set, wherein the newly added implementation strategy is a newly added implementation mode of the sub-processing logic.
In a possible embodiment, the main processing logic further includes an execution sequence of the plurality of first sub-processing logics, the plurality of first sub-processing logics includes a first uniform packet body conversion sub-flow, a session check sub-flow, a decompression sub-flow and a deserialization sub-flow, and the plurality of first implementation policies include a first packet body conversion method corresponding to the uniform packet body conversion sub-flow, a session check method corresponding to the session check sub-flow, a decompression method corresponding to the decompression sub-flow and a deserialization method corresponding to the deserialization sub-flow; the flow executing module 803 is specifically configured to:
based on a plurality of first implementation strategies, executing the following sub-processing logics for the service request according to the execution sequence:
based on the first packet conversion method, executing a first unified packet conversion sub-process on a target network protocol and a target service request to obtain a unified packet which accords with a preset rule;
based on a session check method, executing a session check sub-process on the unified inclusion;
based on the decompression method, executing a decompression sub-process on a result obtained after the session check sub-process is executed;
and executing the deserialization sub-process on the result of the execution of the decompression sub-process based on the deserialization method.
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 one first sub-processing logic, and each first sub-processing logic is represented by a second class inherited from the corresponding first class;
a policy determining module 802, configured to respectively construct respective instances of a plurality of second classes based on the target network protocol, where each of the plurality of second classes corresponds to one of the plurality of first sub-processing logics;
the flow executing module 803 is specifically configured to invoke, through the base class, a method of an instance corresponding to each of the plurality of first sub-processing logics, and execute the corresponding first sub-processing logic.
In a possible embodiment, the main processing logic further includes a second main flow common for performing protocol encapsulation on the multiple types of service processing results, and the second main flow includes multiple second sub-processing logics; the service execution module 804 is specifically configured to:
based on the analysis result, executing a service logic corresponding to the target service request to obtain a service processing result;
and executing a second main process on the service processing result based on second implementation strategies corresponding to the second sub-processing logics respectively to obtain service packet data, wherein the service packet data is data meeting the target network protocol, and each second implementation strategy is determined based on the target network protocol and is an implementation mode of one second sub-processing logic.
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 body conversion sub-process, and the second implementation policy corresponding to each of the plurality of second sub-processing logics includes 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 body conversion method corresponding to the second unified body conversion sub-process; the service execution module 804 is specifically configured to:
based on the serialization method, performing a serialization sub-process on the service processing result;
executing a compression sub-process on a result after the serialization sub-process is executed based on a compression method;
executing a session signature sub-process on a result after the compression sub-process is executed based on a session signature method;
and executing a second unified bag body conversion sub-process on the result after the session signature sub-process is executed based on a second unified bag body conversion method.
In one possible embodiment, the main processing logic is represented by a base class; the service execution module 804 is specifically configured to:
and executing the service logic based on the analysis result by inheriting the third class of the base class to obtain a service processing result.
In a possible embodiment, the main processing logic is represented by a base class, where the base class includes a plurality of fourth classes, each fourth class corresponds to one second sub-processing logic, and each second sub-processing logic is represented by a fifth class inherited from the corresponding fourth class; the service execution module 804 is specifically configured to:
constructing respective instances of a plurality of fifth classes, wherein each fifth class in the plurality of fifth classes corresponds to one second sub-processing logic of the plurality of second sub-processing logics;
and calling the method of the corresponding instance of each first sub-processing logic in the plurality of second sub-processing logics through the base class to execute the corresponding second sub-processing logic.
Based on the same inventive concept, an embodiment of the present application provides a computer device, which can implement the function of the terminal device, the function of the server, or the function of the CGI in the foregoing, please refer to fig. 9, and the computer device includes a processor 901 and a memory 902.
The processor 901 may be a Central Processing Unit (CPU), a digital processing unit, or the like. The specific connection medium between the memory 902 and the processor 901 is not limited in the embodiment of the present application. In the embodiment of the present application, the memory 902 and the processor 901 are connected by the bus 903 in fig. 9, the bus 903 is represented by a thick line in fig. 9, and the connection manner between other components is merely illustrative and is not limited. The bus 903 may be divided into an address bus, a data bus, a control bus, and the like. For ease of illustration, only one thick line is shown in FIG. 9, but this does not indicate only one bus or one type of bus.
The memory 902 may be a volatile memory (volatile memory), such as a random-access memory (RAM); the memory 902 may also be a non-volatile memory (non-volatile memory) such as, but not limited to, a read-only memory (rom), a flash memory (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 desired program code in the form of instructions or data structures and that can be accessed by a computer. The memory 902 may be a combination of the above memories.
A processor 901 for executing a service request processing method as any of the preceding discussed when invoking a computer program stored in the memory 902.
Based on the same inventive concept, embodiments of the present application provide a computer storage medium storing computer instructions, which, when executed on a computer, cause the computer to perform any one of the service request processing methods discussed in the foregoing.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
Based on the same inventive concept, embodiments of the present application provide a computer program product, which includes computer instructions stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions to cause the computer device to execute any one of the service request processing methods described above.
Those of ordinary skill in the art will understand that: all or part of the steps for implementing the method embodiments may be implemented by hardware related to program instructions, and the program may be stored in a computer readable storage medium, and when executed, the program performs the steps including the method embodiments; and the aforementioned storage medium includes: a mobile storage device, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
Alternatively, the integrated unit described above may be stored in a computer-readable storage medium if it is implemented in the form of a software functional module and sold or used as a separate product. Based on such understanding, the technical solutions of the embodiments of the present application may be essentially implemented or portions thereof contributing to the prior art may be embodied in the form of a software product stored in a storage medium, and including several instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the methods described in the embodiments of the present application. And the aforementioned storage medium includes: a removable storage device, a ROM, a RAM, a magnetic or optical disk, or various other media that can store program code.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present application without departing from the spirit and scope of the application. Thus, if such 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 intended to include such modifications and variations as well.

Claims (12)

1. A service request processing method is characterized by comprising the following steps:
acquiring a target network protocol corresponding to the target service request;
determining a first implementation strategy of each of a plurality of first sub-processing logics in a main processing logic based on the target network protocol, wherein the main processing logic comprises a first main flow which is common when a plurality of types of service requests are subjected to protocol analysis, the first main flow comprises the plurality of first sub-processing logics, the main processing logic is pre-configured, and one type of service request in the plurality of types of service requests corresponds to one network protocol;
executing the first main flow to the target service request based on the obtained multiple first implementation strategies to obtain an analysis result of the target service request;
and correspondingly processing the target service request based on the analysis result.
2. The method of claim 1, wherein determining a first implementation policy for each of a plurality of first sub-processing logics in a main processing logic based on the target network protocol comprises:
determining a first execution mode corresponding to the target service request from an execution mode set, wherein each execution mode in the execution mode set represents at least one first sub-processing logic which is not implemented in a null mode and at least one first sub-processing logic which is implemented in a null mode in the plurality of first sub-processing logics when one type of service request is analyzed, and the first sub-processing logic implemented in the null mode refers to the same input when the first sub-processing logic is executed and the same output after the first sub-processing logic is executed;
and respectively determining a first implementation policy of the first sub-processing logic of each non-null implementation and a first implementation policy of the first sub-processing logic of each null implementation from an implementation policy set based on the target network protocol, wherein each implementation policy in the implementation policy set is an implementation manner of one sub-processing logic, and the first implementation policy corresponding to the first sub-processing logic of each null implementation is used for implementing the corresponding first sub-processing logic in the null implementation.
3. The method of claim 2, further comprising at least one of:
writing a second execution mode of the newly added service request of one class into the execution mode set, wherein the second execution mode comprises at least one first-class sub-processing logic which is realized in a non-null mode and at least one second-class sub-processing logic which is realized in a null mode in the plurality of sub-processing logics when the newly added service request of one class is analyzed;
and writing a newly added implementation strategy into the implementation strategy set, wherein the newly added implementation strategy is a newly added implementation mode of a sub-processing logic.
4. The method of claim 1, wherein the main processing logic further comprises an execution order of the plurality of first sub-processing logics, the plurality of first sub-processing logics comprising a first unified body conversion sub-flow, a session check sub-flow, a decompression sub-flow, and a deserialization sub-flow, the plurality of first implementation policies comprising a first body conversion method corresponding to the unified body conversion sub-flow, a session check method corresponding to the session check sub-flow, a decompression method corresponding to the decompression sub-flow, and a deserialization method corresponding to the deserialization sub-flow;
executing the first main flow for the target service request based on the obtained plurality of first implementation policies, including:
based on the plurality of first implementation strategies, executing the following plurality of sub-processing logics for the service request according to the execution sequence:
based on the first packet body conversion method, executing the first unified packet body conversion sub-process on the target network protocol and the target service request to obtain a unified packet body which accords with a preset rule;
based on the session check method, executing a session check sub-process on the unified packet body;
based on the decompression method, executing a decompression sub-process on a result obtained after the session check sub-process is executed;
and executing the deserialization sub-process on the result of executing the decompression sub-process based on the deserialization method.
5. The method of claim 1, wherein the main processing logic is represented by a base class, the base class comprising a plurality of first classes, each first class corresponding to a first sub-processing logic, each first sub-processing logic being represented by a second class that inherits the corresponding first class;
determining a first implementation policy for each of a plurality of first sub-processing logics in the main processing logic based on the target network protocol, including:
constructing respective instances of a plurality of second classes based on the target network protocol, wherein each of the plurality of second classes corresponds to one of the plurality of first sub-processing logics;
executing the first main flow for the target service request based on the obtained plurality of first implementation policies, including:
and calling the method of the corresponding instance of each first sub-processing logic in the plurality of first sub-processing logics through the base class, and executing the corresponding first sub-processing logic.
6. The method of any of claims 1-5, wherein the main processing logic further comprises a second main flow that is common when protocol encapsulating multiple classes of business processing results, the second main flow comprising a plurality of second sub-processing logic;
based on the analysis result, the target service request is correspondingly processed, which comprises the following steps:
based on the analysis result, executing a service logic corresponding to the target service request to obtain a service processing result;
and executing the second main flow on the service processing result based on second implementation strategies corresponding to the second sub-processing logics respectively to obtain service loopback data, wherein the service loopback data is data meeting the target network protocol, and each second implementation strategy is determined based on the target network protocol and is an implementation mode of one second sub-processing logic.
7. The method of claim 6, wherein the plurality of second sub-processing logics comprise a serialization sub-flow, a compression sub-flow, a session signature sub-flow, and a second unified body conversion sub-flow, and wherein the second implementation policy corresponding to each of the plurality of second sub-processing logics comprises a serialization method corresponding to the serialization sub-flow, a compression method corresponding to the compression sub-flow, a session signature method corresponding to the session signature sub-flow, and a second body conversion method corresponding to the second unified body conversion sub-flow;
executing the second main flow for the service processing result based on a second implementation policy corresponding to each of the plurality of second sub-processing logics, including:
based on the serialization method, the serialization sub-process is executed for the service processing result;
executing a compression sub-process on a result after the serialization sub-process is executed based on the compression method;
executing the session signature sub-process on the result of executing the compression sub-process based on the session signature method;
and executing the second unified body conversion sub-process on the result of executing the session signature sub-process based on the second unified body conversion method.
8. The method of claim 6, wherein the main processing logic is represented using a base class;
based on the analysis result, executing a service logic corresponding to the target service request to obtain a service processing result, including:
and executing the service logic based on the analysis result through a third class inherited to the base class to obtain a service processing result.
9. The method of claim 6, wherein the main processing logic is represented by a base class, the base class comprising a plurality of fourth classes, each fourth class corresponding to a second sub-processing logic, each second sub-processing logic being represented by a fifth class that inherits from the corresponding fourth class;
executing the second main flow for the service processing result based on a second implementation policy corresponding to each of the plurality of second sub-processing logics, including:
constructing respective instances of a plurality of fifth classes, wherein each fifth class in the plurality of fifth classes corresponds to one second sub-processing logic of the plurality of second sub-processing logics;
and calling the method of the corresponding instance of each first sub-processing logic in the plurality of second sub-processing logics through the base class, and executing the corresponding second sub-processing logic.
10. A service request processing apparatus, comprising:
the protocol acquisition module is used for acquiring a target network protocol corresponding to the target service request;
a policy determining module, configured to determine, based on the target network protocol, a first implementation policy of each of a plurality of first sub-processing logics in a main processing logic, where the main processing logic includes a first main flow that is common when performing protocol analysis on a plurality of types of service requests, the first main flow includes the plurality of first sub-processing logics, the main processing logic is preconfigured, and one type of service request in the plurality of types of service requests corresponds to one network protocol;
the process execution module is used for executing the first main process to the target service request based on the obtained plurality of first implementation strategies to obtain an analysis result of the target service request;
and the service execution module is used for correspondingly processing the target service request based on the analysis result.
11. A computer device, comprising:
at least one processor, and
a memory communicatively coupled to the at least one processor;
wherein the memory stores instructions executable by the at least one processor, the at least one processor implementing the method of any one of claims 1-9 by executing the instructions stored by the memory.
12. A computer storage medium storing computer instructions which, when run on a computer, cause the computer to perform the method of any one of claims 1 to 9.
CN202110725546.3A 2021-06-29 2021-06-29 Service request processing method, device, equipment and medium Pending CN115550468A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110725546.3A CN115550468A (en) 2021-06-29 2021-06-29 Service request processing method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110725546.3A CN115550468A (en) 2021-06-29 2021-06-29 Service request processing method, device, equipment and medium

Publications (1)

Publication Number Publication Date
CN115550468A true CN115550468A (en) 2022-12-30

Family

ID=84705747

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110725546.3A Pending CN115550468A (en) 2021-06-29 2021-06-29 Service request processing method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN115550468A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115996246A (en) * 2023-03-23 2023-04-21 云粒智慧科技有限公司 Processing method and device of target protocol request, electronic equipment and storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115996246A (en) * 2023-03-23 2023-04-21 云粒智慧科技有限公司 Processing method and device of target protocol request, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
US11190609B2 (en) Connection pooling for scalable network services
US11159528B2 (en) Authentication to network-services using hosted authentication information
US20180247654A1 (en) Device identifier dependent operation processing of packet based data communication
US20190079751A1 (en) Infrastructure Instantiation, Collaboration, and Validation Architecture for Serverless Execution Frameworks
EP2561656B1 (en) Servlet api and method for xmpp protocol
EP3991390A1 (en) Connection pooling for scalable network services
US20110321131A1 (en) Security model for workflows aggregating third party secure services
US20090106431A1 (en) Information on Demand Process Framework to Generate, Manage, Secure, and Deploy Browsers and Application Accessible Web Services
CN111552568A (en) Cloud service calling method and device
AlShahwan et al. Security framework for RESTful mobile cloud computing Web services
AlShahwan et al. Mobile cloud computing for providing complex mobile web services
CN115550468A (en) Service request processing method, device, equipment and medium
CN114338682A (en) Flow identity mark transmission method and device, electronic equipment and storage medium
CN112015383A (en) Login method and device
US8499031B1 (en) Markup language messaging service for secure access by edge applications
CN117194064A (en) Remote calling method and device
US20220400082A1 (en) Ephemeral data stream routing service
Baraki et al. Sam: A semantic-aware middleware for mobile cloud computing
US9479599B2 (en) Reroute of a web service in a web based application
CN112929453A (en) Method and device for sharing session data
CN113626001A (en) API dynamic editing method and device based on script
Capilla Context-aware architectures for building service-oriented systems
CN112165529A (en) Method, device, equipment and medium for low-cost cross-network data exchange
CN114124508B (en) Application login method and system
Medjiah et al. On the enhancement of non-functional requirements for cloud-assisted middleware-based IoT and other applications

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40079451

Country of ref document: HK