Event processing method, system, device and equipment and storage medium
By parsing the processing rule description file on the client, the target state machine is generated and the event flow is directly processed on the client, which solves the problem of network resource waste caused by client event flow processing and improves processing efficiency.
Patent Information
- Application Number
- CN202411823811.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-11
- Publication Date
- 2025-04-08
AI Technical Summary
As client business develops, more and more event streams are generated by clients, resulting in higher network resource costs required to be transmitted to the server for processing.
The processing rule description file corresponding to the pending event stream is obtained on the client, the file is parsed based on the preset file protocol to generate the target state machine, and the event sequence is input into the target state machine to determine the target event sequence that complies with the preset processing rules.
Complete event processing on the client reduces the waste of network resources generated when transmitting event streams to the server to process by the server, and shortens the execution time of preset processing rules.
Smart Images

Figure CN119782001A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of event processing, and in particular to an event processing method, system, device, equipment and storage medium. Background Art
[0002] An event stream refers to a sequence of events generated in chronological order. For example, an event stream may include a sequence of events of a certain type of business generated in chronological order. Currently, the event stream generated by the client is usually processed by the server. For example, the server may write corresponding processing rules for the event stream to be processed. After receiving the event stream from the client, the server may process the event stream according to the processing rules.
[0003] However, with the continuous development of client business, the event streams generated by the client are also increasing. Since the event streams generated by the client usually need to be transmitted to the server through the network for processing by the server, a higher network resource cost is required. Summary of the invention
[0004] In order to solve the above technical problems or at least partially solve the above technical problems, the present disclosure provides an event processing method, system, device, equipment and storage medium.
[0005] In a first aspect, an embodiment of the present disclosure provides an event processing method, the method comprising:
[0006] In response to a generation signal of an event stream to be processed, a processing rule description file corresponding to the event stream to be processed is obtained; wherein the processing rule description file is obtained by compiling a preset processing rule corresponding to the event stream to be processed by the server based on a preset file protocol;
[0007] Parsing the processing rule description file corresponding to the event stream to be processed based on the preset file protocol to generate a target state machine;
[0008] The event sequence in the event stream to be processed is input into the target state machine, and the target state machine is used to determine the target event sequence from the event stream to be processed; wherein the event characteristics of the target event sequence conform to the preset processing rules.
[0009] In an optional embodiment, the target state machine includes transfer edges between multiple state nodes and adjacent state nodes, and the transfer edges are used to represent the transfer of the state corresponding to the previous state node among the adjacent state nodes to the state corresponding to the next state node, and the edge information of the transfer edges includes transfer condition information and transfer execution action information from the state corresponding to the previous state node to the state corresponding to the next state node.
[0010] In an optional implementation manner, the parsing of the processing rule description file corresponding to the event stream to be processed based on the preset file protocol to generate a target state machine includes:
[0011] Parsing the processing rule description file corresponding to the event stream to be processed based on the preset file protocol to obtain an abstract syntax tree; wherein the abstract syntax tree is used to describe the transfer condition information and transfer execution action information of the state corresponding to the previous state node to the state corresponding to the next state node;
[0012] Based on the abstract syntax tree, a target state machine is generated.
[0013] In an optional implementation manner, the method further includes:
[0014] The target event sequence is subjected to a preset post-processing to obtain a processed event sequence.
[0015] In an optional implementation, the target state machine is a non-deterministic finite element automatic state machine.
[0016] In an optional implementation, the processing rule description file is a JSON file.
[0017] In a second aspect, the present disclosure provides an event processing system, the system comprising a client and a server;
[0018] The server is used to compile and process the preset processing rules corresponding to the event stream to be processed based on the preset file protocol to obtain the processing rule description file corresponding to the event stream to be processed;
[0019] The client is used to respond to the generation signal of the event stream to be processed, obtain the processing rule description file corresponding to the event stream to be processed, and parse the processing rule description file based on the preset file protocol to generate a target state machine, and input the event sequence in the event stream to be processed into the target state machine, and use the target state machine to determine the target event sequence from the event stream to be processed; wherein the event characteristics of the target event sequence conform to the preset processing rules corresponding to the event stream to be processed.
[0020] In an optional implementation manner, the client is further configured to send a rule issuing request to the server when a preset rule acquisition condition is met;
[0021] The server is further configured to send a processing rule description file corresponding to the event flow to be processed to the client in response to the rule sending request.
[0022] In an optional implementation manner, the client is specifically configured to send a rule issuance request to the server during the startup of the target application.
[0023] In a third aspect, the present disclosure provides an event processing device, the device comprising:
[0024] An acquisition module, configured to acquire a processing rule description file corresponding to the event stream to be processed in response to a generation signal of the event stream to be processed; wherein the processing rule description file is obtained by compiling the preset processing rules corresponding to the event stream to be processed by the server based on a preset file protocol;
[0025] A parsing module, used for parsing the processing rule description file corresponding to the event stream to be processed based on the preset file protocol to generate a target state machine;
[0026] A determination module is used to input the event sequence in the event stream to be processed into the target state machine, and use the target state machine to determine the target event sequence from the event stream to be processed; wherein the event characteristics of the target event sequence conform to the preset processing rules.
[0027] In a fourth aspect, an embodiment of the present disclosure further provides an electronic device, comprising: a processor; a memory for storing executable instructions of the processor; the processor is used to read the executable instructions from the memory and execute the instructions to implement an event processing method as provided in an embodiment of the present disclosure.
[0028] In a fifth aspect, an embodiment of the present disclosure further provides a computer-readable storage medium, wherein the storage medium stores a computer program, and the computer program is used to execute the event processing method provided by the embodiment of the present disclosure.
[0029] In a sixth aspect, an embodiment of the present disclosure further provides a computer program product, wherein the computer program product includes a computer program / instructions, and when the computer program / instructions are executed by a processor, an event processing method as provided in the embodiment of the present disclosure is implemented.
[0030] Compared with the prior art, the technical solution provided by the embodiments of the present disclosure has the following advantages:
[0031] The disclosed embodiment provides an event processing method, the method comprising: first, in response to the generation information of the event stream to be processed, obtaining a processing rule description file corresponding to the event stream to be processed, wherein the processing rule description file is obtained by compiling and processing the preset processing rules corresponding to the event stream to be processed by the server based on the preset file protocol; parsing the processing rule description file corresponding to the event stream to be processed based on the preset file protocol to generate a target state machine; inputting the event sequence in the event stream to be processed into the target state machine, and determining the target event sequence from the event to be processed by the target state machine, and the event characteristics of the target event sequence meet the preset processing rules. It can be seen that the disclosed embodiment can generate a target state machine using the obtained processing rule description file, and determine the target event sequence that meets the preset processing rules from the event stream to be processed by the target state machine, so as to complete the processing of the event stream to be processed on the client, thereby reducing the waste of network resources generated by transmitting the event stream to the server for the server to process the event stream.
[0032] In addition, since the embodiment of the present disclosure compiles and processes the preset processing rules corresponding to the event stream to be processed in advance on the server side to obtain the corresponding processing rule description file, when the generation signal of the event stream to be processed is received, the target state machine can be directly generated based on the processing rule description file, and the target state machine can be used to determine the corresponding target event sequence, thereby reducing the execution time of the preset processing rules. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.
[0034] Figure 1 It is a schematic diagram of implementing event stream processing on the server side in the prior art;
[0035] Figure 2 A schematic diagram of the structure of an event processing system provided for the disclosed embodiment;
[0036] Figure 3 A flowchart of an event processing method provided by an embodiment of the present disclosure;
[0037] Figure 4 A schematic diagram of a target state machine provided in an embodiment of the present disclosure;
[0038] Figure 5 A processing flow chart for an event stream to be processed provided in an embodiment of the present disclosure;
[0039] Figure 6A schematic diagram of the structure of an event processing device provided by an embodiment of the present disclosure;
[0040] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0041] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0042] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0043] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0044] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0045] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0046] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0047] Complex Event Processing (CEP) is a processing technology used to process and analyze event stream data. An event stream refers to a sequence of events generated in chronological order. For example, an event stream may include a sequence of events of a certain type of business generated in chronological order. Complex event stream processing technology is used to extract important complex event patterns from these event streams.
[0048] Currently, the server-oriented stream processing framework Flink is usually used to process the event stream generated by the client. Figure 1 As shown, it is a schematic diagram of implementing event stream processing on the server side in the prior art. Specifically, corresponding CEP rules can be written on the server side for the event stream to be processed. After receiving the event stream from the client, the server side can process the event stream according to the CEP rules and output an event sequence that complies with the CEP rules. The event sequence that complies with the CEP rules can also be post-processed later.
[0049] However, with the continuous development of client business, the event streams generated by the client are also increasing. Since the event streams generated by the client usually need to be transmitted to the server in real time through the network for processing by the server, a higher network resource cost is required.
[0050] Therefore, the embodiment of the present disclosure provides an event processing method, which includes: first, in response to the generation information of the event stream to be processed, obtaining the processing rule description file corresponding to the event stream to be processed, wherein the processing rule description file is obtained by compiling and processing the preset processing rules corresponding to the event stream to be processed by the server based on the preset file protocol; parsing the processing rule description file corresponding to the event stream to be processed based on the preset file protocol to generate a target state machine; inputting the event sequence in the event stream to be processed into the target state machine, and using the target state machine to determine the target event sequence from the event to be processed, and the event characteristics of the target event sequence meet the preset processing rules. It can be seen that the embodiment of the present disclosure can generate a target state machine using the acquired processing rule description file, and use the target state machine to determine the target event sequence that meets the preset processing rules from the event stream to be processed, so as to complete the processing of the event stream to be processed on the client, thereby reducing the network resources generated when the event stream is transmitted to the server for the server to process the event stream.
[0051] In addition, since the embodiment of the present disclosure compiles and processes the preset processing rules corresponding to the event stream to be processed in advance on the server side to obtain the corresponding processing rule description file, when the generation signal of the event stream to be processed is received, the target state machine can be directly generated based on the processing rule description file, and the target state machine can be used to determine the corresponding target event sequence, thereby shortening the execution time of the preset processing rules.
[0052] Based on this, the present disclosure provides an event processing system, referring to Figure 2 , is a structural diagram of an event processing system provided in a public embodiment, wherein the event processing system 201 includes a server 202 and a client 203.
[0053] The server 202 is used to compile the preset processing rules corresponding to the event stream to be processed based on the preset file protocol to obtain the rule description file corresponding to the event stream to be processed.
[0054] In actual applications, in order to ensure the consistency of the protocols between the client and the server, the server and the client can be designed separately so that both can support the preset file protocol, wherein the preset file protocol can include the JSON protocol, which is a lightweight data exchange format that is easy for machines to parse and generate. Since both the client and the server support the JSON (JavaScript Object Notation) protocol, the client and the server can use the JSON protocol for data exchange.
[0055] In the disclosed embodiment, the event stream to be processed refers to the event stream generated by the client, and the event stream to be processed may include events obtained through the embedded logic code in the business code, such as errors or abnormal events occurring in the client, etc. In actual applications, users can write corresponding preset processing rules for the event stream to be processed, so that the rules can be applied to the event stream to be processed later, thereby obtaining an event sequence that meets the rules.
[0056] Among them, the preset processing rules refer to pre-defined rules for analyzing and processing event streams. The preset processing rules can be used to extract events that meet user needs from the event stream. For example, the preset processing rules can include identifying network events containing HTTP (Hypertext Transfer Protocol) requests from the network event stream.
[0057] In practical applications, a syntax description file (Domain Specific Language, DSL) can be used to write corresponding preset processing rules for the event flow to be processed. Since the preset processing rules written based on DSL cannot be run directly on the client, the preset processing rules need to be compiled and processed on the server based on the preset file protocol before the client executes the rules to obtain a processing rule description file that can be parsed by the client.
[0058] In the embodiment of the present disclosure, the processing rule description file refers to an intermediate product generated by compiling and processing the preset processing rules corresponding to the event flow to be processed and in accordance with the preset file protocol. The processing rule description file may be a file in JSON format, for example.
[0059] In order to shorten the time taken by the client to execute preset processing rules and thus improve the performance of the client, the embodiment of the present disclosure compiles the preset processing rules in advance on the server side based on the preset file protocol to obtain a processing rule description file corresponding to the event stream to be processed. The client only needs to parse the processing rule description file to obtain a target state machine that can be used to analyze and process the event stream to be processed.
[0060] The client 203 is used to respond to the generation signal of the event stream to be processed, obtain the processing rule description file corresponding to the event stream to be processed, and parse the processing rule description file based on the preset file protocol to generate a target state machine, and input the event sequence in the event stream to be processed into the target state machine, and use the target state machine to determine the target event sequence from the event stream to be processed.
[0061] In the disclosed embodiment, in response to a generation signal of an event stream to be processed, the client first obtains a processing rule description file corresponding to the event stream to be processed from the server, and parses the processing rule description file based on a preset file protocol to generate a target state machine.
[0062] In an optional implementation, the client is further configured to send a rule issuance request to the server when the preset rule acquisition condition is met. The rule issuance request is used to request the server to issue a processing rule description file corresponding to the event stream to be processed, and the preset rule acquisition condition may include: sending a rule issuance request to the server during the cold start of the client application, or sending a rule issuance request to the server when the client application switches to the background, etc.
[0063] In the disclosed embodiment, the server is also used to, upon receiving a rule issuance request from the client, first compile and process the preset processing rules corresponding to the event stream to be processed based on the preset file protocol, obtain the processing rule description file corresponding to the event stream to be processed, and then issue the processing rule description file corresponding to the event stream to be processed to the client.
[0064] Since both the client and the server support the preset file protocol, after receiving the processing rule description file sent by the server, the client can parse the processing rule description file based on the preset file protocol to obtain the target state machine.
[0065] In the disclosed embodiment, the client parses the processing rule description file based on the preset file protocol, generates the target state machine, and can also input the event sequence in the event stream to be processed into the target state machine, and use the target state machine to determine the target event sequence from the event stream to be processed. The target event sequence refers to the event sequence whose event features in the event stream to be processed meet the preset processing rules.
[0066] Exemplarily, assuming that the preset processing rule is to identify all HTTP requests from network traffic, when at least one network traffic is obtained, the at least one network traffic can be determined as an event stream to be processed and input into a target state machine used to describe the preset processing rule, and the output target event sequence is a network event containing HTTP requests.
[0067] In the event processing system provided by the embodiment of the present disclosure, the server is used to compile and process the preset processing rules corresponding to the event stream to be processed based on the preset file protocol to obtain the processing rule description file corresponding to the event stream to be processed; the client is used to respond to the generation signal of the event stream to be processed, obtain the processing rule description file corresponding to the event stream to be processed, and parse the processing rule description file based on the preset file protocol to generate a target state machine, and input the event sequence in the event stream to be processed into the target state machine, and use the target state machine to determine the target event sequence that meets the preset processing rules from the event stream to be processed. It can be seen that the embodiment of the present disclosure reduces the waste of network resources generated by transmitting the event stream to the server for the server to process the event stream by converting the processing rule description file corresponding to the event stream to be processed into the target state machine on the client, and using the target state machine to process the event stream to be processed generated by the client.
[0068] In addition, since the embodiment of the present disclosure obtains a processing rule description file by compiling and processing preset processing rules corresponding to the event stream to be processed on the server in advance, the client can generate a target state machine for processing the event stream by parsing the rule description file after obtaining the processing rule description file, thereby reducing the time spent on the client to compile the processing rule description file and improving the performance of the client.
[0069] Based on this, the embodiment of the present disclosure further provides an event processing method, which is introduced below in conjunction with a specific embodiment.
[0070] Figure 3 The present invention provides a flow chart of an event processing method provided in an embodiment of the present invention. The method can be executed by an event processing device, wherein the device can be implemented by software and / or hardware and can generally be integrated in an electronic device. Figure 3 As shown, the method includes:
[0071] S301: In response to a generation signal of an event stream to be processed, obtaining a processing rule description file corresponding to the event stream to be processed.
[0072] The processing rule description file is obtained by compiling the preset processing rules corresponding to the event stream to be processed by the server based on a preset file protocol.
[0073] The event processing method provided in the embodiments of the present disclosure may be applied to a client. Specifically, the client may be deployed on a terminal such as a smart phone, a tablet computer, or a desktop computer.
[0074] The disclosed embodiment compiles the preset processing rules corresponding to the event stream to be processed in advance on the server side to obtain the corresponding processing rule description file, so that when the generation signal of the event stream to be processed is received later, there is no need to compile again, and the compiled processing rule description file can be used to generate the target state machine, thereby shortening the execution time of the preset processing rules.
[0075] In an optional implementation, the stream of pending events generated by the client can be obtained by means of tracking points. For example, the tracking point events can be written into the business code of the client to obtain the business code with tracking point logic, so that in the subsequent process of executing the tracking point logic code, the stream of pending events generated by the client can be obtained by triggering the tracking point events.
[0076] In an optional implementation, during the cold start of the application or when it is detected that the application has switched to the background, a processing rule description file corresponding to the event stream to be processed can be obtained from the server by sending a rule issuance request to the server.
[0077] S302: Parsing the processing rule description file corresponding to the event stream to be processed based on the preset file protocol to generate a target state machine.
[0078] In the disclosed embodiment, after obtaining the processing rule description file corresponding to the event stream to be processed, the processing rule description file is parsed based on a preset file protocol to generate a target state machine.
[0079] In practical applications, a state machine is a computing model that is used to obtain the next state based on input events and the current state.
[0080] In an optional implementation, since the processing rule description file corresponding to the pending event stream sent by the server is usually stored in a disk, and the client can usually only read the data in the file in the memory and process it. Therefore, after obtaining the processing rule description file corresponding to the pending event stream, the embodiment of the present disclosure first registers the pending rule description file in the client's software development kit (SDK) to obtain the corresponding instance, and then parses the instance to obtain the target state machine, so as to use the target state machine to process the pending event stream.
[0081] In an optional implementation, the target state machine may include a nondeterministic finite automaton. Among them, a nondeterministic finite automaton (NFA) is an abstract computing model that can be used to recognize regular expressions. The nondeterministic finite automaton can be composed of a state set, an input alphabet, a transition function, a start state, and an accepting state set. Since the nondeterministic finite automaton allows multiple transition options in the same state, it is more flexible when using states to describe preset processing rules, that is, it can use fewer states and transition rules to describe complex processing rules.
[0082] It can be seen that the embodiment of the present disclosure compiles and processes the preset processing rules corresponding to the event flow to be processed in advance on the server side to obtain the corresponding processing rule description file. After sending it to the client, the client only needs to process the rule description file to generate a target state machine to process the event flow to be processed, thereby shortening the execution time of the client.
[0083] S303: Inputting the event sequence in the event stream to be processed into the target state machine, and using the target state machine to determine the target event sequence from the event stream to be processed.
[0084] Among them, the event characteristics of the target event sequence conform to the preset processing rules.
[0085] In the disclosed embodiment, since the target state machine is generated by the processing rule description file corresponding to the event stream to be processed, after the event sequence in the event stream to be processed is input into the target state machine, the target state machine can determine the target event sequence whose event characteristics meet the preset processing rules from the input event stream to be processed according to the preset processing rules.
[0086] Exemplarily, assuming that the event sequence in the event stream to be processed includes event A, event B and event C, the execution process of the preset processing rule may include: when the current state is S0, determine whether the input event is event A, if it is determined to be event A, execute the next state, that is, state S1; when the current state is S1, determine whether the input event is event B, if it is determined to be event B, execute the next state, that is, state S2.
[0087] In an optional implementation, after the target event sequence is determined from the event stream to be processed using the target state machine, the target event sequence may be subjected to preset post-processing to obtain a processed event sequence. The preset post-processing may include filtering processing, abnormal event marking processing, etc. By performing preset post-processing on the target event sequence, a processed event sequence that meets user needs may be obtained.
[0088] In the event processing method provided by the embodiment of the present disclosure, first, in response to the generation information of the event stream to be processed, a processing rule description file corresponding to the event stream to be processed is obtained, wherein the processing rule description file is obtained by the server compiling and processing the preset processing rules corresponding to the event stream to be processed based on the preset file protocol; then, the processing rule description file corresponding to the event stream to be processed is parsed based on the preset file protocol to generate a target state machine; then, the event sequence in the event stream to be processed is input into the target state machine, and the target state machine is used to determine the target event sequence from the event to be processed, and the event characteristics of the target event sequence meet the preset processing rules. It can be seen that the embodiment of the present disclosure obtains the target state machine by parsing the processing rule description file corresponding to the event stream to be processed, and determines the target event sequence that meets the preset processing rules from the event stream to be processed by the target state machine, thereby reducing the waste of network resources generated by transmitting the event stream to the server for the server to process the event stream.
[0089] In addition, since the embodiment of the present disclosure compiles and processes the preset processing rules corresponding to the event stream to be processed in advance on the server side to obtain the corresponding processing rule description file, when the generation signal of the event stream to be processed is received, the target state machine can be directly generated based on the processing rule description file, and the target state machine can be used to determine the corresponding target event sequence, thereby reducing the execution time of the preset processing rules.
[0090] In an optional embodiment, the target state machine also includes transfer edges between multiple state nodes and adjacent nodes, wherein the transfer edge is used to represent the transfer of the state corresponding to the previous state node in the adjacent state nodes to the state corresponding to the next state node, and the edge information of the transfer edge includes the transfer condition information and transfer execution action information of the state corresponding to the previous state node to the state corresponding to the next state node.
[0091] In the disclosed embodiment, the transfer condition information refers to the condition that needs to be satisfied when the state corresponding to the previous state node is transferred to the state corresponding to the next state node. The transfer condition information may include, for example, determining whether the event name is search, determining whether the event name is video browsing, etc. The transfer execution action information may be used to describe the execution action corresponding to the transfer condition information of the transfer edge, for example, it may include migration, reception, ignoring, or transfer to the next node to process the event, etc. After the action is executed, the state corresponding to the current state node may be transferred to the state corresponding to the next state node.
[0092] like Figure 4 , which is a schematic diagram of a target state machine provided by an embodiment of the present disclosure, wherein the initial state node of the target state machine is node S0, and the event sequence in the event stream to be processed includes event a, event b and event c.
[0093] After the above event sequence is input into the target state machine, the target state machine first determines all outgoing edges of state node S0 (i.e., edges going out from state node S0), and determines that the transfer edge corresponding to state node S0 is transfer edge 1, and the transfer condition information bound to the transfer edge is to determine whether it is event a, and the bound transfer execution action information is to capture event a and run to the next state node, i.e., state node S1. Obviously, event a satisfies the transfer condition information on transfer edge 1, so the action of capturing event a and transferring from state node S0 to state node S1 is executed.
[0094] When the current state node is S1, all outgoing edges of state node S1 are judged, namely, transfer edge 2 and transfer edge 3, wherein transfer edge 2 is used to represent: when it is determined that the event input to state node S1 is event b, event b is not executed and event b is transferred to state node S2 for processing; transfer edge 2 is used to represent: when it is determined that the events input to state node S1 include events other than event b, events other than event b are ignored and not processed.
[0095] When the current state node is S2, all outgoing edges of the state node S2, namely, the transition edge 4, are determined, wherein the transition edge 4 is used to represent: when it is determined that the event input to the state node S2 is event c, the event c is captured and the execution ends.
[0096] In an optional implementation, the processing rule description file corresponding to the event flow to be processed can also be parsed based on a preset file protocol to obtain an abstract syntax tree, wherein the abstract syntax tree is used to describe the transfer condition information and transfer execution action information of the state corresponding to the previous state node to the state corresponding to the next state node; then, based on the abstract syntax tree, the target state machine is generated.
[0097] Among them, the Abstract Syntax Tree (AST) is a tree structure used to represent the abstract syntax structure of the code. Each node in the AST represents a structure in the code, such as an expression, statement, function, etc. The nodes are connected through parent-child relationships to form a tree structure.
[0098] In the embodiments of the present disclosure, nodes in an abstract syntax tree can be used to describe state nodes, and edges between two adjacent nodes in abstract syntax data can be used to describe the transfer of a state corresponding to a previous state node in adjacent state nodes to a state corresponding to a next state node. Specifically, the edges in the abstract syntax tree can be used to describe the transfer condition information and transfer execution action information from the state corresponding to the previous state node to the state corresponding to the next state node.
[0099] In the disclosed embodiment, after obtaining an abstract syntax tree based on a processing rule description file, the abstract syntax tree is traversed, and state nodes and transfer edges of a target state machine are constructed according to the syntax structure of the abstract syntax tree, wherein corresponding state nodes can be constructed for nodes in the abstract syntax tree, and the state nodes can include information such as names; corresponding transfer edges can be constructed for edges in the abstract syntax tree, and corresponding transfer condition information and transfer execution action information, etc., are bound to the transfer edges.
[0100] like Figure 5 As shown, it is a processing flow chart for an event stream to be processed provided by an embodiment of the present disclosure.
[0101] First, the server compiles the preset processing rules corresponding to the event stream to be processed based on the preset file protocol to obtain a processing rule description file corresponding to the event stream to be processed.
[0102] When the server receives a rule delivery request from the client, it delivers a processing rule description file corresponding to the event flow to be processed to the client in response to the rule delivery request.
[0103] In response to the generation signal of the event stream to be processed, the client obtains the rules of the room to be processed corresponding to the event stream to be processed, and parses the processing rule description file based on the preset file protocol to generate a target state machine, and then inputs the event sequence in the event stream to be processed obtained by the tracking point into the target state machine, and uses the target state machine to determine the target event sequence from the event stream to be processed. Output the target event sequence so that the target event sequence can be pre-processed later to obtain the processed event sequence.
[0104] In actual applications, the tracking events can be written into the client's business code to obtain business code with tracking logic, so that in the subsequent process of executing the tracking logic code, the tracking events can be triggered to obtain the event stream to be processed generated by the client.
[0105] In addition, after obtaining the processing rule description file corresponding to the event stream to be processed, the client can also register rule callbacks and business functions to the processing rule description file to associate the preset processing rules with the corresponding callback functions so that the corresponding callback functions can be called when the rules are met. Among them, business functions refer to functions or methods related to business logic. Business functions are usually related to specific business scenarios and are used to implement specific business processes or functions.
[0106] In order to implement the above embodiment, the present disclosure also proposes an event processing device. Figure 6 This is a schematic diagram of the structure of an event processing device provided by an embodiment of the present disclosure. The device can be implemented by software and / or hardware and can generally be integrated into an electronic device. Figure 6 As shown, the device comprises:
[0107] The acquisition module 601 is used to obtain a processing rule description file corresponding to the event stream to be processed in response to a generation signal of the event stream to be processed; wherein the processing rule description file is obtained by the server compiling the preset processing rules corresponding to the event stream to be processed based on a preset file protocol;
[0108] A parsing module 602, configured to parse the processing rule description file corresponding to the event stream to be processed based on the preset file protocol to generate a target state machine;
[0109] The determination module 603 is used to input the event sequence in the event stream to be processed into the target state machine, and use the target state machine to determine the target event sequence from the event stream to be processed; wherein the event characteristics of the target event sequence conform to the preset processing rules.
[0110] In an optional embodiment, the target state machine includes transfer edges between multiple state nodes and adjacent state nodes, and the transfer edges are used to represent the transfer of the state corresponding to the previous state node among the adjacent state nodes to the state corresponding to the next state node, and the edge information of the transfer edges includes transfer condition information and transfer execution action information from the state corresponding to the previous state node to the state corresponding to the next state node.
[0111] In an optional implementation, the parsing module includes:
[0112] A parsing submodule, used to parse the processing rule description file corresponding to the event stream to be processed based on the preset file protocol to obtain an abstract syntax tree; wherein the abstract syntax tree is used to describe the transfer condition information and transfer execution action information of the state corresponding to the previous state node to the state corresponding to the next state node;
[0113] The generating submodule is used to generate a target state machine based on the abstract syntax tree.
[0114] In an optional implementation, the device further includes:
[0115] The preset post-processing module is used to perform preset post-processing on the target event sequence to obtain a processed event sequence.
[0116] In an optional implementation, the target state machine is a non-deterministic finite element automatic state machine.
[0117] In an optional implementation, the processing rule description file is a JSON file.
[0118] In the event processing device provided by the embodiment of the present disclosure, first, in response to the generation information of the event stream to be processed, a processing rule description file corresponding to the event stream to be processed is obtained, wherein the processing rule description file is obtained by compiling and processing the preset processing rules corresponding to the event stream to be processed by the server based on the preset file protocol; the processing rule description file corresponding to the event stream to be processed is parsed based on the preset file protocol to generate a target state machine; the event sequence in the event stream to be processed is input into the target state machine, and the target state machine is used to determine the target event sequence from the event to be processed, and the event characteristics of the target event sequence meet the preset processing rules. It can be seen that the embodiment of the present disclosure obtains the target state machine by parsing the processing rule description file corresponding to the event stream to be processed, and determines the target event sequence that meets the preset processing rules from the event stream to be processed by the target state machine, thereby reducing the waste of network resources generated by transmitting the event stream to the server and processing the event stream by the server.
[0119] In addition to the above-mentioned method and apparatus, the embodiments of the present disclosure further provide a computer-readable storage medium, in which instructions are stored. When the instructions are executed on a terminal device, the terminal device implements the event processing method described in the embodiments of the present disclosure.
[0120] In order to implement the above embodiments, the present disclosure also proposes a computer program product, including a computer program / instruction, which implements the event processing method in the above embodiments when executed by a processor.
[0121] In addition, the present disclosure also provides an event processing device, see Figure 7 As shown, it may include:
[0122] Processor 701, memory 702, input device 703 and output device 704. The number of processors 701 in the event processing device can be one or more. Figure 7In some embodiments of the present disclosure, the processor 701, the memory 702, the input device 703 and the output device 704 may be connected via a bus or other means, wherein: Figure 7 The example of connecting through bus is taken in the following.
[0123] The memory 702 can be used to store software programs and modules. The processor 701 executes various functional applications and event processing of the event processing device by running the software programs and modules stored in the memory 702. The memory 702 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, at least one application required for a function, etc. In addition, the memory 702 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. The input device 703 can be used to receive input digital or character information, and generate signal input related to user settings and function control of the event processing device.
[0124] Specifically in this embodiment, the processor 701 will load the executable files corresponding to the processes of one or more applications into the memory 702 according to the following instructions, and the processor 701 will run the applications stored in the memory 702, thereby realizing the various functions of the above-mentioned event processing device.
[0125] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0126] The above description is only a specific embodiment of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. An event processing method, characterized in that: include: In response to a generation signal of an event stream to be processed, a processing rule description file corresponding to the event stream to be processed is obtained; wherein the processing rule description file is obtained by compiling a preset processing rule corresponding to the event stream to be processed by the server based on a preset file protocol; Parsing the processing rule description file corresponding to the event stream to be processed based on the preset file protocol to generate a target state machine; The event sequence in the event stream to be processed is input into the target state machine, and the target state machine is used to determine the target event sequence from the event stream to be processed; wherein the event characteristics of the target event sequence conform to the preset processing rules.
2. The method according to claim 1, characterized in that The target state machine includes multiple state nodes and transfer edges between adjacent state nodes, the transfer edges are used to represent the transfer of the state corresponding to the previous state node among the adjacent state nodes to the state corresponding to the next state node, and the edge information of the transfer edges includes transfer condition information and transfer execution action information of the state corresponding to the previous state node to the state corresponding to the next state node.
3. The method according to claim 2, characterized in that The step of parsing the processing rule description file corresponding to the event stream to be processed based on the preset file protocol to generate a target state machine includes: Parsing the processing rule description file corresponding to the event stream to be processed based on the preset file protocol to obtain an abstract syntax tree; wherein the abstract syntax tree is used to describe the transfer condition information and transfer execution action information of the state corresponding to the previous state node to the state corresponding to the next state node; Based on the abstract syntax tree, a target state machine is generated.
4. The method according to claim 1, characterized in that: The method further comprises: The target event sequence is subjected to a preset post-processing to obtain a processed event sequence.
5. The method according to claim 1, characterized in that: The target state machine is a non-deterministic finite automatic state machine.
6. The method according to claim 1, characterized in that The processing rule description file is a JSON file.
7. An event processing system, characterized in that: The system includes a client and a server; The server is used to compile and process the preset processing rules corresponding to the event stream to be processed based on the preset file protocol to obtain the processing rule description file corresponding to the event stream to be processed; The client is used to respond to the generation signal of the event stream to be processed, obtain the processing rule description file corresponding to the event stream to be processed, and parse the processing rule description file based on the preset file protocol to generate a target state machine, and input the event sequence in the event stream to be processed into the target state machine, and use the target state machine to determine the target event sequence from the event stream to be processed; wherein the event characteristics of the target event sequence conform to the preset processing rules corresponding to the event stream to be processed.
8. The system according to claim 7, characterized in that The client is further configured to send a rule issuing request to the server when a preset rule obtaining condition is met; The server is further configured to send a processing rule description file corresponding to the event flow to be processed to the client in response to the rule sending request.
9. The system according to claim 7, characterized in that The client is specifically used to send a rule issuance request to the server during the start-up process of the target application.
10. An event processing device, characterized in that: The device comprises: An acquisition module, configured to acquire a processing rule description file corresponding to the event stream to be processed in response to a generation signal of the event stream to be processed; wherein the processing rule description file is obtained by compiling the preset processing rules corresponding to the event stream to be processed by the server based on a preset file protocol; A parsing module, used for parsing the processing rule description file corresponding to the event stream to be processed based on the preset file protocol to generate a target state machine; A determination module is used to input the event sequence in the event stream to be processed into the target state machine, and use the target state machine to determine the target event sequence from the event stream to be processed; wherein the event characteristics of the target event sequence conform to the preset processing rules.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and when the instructions are executed on a terminal device, the terminal device implements the method according to any one of claims 1 to 6.
12. An event processing device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method according to any one of claims 1 to 6 is implemented.
13. A computer program product, characterized in that The computer program product comprises a computer program / instruction, and when the computer program / instruction is executed by a processor, the method according to any one of claims 1 to 6 is implemented.