Asynchronous task center and asynchronous task execution method
Through the state machine, actuator and connection machine of the asynchronous task center, combined with the restorer and observer, the problems of asynchronous task management complexity and resource consumption in online ride-hailing services are solved, and efficient task execution and system reliability are achieved.
Patent Information
- Application Number
- CN202411103948.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-13
- Publication Date
- 2024-11-29
AI Technical Summary
In the online taxi-hailing service scenario, it is difficult for the existing technology to effectively manage and execute a large number of asynchronous tasks, resulting in high complexity of service I/O requests, high resource consumption, high export pressure, and lack of module decoupling and high availability of upstream servers. .
A asynchronous task center is proposed. Through the combination of state machine, executor and connecting machine, the state in the event request command is parsed and corresponding asynchronous tasks are performed, thereby reducing the complexity of service I/O requests of upstream servers and realizing module decoupling. And improve the high availability and reliability of tasks through restorers and observers.
Effectively manage and execute asynchronous tasks in the taxi-hailing process, reduce the export pressure of upstream servers, improve the system maintainability and development efficiency, improve the throughput of submodules, realize unified monitoring and management of asynchronous tasks, and ensure the reliability of tasks. and usability.
Smart Images

Figure CN119045966A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of big data technology, and in particular to the field of task processing technology, and can be applied to scenarios such as autonomous driving online taxi-hailing and traditional online taxi-hailing. Background Art
[0002] In the scenario of online car-hailing services, the server needs to maintain long-term communication with multiple terminals. For the passenger side, the server needs to update information such as drivers, itineraries, and road conditions in real time; push events such as text messages, bills, and coupon activities; and synchronize data such as order information, invoice information, and payment information. For the transportation side, the server needs to synchronize passenger needs, real-time locations, and synchronize orders, bills, invoices, and other information. For partners, the server needs to pull and push data in real time.
[0003] Among them, asynchronous messages in the taxi service scenario are usually processed through the following three solutions: First, a single module builds a processing function and triggers it through a local call. Second, each independent module opens an interface for processing and triggers it through a remote call. Third, decouple through middleware such as databases and message queues, and trigger it through timed training events. Summary of the invention
[0004] The embodiments of the present disclosure provide an asynchronous task center and an asynchronous task execution method, apparatus, device, storage medium, and program product.
[0005] In the first aspect, the embodiments of the present disclosure propose an asynchronous task center, including a state machine, an executor and a connection machine; the state machine is used to receive an event request command sent by an upstream server, parse the status of the taxi-hailing process in the event request command, and determine the asynchronous task type corresponding to the status; the executor is used to receive the asynchronous task type corresponding to the status, and execute the asynchronous task corresponding to the asynchronous task type; the connection machine is used to provide corresponding data to the executor according to the asynchronous task type during the execution of the asynchronous task.
[0006] In the second aspect, an embodiment of the present disclosure proposes an asynchronous task execution method, including: receiving an event request command sent by an upstream server; parsing the status of the taxi-hailing process in the event request command in a state machine, and determining the asynchronous task type corresponding to the status; executing the asynchronous task corresponding to the asynchronous task type in the executor to obtain the asynchronous task execution result, wherein, during the execution of the asynchronous task, the connection machine provides corresponding data to the executor according to the asynchronous task type.
[0007] In the third aspect, an embodiment of the present disclosure proposes an asynchronous task execution device, comprising: a receiving module, configured to receive an event request command sent by an upstream server; a determining module, configured to parse the state of the taxi-hailing process in the event request command in a state machine, and determine the asynchronous task type corresponding to the state; an executing module, configured to execute an asynchronous task corresponding to the asynchronous task type in an executor, and obtain an asynchronous task execution result, wherein, during the execution of the asynchronous task, the connecting machine provides corresponding data to the executor according to the asynchronous task type.
[0008] In a fourth aspect, an embodiment of the present disclosure proposes an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method described in the second aspect.
[0009] In a fifth aspect, an embodiment of the present disclosure proposes a non-transitory computer-readable storage medium storing computer instructions, where the computer instructions are used to enable a computer to execute the method described in the second aspect.
[0010] In a sixth aspect, an embodiment of the present disclosure proposes a computer program product, including a computer program, which implements the method described in the second aspect when executed by a processor.
[0011] The key or important features of the embodiments of the present disclosure are not intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] Other features, purposes and advantages of the present disclosure will become more apparent by reading the detailed description of non-limiting embodiments made with reference to the following drawings. The drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure. Among them:
[0013] Figure 1 is a schematic diagram of the structure of an embodiment of an asynchronous task center according to the present disclosure;
[0014] Figure 2 This is a schematic diagram of the state machine of the taxi-hailing process;
[0015] Figure 3 is a structural diagram of another embodiment of an asynchronous task center according to the present disclosure;
[0016] Figure 4 is a flowchart of an embodiment of an asynchronous task execution method according to the present disclosure;
[0017] Figure 5is a structural diagram of an embodiment of an asynchronous task execution device according to the present disclosure;
[0018] Figure 6 It is a block diagram of an electronic device used to implement the asynchronous task execution method of the embodiment of the present disclosure. DETAILED DESCRIPTION
[0019] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0020] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present disclosure may be combined with each other. The present disclosure will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0021] Figure 1 A structural diagram of an embodiment of an asynchronous task center according to the present disclosure is shown.
[0022] In this embodiment, the asynchronous task center 100 may include a state machine 101 , an executor 102 , and a connection machine 103 .
[0023] The state machine 101 can receive the event request command sent by the upstream server, parse the state of the taxi-hailing process in the event request command, and determine the asynchronous task type corresponding to the state.
[0024] The executor 102 may receive an asynchronous task type corresponding to the state, and execute an asynchronous task corresponding to the asynchronous task type.
[0025] The connection machine 103 may provide corresponding data to the executor 102 according to the type of the asynchronous task during the execution of the asynchronous task.
[0026] In the scenario of online car-hailing services, the server needs to maintain long-term communication with multiple terminals. For the passenger side, the server needs to update information such as drivers, itineraries, and road conditions in real time; push events such as text messages, bills, and coupon activities; and synchronize order information, invoice information, payment information, and other data. For the transportation side, the server needs to synchronize passenger needs, real-time locations, and synchronize orders, bills, invoices, and other information. For partners, the server needs to pull and push data in real time. Therefore, there are a large number of asynchronous tasks that need to be executed.
[0027] In the online car-hailing service scenario, there are various asynchronous tasks. For example, sending text messages, delaying dispatch, issuing coupons, automatic deductions, track reporting, log storage, etc. These asynchronous tasks involve dozens of downstream servers. As the business develops, the number of asynchronous tasks and downstream server data will gradually increase.
[0028] In the process of taking an online car-hailing service, there is still a relatively fixed state. Figure 2 The following is a schematic diagram of the state machine of the taxi-hailing process. Figure 2 As shown, the state machine 101 can parse out states including but not limited to: order placement 201, driver acceptance 202, driver arrival 203, trip start 204, trip end 205, passenger payment 206, post-ride feedback 207, order completion 208 and invalid order 209. The asynchronous task type corresponding to each state may include but is not limited to: real-time task, scheduled task and delayed task. Each asynchronous task type may include multiple specific asynchronous tasks. The state machine 101 can send the asynchronous task type corresponding to the state to the executor 102. The executor 102 can execute these specific asynchronous tasks. During the execution of the asynchronous task, the connector 103 can provide corresponding data to the executor 102 according to the asynchronous task type. Among them, the connector 103 may include but is not limited to: order center, SMS platform, cash register platform and data warehouse platform. If the execution is successful, the state can be sequentially changed from order placement 201 to order completion 208. For any of the states of order placement 201, driver acceptance 202 and driver arrival 203, if the execution fails, the state will be changed to invalid order 209.
[0029] The asynchronous task center 100 can aggregate asynchronous tasks according to the state dimension, so as to well manage and expand all asynchronous tasks in the taxi-hailing process. Specifically, for each state parsed by the state machine 101, all corresponding asynchronous tasks are aggregated into the executor 102 for execution.
[0030] In the prior art, different asynchronous tasks are executed in different task servers. Therefore, when the upstream server receives an event, it needs to parse out all asynchronous tasks corresponding to the state and send a command to the task server corresponding to each asynchronous task. For example, if one state corresponds to n asynchronous tasks, the upstream server needs to send n commands to n task servers. In this way, the complexity of the service I / O (Input / Output) request of the upstream server is n.
[0031] In order to reduce the complexity of the service I / O request of the upstream server, the present disclosure constructs an asynchronous task center 100 based on the state machine 101, the executor 102 and the connector 103. When the upstream server receives an event, it only needs to send an event request command to the asynchronous task center 100. Subsequently, the state machine 101 of the asynchronous task center 100 can parse the state in the event request command and determine the asynchronous task type corresponding to the state. The executor 102 in the asynchronous task center 100 can execute all asynchronous tasks corresponding to the asynchronous task type, and obtain the corresponding data from the connector 103 during the execution of the asynchronous task. By scheduling the asynchronous task center 100, on the one hand, the upstream server does not need to pay attention to the specific implementation of the business, and module decoupling is realized; on the other hand, the upstream server does not need to send n commands to different task servers, saving service resources and reducing the service I / O request from n to 1. The export traffic of the upstream server is migrated to the asynchronous task center 100, thereby reducing the export pressure of the upstream server.
[0032] In some embodiments, in addition to providing corresponding data to the executor 102 according to the asynchronous task type during the execution of the asynchronous task, the connector 103 can also obtain the asynchronous task execution result generated by the executor 102 after the asynchronous task is executed, and send the asynchronous task execution result to the downstream.
[0033] Taking the order status as an example, after the asynchronous task center 100 receives an order request command, it will trigger three types of tasks: real-time, scheduled, and delayed. Among them, real-time tasks may include but are not limited to: obtaining nearby drivers who can accept orders, obtaining real-time traffic information, etc. Scheduled tasks may include but are not limited to: pushing specific car models during peak hours in the morning and evening. Delayed tasks may include but are not limited to: automatically re-ordering, replenishing coupons, adding car models, etc. These tasks are all executed by the executor 102. In addition, during the execution of these tasks, the connector 103 will provide the corresponding data to the executor 102. In some embodiments, the executor 102 can also push data to the connector 103. For example, in the order status, the executor 102 can record the user's behavior data during the order process and push it to the order center and data warehouse platform. The executor 102 can also obtain the user's credit information from the connection machine 103, and determine whether the order is completed based on the user's credit information. If the order is completed, the executor 102 can send the execution result to the SMS platform of the connection machine 103, and send a SMS message of successful order to the passenger through the SMS platform.
[0034] Taking the driver's order acceptance status as an example, after the asynchronous task center 100 receives a driver's order acceptance command, it will trigger three types of tasks: real-time, scheduled, and delayed. Among them, real-time tasks may include but are not limited to: sending instant messaging messages to drivers and passengers, sending text messages to passengers, etc. Scheduled tasks may include but are not limited to: refreshing driver status, location, distance information, etc. in seconds. Delayed tasks may include but are not limited to: driver refusal identification, driver change, etc. These tasks are all executed by the executor 102. In addition, during the execution of these tasks, the connector 103 will provide the corresponding data to the executor 102. In some embodiments, the executor 102 can also push data to the connector 103. For example, in the driver's order acceptance state, when the executor 102 performs the task of refreshing the driver's location information in seconds, it can request the third-party platform through the connector 103 to obtain the driver's location data.
[0035] Taking the driver arrival status as an example, after the asynchronous task center 100 receives a driver arrival command, it will trigger three types of tasks: real-time, scheduled, and delayed. Among them, real-time tasks may include but are not limited to: sending text messages, informing passengers through instant messaging, pop-up windows in the terminal, mobile phone vibration, etc. Scheduled tasks may include but are not limited to: refreshing the driver and passenger locations in seconds, etc. Delayed tasks may include but are not limited to: automatic cancellation due to timeout, penalty, etc. These tasks are all executed by the executor 102. In addition, during the execution of these tasks, the connector 103 will provide the corresponding data to the executor 102. In some embodiments, the executor 102 can also push data to the connector 103. For example, in the driver arrival state, when the executor 102 executes the task of penalty, if the passenger fails to get on the bus due to timeout and the driver cancels the order, it will immediately request the partner platform to obtain the fees that the passenger needs to pay.
[0036] Taking the start of a trip as an example, after the asynchronous task center 100 receives a trip start command, it will trigger three types of tasks: real-time, scheduled, and delayed. Among them, real-time tasks may include but are not limited to: modifying the destination, emergency call for help, etc. Scheduled tasks may include but are not limited to: refreshing route information, cost information, etc. Delayed tasks may include but are not limited to: pushing trip data to the data warehouse platform, etc. These tasks are all executed by the executor 102. In addition, during the execution of these tasks, the connector 103 will provide the corresponding data to the executor 102. In some embodiments, the executor 102 can also push data to the connector 103. For example, in the start of a trip, when the executor 102 executes the task of refreshing route information, it can request the partner platform and the navigation route calculation platform through the connector 103 to obtain the driver's location information and road condition information respectively.
[0037] Taking the end of trip status as an example, after the asynchronous task center 100 receives a trip end command, it will trigger three types of tasks: real-time, scheduled, and delayed. Among them, real-time tasks may include but are not limited to: pushing bill data, issuing completed coupons, etc. Scheduled tasks may include but are not limited to: pushing data to the data warehouse platform, etc. Delayed tasks may include but are not limited to: delaying automatic deductions, etc. These tasks are all executed by the executor 102. In addition, during the execution of these tasks, the connector 103 will provide the corresponding data to the executor 102. In some embodiments, the executor 102 can also push data to the connector 103. For example, in the end of trip state, when the executor 102 executes the delayed automatic deduction task, after the countdown ends, the executor 102 will notify the cash register platform through the connection machine 103 to perform automatic deductions.
[0038] Taking the passenger payment status as an example, after the asynchronous task center 100 receives a passenger payment command, it will trigger three types of tasks: real-time, scheduled, and delayed. Among them, real-time tasks may include but are not limited to: displaying bills, itinerary information, etc. Scheduled tasks may include but are not limited to: pushing payment data to the cash register platform, data warehouse platform, etc. Delayed tasks may include but are not limited to: splitting accounts, reconciliation, etc. These tasks are all executed by the executor 102. In addition, during the execution of these tasks, the connector 103 will provide the corresponding data to the executor 102. In some embodiments, the executor 102 can also push data to the connector 103. For example, in the passenger payment state, when the executor 102 executes the split account task, it can connect to the partner platform and the cash register platform through the connector 103 to obtain the payment details, and then split the accounts according to the proportion agreed in the contract.
[0039] Taking the post-ride feedback state as an example, after the asynchronous task center 100 receives a post-ride feedback command, it will trigger three types of tasks: real-time, scheduled, and delayed. Among them, real-time tasks may include but are not limited to: error recovery, complaint feedback, phone calls, etc. Scheduled tasks may include but are not limited to: pushing travel experience scores, etc. Delayed tasks may include but are not limited to: blacklisting drivers, etc. These tasks are all executed by the executor 102. In addition, during the execution of these tasks, the connector 103 will provide the corresponding data to the executor 102. In some embodiments, the executor 102 can also push data to the connector 103. For example, in the post-ride feedback state, when the executor 102 executes the blacklist driver task, it can obtain the driver information and report the driver's bad behavior through the connector 103, and return the result after the three parties make a judgment.
[0040] Taking the order completion status as an example, after the asynchronous task center 100 receives an order completion command, it will trigger three types of tasks: real-time, scheduled, and delayed. Among them, real-time tasks may include but are not limited to: issuing coupons to users. Scheduled tasks may include but are not limited to: inviting users to fill in destination information, collecting road condition data, etc. Delayed tasks may include but are not limited to: issuing invoices, etc. These tasks are all executed by the executor 102. In addition, during the execution of these tasks, the connector 103 will provide the corresponding data to the executor 102. In some embodiments, the executor 102 can also push data to the connector 103. For example, in the order completion state, when the executor 102 executes the invoice issuance task, it can request the partner platform through the connector 103, send an invoice issuance request, and wait for the three parties to issue the invoice before notifying the executor 102 of the result.
[0041] Taking the invalid order status as an example, after the asynchronous task center 100 receives an invalid order command, it will trigger three types of tasks: real-time, scheduled, and delayed. Among them, real-time tasks may include but are not limited to: reissuing orders, pushing data to disk, etc. Scheduled tasks may include but are not limited to: counting invalid orders, etc. Delayed tasks may include but are not limited to: issuing coupons to users, etc. These tasks are all executed by the executor 102. In addition, during the execution of these tasks, the connector 103 will provide the corresponding data to the executor 102. In some embodiments, the executor 102 can also push data to the connector 103. For example, in the invalid order state, when the executor 102 counts invalid order tasks, it can connect to the data warehouse platform through the connector 103 to count invalid orders for monitoring and alarm.
[0042] The disclosed embodiment provides an asynchronous task center, which is constructed based on a state machine, an executor, and a connector. By scheduling the asynchronous task center, on the one hand, the upstream server does not need to pay attention to the specific implementation of the business, and module decoupling is achieved; on the other hand, the upstream server does not need to send n commands to different downstream servers, saving service resources and reducing the service I / O request from n to 1. The export traffic of the upstream server is migrated to the asynchronous task center, thereby reducing the export pressure of the upstream server.
[0043] Figure 3 A structural diagram of another embodiment of an asynchronous task center according to the present disclosure is shown.
[0044] In this embodiment, the asynchronous task center 100 may include a state machine 101 , an executor 102 , a connection machine 103 , a restorer 104 , an observation machine 105 and a storage layer 106 .
[0045] The state machine 101 can receive the event request command sent by the upstream server, parse the state of the taxi-hailing process in the event request command, and determine the asynchronous task type corresponding to the state.
[0046] The executor 102 may receive an asynchronous task type corresponding to the state, and execute an asynchronous task corresponding to the asynchronous task type.
[0047] The connection machine 103 may provide corresponding data to the executor 102 according to the type of the asynchronous task during the execution of the asynchronous task.
[0048] After the asynchronous task fails to be executed, the recoverer 104 may send a recovery strategy corresponding to the asynchronous task to the executor 102 .
[0049] The executor 102 may re-execute the asynchronous task based on a recovery strategy.
[0050] The observation machine 105 can observe the execution status of the asynchronous task at each stage through aspects, and perform actions including but not limited to: generating logs, monitoring, and alarming based on the execution status.
[0051] The storage layer 106 can store data generated during the execution of asynchronous tasks.
[0052] In the scenario of online car-hailing services, the server needs to maintain long-term communication with multiple terminals. For the passenger side, the server needs to update information such as drivers, itineraries, and road conditions in real time; push events such as text messages, bills, and coupon activities; and synchronize order information, invoice information, payment information, and other data. For the transportation side, the server needs to synchronize passenger needs, real-time locations, and synchronize orders, bills, invoices, and other information. For partners, the server needs to pull and push data in real time. Therefore, there are a large number of asynchronous tasks that need to be executed.
[0053] In the online car-hailing service scenario, there are various asynchronous tasks. For example, sending text messages, delaying dispatch, issuing coupons, automatic deductions, track reporting, log storage, etc. These asynchronous tasks involve dozens of downstream servers. As the business develops, the number of asynchronous tasks and downstream server data will gradually increase.
[0054] In the process of taking an online car-hailing service, there is still a relatively fixed state. Figure 2 The following is a schematic diagram of the state machine of the taxi-hailing process. Figure 2As shown, the state machine 101 can parse out states including but not limited to: order placement 201, driver acceptance 202, driver arrival 203, trip start 204, trip end 205, passenger payment 206, post-ride feedback 207, order completion 208 and invalid order 209. The asynchronous task type corresponding to each state may include but is not limited to: real-time task, scheduled task and delayed task. Each asynchronous task type may include multiple specific asynchronous tasks. The state machine 101 can send the asynchronous task type corresponding to the state to the executor 102. The executor 102 can execute these specific asynchronous tasks. During the execution of the asynchronous task, the connector 103 can provide corresponding data to the executor 102 according to the asynchronous task type. Among them, the connector 103 may include but is not limited to: order center, SMS platform, cash register platform and data warehouse platform. If the execution is successful, the state can be sequentially changed from order placement 201 to order completion 208. For any of the states of order placement 201, driver acceptance 202 and driver arrival 203, if the execution fails, the state will be changed to invalid order 209.
[0055] The asynchronous task center 100 can aggregate asynchronous tasks according to the state dimension, so as to well manage and expand all asynchronous tasks in the taxi-hailing process. Specifically, for each state parsed by the state machine 101, all corresponding asynchronous tasks are aggregated into the executor 102 for execution.
[0056] In the prior art, different asynchronous tasks are executed in different task servers. Therefore, when the upstream server receives an event, it needs to parse out all asynchronous tasks corresponding to the state and send a command to the task server corresponding to each asynchronous task. For example, if one state corresponds to n asynchronous tasks, the upstream server needs to send n commands to n task servers. In this way, the complexity of the service I / O request of the upstream server is n.
[0057] In order to reduce the complexity of the service I / O request of the upstream server, the present disclosure constructs an asynchronous task center 100 based on the state machine 101, the executor 102 and the connector 103. When the upstream server receives an event, it only needs to send an event request command to the asynchronous task center 100. Subsequently, the state machine 101 of the asynchronous task center 100 can parse the state in the event request command and determine the asynchronous task type corresponding to the state. The executor 102 in the asynchronous task center 100 can execute all asynchronous tasks corresponding to the asynchronous type, and obtain the corresponding data from the connector 103 during the execution of the asynchronous task. By scheduling the asynchronous task center 100, on the one hand, the upstream server does not need to pay attention to the specific implementation of the business, and module decoupling is realized; on the other hand, the upstream server does not need to send n commands to different downstream servers, saving service resources and reducing the service I / O request from n to 1. The export traffic of the upstream server is migrated to the asynchronous task center 100, thereby reducing the export pressure of the upstream server.
[0058] In some embodiments, in addition to providing corresponding data to the executor 102 according to the asynchronous task type during the execution of the asynchronous task, the connector 103 can also obtain the asynchronous task execution result generated by the executor 102 after the asynchronous task is executed, and send the asynchronous task execution result to the downstream.
[0059] The recovery strategy of the restorer 104 may include, but is not limited to, best effort delivery, disaster recovery downgrade, etc. Among them, best effort delivery may trigger the executor 102 to execute the asynchronous task multiple times to ensure the successful execution of the asynchronous task as much as possible. Disaster recovery downgrade may directly trigger the executor 102 to obtain the default execution result when the asynchronous task fails to execute. For example, for the ticket replenishment task, if the execution fails, the restorer 104 may directly trigger the executor 102 to replenish the ticket.
[0060] In some embodiments, after the asynchronous task fails to execute, the recoverer 104 determines the re-execution time point of the asynchronous task and sends a re-execution command to the executor 102 at the re-execution time point; the executor 102 re-executes the asynchronous task in response to the re-execution command.
[0061] In some embodiments, after the asynchronous task fails to execute, the recoverer 104 determines the last execution result of the asynchronous task and sends the last execution result to the executor 102; the executor 102 uses the last execution result as the current execution result of the asynchronous task.
[0062] In some embodiments, after the asynchronous task corresponding to the delayed task fails to execute, the recoverer 104 downgrades the delayed task to a real-time task and sends a re-execution command to the executor 102; the executor 102 immediately re-executes the asynchronous task corresponding to the real-time task in response to the re-execution command.
[0063] Taking the order status as an example, after the asynchronous task center 100 receives an order request command, it will trigger three types of tasks: real-time, scheduled, and delayed. Among them, real-time tasks may include but are not limited to: obtaining nearby drivers who can accept orders, obtaining real-time traffic information, etc.; scheduled tasks may include but are not limited to: pushing specific car models during peak hours in the morning and evening; delayed tasks may include but are not limited to: automatically re-ordering, replenishing coupons, adding car models, etc. These tasks are all executed by the executor 102. In addition, during the execution of these tasks, the connector 103 will provide the corresponding data to the executor 102. In some embodiments, the executor 102 can also push data to the connector 103. The executor 102 will also interact with the restorer 104 multiple times to further ensure the high availability of the task. For example, in the order status, the executor 102 can record the behavior data of the user during the order process and push it to the order center and data warehouse platform. The executor 102 can obtain the user's credit information from the connector 103 and determine whether to complete the order based on the user's credit information. If the order is completed, the executor 102 can send the execution result to the SMS platform of the connection machine 103, and send a SMS message of successful order to the passenger through the SMS platform. In order to ensure the high availability of the task of generating the order, if the task fails to be executed, the executor 102 can first store the user order task in a disk for persistent storage, and then inform the restorer 104 to re-trigger. After receiving the task, the restorer 104 will tell the executor 102 to execute the task again at a certain time according to the configured strategy.
[0064] Taking the driver's order acceptance status as an example, after the asynchronous task center 100 receives a driver's order acceptance command, it will trigger three types of tasks: real-time, scheduled, and delayed. Among them, real-time tasks may include but are not limited to: sending instant messaging messages to drivers and passengers, sending text messages to passengers, etc. Scheduled tasks may include but are not limited to: refreshing driver status, location, distance information, etc. in seconds. Delayed tasks may include but are not limited to: driver refusal identification, driver change, etc. These tasks are all executed by the executor 102. In addition, during the execution of these tasks, the connector 103 will provide corresponding data to the executor 102. In some embodiments, the executor 102 can also push data to the connector 103. For example, in the driver's order acceptance state, when the executor 102 executes the task of refreshing the driver's location information in seconds, it can request the third-party platform through the connector 103 to obtain the driver's location data. Since the task will be refreshed in seconds, when the restorer 104 receives the failed location acquisition task submitted by the executor 102, it can return the last location data to the executor 102 for downgrade processing, and the next time the executor 102 executes, it can automatically refresh this location data.
[0065] Taking the driver arrival state as an example, after the asynchronous task center 100 receives a driver arrival command, it will trigger three types of tasks: real-time, scheduled, and delayed. Among them, real-time tasks may include but are not limited to: sending text messages, notifying passengers through instant messaging, pop-up windows in the terminal, mobile phone vibration, etc. Scheduled tasks may include but are not limited to: refreshing the driver and passenger locations in seconds, etc. Delayed tasks may include but are not limited to: automatic cancellation due to timeout, penalty, etc. These tasks are all executed by the executor 102. In addition, during the execution of these tasks, the connector 103 will provide the corresponding data to the executor 102. In some embodiments, the executor 102 can also push data to the connector 103. For example, in the driver arrival state, when the executor 102 executes the penalty task, if the passenger does not get on the car within the time limit and the driver cancels the order, it will immediately request the partner platform to obtain the fees that the passenger needs to pay. If the task fails to be executed, the executor 102 can send the data to the restorer 104. Since the task involves money, high availability needs to be guaranteed. The restorer 104 can continue to retry and submit the task to the executor 102 until the task is successfully executed.
[0066] Taking the trip start state as an example, after the asynchronous task center 100 receives a trip start command, it will trigger three types of tasks: real-time, scheduled, and delayed. Among them, real-time tasks may include but are not limited to: modifying the destination, emergency call for help, etc. Scheduled tasks may include but are not limited to: refreshing route information, cost information, etc. Delayed tasks may include but are not limited to: pushing trip data to the data warehouse platform, etc. These tasks are all executed by the executor 102. In addition, during the execution of these tasks, the connector 103 will provide the corresponding data to the executor 102. In some embodiments, the executor 102 can also push data to the connector 103. For example, in the trip start state, when the executor 102 executes the task of refreshing route information, it can request the partner platform and the navigation route calculation platform through the connector 103 to obtain the driver's location information and road condition information respectively. If the task execution fails, the executor 102 can submit the task to the restorer 104. Since the task is refreshed in seconds, the restorer 104 can downgrade the output of the last route result.
[0067] Taking the end of trip state as an example, after the asynchronous task center 100 receives a trip end command, it will trigger three types of tasks: real-time, scheduled, and delayed. Among them, real-time tasks may include but are not limited to: pushing bill data, issuing single coupons, etc. Scheduled tasks may include but are not limited to: pushing data to the data warehouse platform, etc. Delayed tasks may include but are not limited to: delaying automatic deductions, etc. These tasks are all executed by the executor 102. In addition, during the execution of these tasks, the connector 103 will provide the corresponding data to the executor 102. In some embodiments, the executor 102 can also push data to the connector 103. For example, in the end of trip state, when the executor 102 executes the delayed automatic deduction task, after the countdown ends, the executor 102 will notify the cashier platform through the connector 103 to perform automatic deductions. If the task execution fails, the executor 102 can submit the task to the restorer 104. When processing delayed failed tasks, the restorer 104 does not simply continue to retry the delayed task, but downgrades the delayed task to a real-time task and immediately retries to ensure the successful execution of the task.
[0068] Taking the passenger payment status as an example, after the asynchronous task center 100 receives a passenger payment command, it will trigger three types of tasks: real-time, scheduled, and delayed. Among them, real-time tasks may include but are not limited to: displaying bills, itinerary information, etc. Scheduled tasks may include but are not limited to: pushing payment data to the cash register platform, data warehouse platform, etc. Delayed tasks may include but are not limited to: account splitting, reconciliation, etc. These tasks are all executed by the executor 102. In addition, during the execution of these tasks, the connector 103 will provide the corresponding data to the executor 102. In some embodiments, the executor 102 can also push data to the connector 103. For example, in the passenger payment state, when the executor 102 executes the account splitting task, it can connect to the partner platform and the cash register platform through the connector 103 to obtain the payment details, and then split the account according to the proportion agreed in the contract. If the task execution fails, it will be restored through the restorer 104, and the restorer 104 will downgrade the delayed task to a real-time task and submit it to the executor 102 for retrying.
[0069] Taking the post-ride feedback state as an example, after the asynchronous task center 100 receives a post-ride feedback command, it will trigger three types of tasks: real-time, scheduled, and delayed. Among them, real-time tasks may include but are not limited to: error recovery, complaint feedback, phone calls, etc. Scheduled tasks may include but are not limited to: push travel experience scores, etc. Delayed tasks may include but are not limited to: blacklisting drivers, etc. These tasks are all executed by the executor 102. In addition, during the execution of these tasks, the connector 103 will provide corresponding data to the executor 102. In some embodiments, the executor 102 can also push data to the connector 103. For example, in the post-ride feedback state, when the executor 102 executes the blacklist driver task, it can obtain driver information and report the driver's bad behavior through the connector 103, and return the result after the three parties make a judgment. If the task execution fails, the executor 102 will submit the task to the restorer 104, and the restorer 104 will downgrade the delayed task to a real-time task, and then submit it to the executor 102 for retry processing.
[0070] Taking the order completion state as an example, after the asynchronous task center 100 receives an order completion command, it will trigger three types of tasks: real-time, scheduled, and delayed. Among them, real-time tasks may include but are not limited to: issuing coupons to users. Scheduled tasks may include but are not limited to: inviting users to fill in destination information, collecting road condition data, etc. Delayed tasks may include but are not limited to: issuing invoices, etc. These tasks are all executed by the executor 102. In addition, during the execution of these tasks, the connector 103 will provide the corresponding data to the executor 102. In some embodiments, the executor 102 can also push data to the connector 103. For example, in the order completion state, when the executor 102 executes the invoice issuance task, it can request the partner platform through the connector 103, send an invoice issuance request, and wait for the three parties to issue the invoice before notifying the executor 102 of the result. If the task execution fails, the restorer 104 will not retry when receiving the task submitted by the executor 102, but will return a failure result, so that the passenger can verify the parameters, manually retry, and issue the invoice.
[0071] Taking the invalid order status as an example, after the asynchronous task center 100 receives an invalid order command, it will trigger three types of tasks: real-time, scheduled, and delayed. Among them, real-time tasks may include but are not limited to: re-issuing orders, pushing data to disk, etc. Scheduled tasks may include but are not limited to: counting invalid orders, etc. Delayed tasks may include but are not limited to: issuing coupons to users, etc. These tasks are all executed by the executor 102. In addition, during the execution of these tasks, the connector 103 will provide corresponding data to the executor 102. In some embodiments, the executor 102 can also push data to the connector 103. For example, in the invalid order state, when the executor 102 counts invalid order tasks, it can be connected to the data warehouse platform through the connector 103, count invalid orders for monitoring and alarm. When the task execution fails, the restorer 104 will downgrade the task and inform the system administrator through SMS, email, phone, etc., and through manual intervention to check whether the system has faults, thereby avoiding risks.
[0072] Since all asynchronous tasks are aggregated and executed in the asynchronous task center 100, the observation machine 105 can observe the execution status of each stage of the asynchronous task through sections, and realize functions including but not limited to logging, monitoring, and alarming, thereby realizing visual observation of the asynchronous task center.
[0073] The storage layer 106 can use common storage components for data storage and persistence. Among them, Kafka can be used to receive large amounts of data flowing into the system. MySQL can be used to support data persistence. Redis can be used as a cache to improve system execution efficiency.
[0074] The disclosed embodiment provides an asynchronous task center, which is constructed based on a state machine, an executor, and a connection machine. By scheduling the asynchronous task center, on the one hand, the upstream server does not need to pay attention to the specific implementation of the business, and module decoupling is achieved; on the other hand, the upstream server does not need to send n commands to different downstream servers, which saves service resources and reduces the service I / O request from n to 1. The export traffic of the upstream server is migrated to the asynchronous task center, thereby reducing the export pressure of the upstream server. The execution process of asynchronous tasks in the taxi service scenario is uniformly monitored and managed from the aspect, which realizes module reuse and improves system maintainability. The monitoring and alarm of asynchronous tasks ensures the reliability and availability of tasks.
[0075] The asynchronous task center provided by the embodiment of the present disclosure greatly improves the throughput of each sub-module, is easy to maintain and expand, and uniformly schedules, monitors, and manages asynchronous tasks, greatly improving development efficiency.
[0076] Figure 4 A process 400 of an embodiment of an asynchronous task execution method according to the present disclosure is shown. The asynchronous task execution method comprises the following steps:
[0077] Step 401: Receive an event request command sent by an upstream server.
[0078] Step 402: parse the state of the taxi-hailing process in the event request command in the state machine, and determine the asynchronous task type corresponding to the state.
[0079] Step 403: execute the asynchronous task corresponding to the asynchronous task type in the executor to obtain the asynchronous task execution result.
[0080] In this embodiment, the asynchronous task center 100 may include a state machine 101 , an executor 102 , and a connection machine 103 .
[0081] In the scenario of online car-hailing services, the server needs to maintain long-term communication with multiple terminals. For the passenger side, the server needs to update information such as drivers, itineraries, and road conditions in real time; push events such as text messages, bills, and coupon activities; and synchronize order information, invoice information, payment information, and other data. For the transportation side, the server needs to synchronize passenger needs, real-time locations, and synchronize orders, bills, invoices, and other information. For partners, the server needs to pull and push data in real time. Therefore, there are a large number of asynchronous tasks that need to be executed.
[0082] In the online car-hailing service scenario, there are various asynchronous tasks. For example, sending text messages, delaying dispatch, issuing coupons, automatic deductions, track reporting, log storage, etc. These asynchronous tasks involve dozens of downstream servers. As the business develops, the number of asynchronous tasks and downstream server data will gradually increase.
[0083] In the process of taking a ride in an online car-hailing service, there are relatively fixed states. For example, the state machine can parse out states including but not limited to: order placement, driver acceptance, driver arrival, trip start, trip end, passenger payment, post-ride feedback, order completion, and invalid order. The asynchronous task type corresponding to each state may include but not limited to: real-time tasks, scheduled tasks, and delayed tasks. Each asynchronous task type may include multiple specific asynchronous tasks. The state machine can send the asynchronous task type corresponding to the state to the executor. The executor can execute these specific asynchronous tasks. During the execution of the asynchronous task, the connector can provide the corresponding data to the executor according to the asynchronous task type. Among them, the connector may include but not limited to: order center, SMS platform, cash register platform, and data warehouse platform. If the execution is successful, the state can be changed from the order placement sequence to the order completion. For any of the states of order placement, driver acceptance, and driver arrival, if the execution fails, the state will be changed to an invalid order.
[0084] The asynchronous task center can aggregate asynchronous tasks by state dimension, so as to manage and expand all asynchronous tasks in the taxi-hailing process. Specifically, for each state parsed by the state machine, all corresponding asynchronous tasks are aggregated into the executor for execution.
[0085] In the prior art, different asynchronous tasks are executed in different task servers. Therefore, when the upstream server receives an event, it needs to parse out all asynchronous tasks corresponding to the state and send a command to the task server corresponding to each asynchronous task. For example, if one state corresponds to n asynchronous tasks, the upstream server needs to send n commands to n task servers. In this way, the complexity of the service I / O request of the upstream server is n.
[0086] In order to reduce the complexity of the service I / O requests of the upstream server, the present disclosure constructs an asynchronous task center based on a state machine, an executor, and a connector. When the upstream server receives an event, it only needs to send an event request command to the asynchronous task center. Subsequently, the state machine of the asynchronous task center can parse the state in the event request command and determine the asynchronous task type corresponding to the state. The asynchronous task center executes all asynchronous tasks corresponding to the asynchronous task type, and obtains the corresponding data from the connection machine during the execution of the asynchronous task. By scheduling the asynchronous task center, on the one hand, the upstream server does not need to pay attention to the specific implementation of the business, and module decoupling is achieved; on the other hand, the upstream server does not need to send n commands to different downstream servers, saving service resources and reducing the service I / O request from n to 1. The export traffic of the upstream server is migrated to the asynchronous task center, thereby reducing the export pressure of the upstream server.
[0087] In some embodiments, after an asynchronous task fails to execute, a recovery strategy corresponding to the asynchronous task is determined in the restorer, and the asynchronous task is re-executed in the executor based on the recovery strategy corresponding to the asynchronous task. Among them, the recovery strategy of the restorer may include but is not limited to: best effort delivery, disaster recovery downgrade, etc. Best effort delivery can be to trigger the executor to execute the asynchronous task multiple times to try to ensure the successful execution of the asynchronous task. Disaster recovery downgrade can be to directly trigger the executor to obtain the default execution result when the asynchronous task fails to execute. For example, for a ticket replenishment task, if the execution fails, the restorer can directly trigger the executor to replenish the ticket.
[0088] In some embodiments, after an asynchronous task fails to execute, a re-execution time point for the asynchronous task is determined in the recoverer, and a re-execution command is sent to the executor at the re-execution time point. The executor re-executes the asynchronous task in response to the re-execution command.
[0089] In some embodiments, after the asynchronous task fails to execute, the last execution result of the asynchronous task is determined in the recoverer, and the last execution result is sent to the executor, and the last execution result is used as the current execution result of the asynchronous task in the executor.
[0090] In some embodiments, after the asynchronous task corresponding to the delayed task fails to execute, the delayed task is downgraded to a real-time task in the recoverer, and a re-execution command is sent to the executor. In the executor, in response to the re-execution command, the asynchronous task corresponding to the real-time task is immediately re-executed.
[0091] Taking the order status as an example, after the asynchronous task center receives an order request command, it will trigger three types of tasks: real-time, scheduled, and delayed. Among them, real-time tasks may include but are not limited to: obtaining nearby drivers who can accept orders, obtaining real-time traffic information, etc.; scheduled tasks may include but are not limited to: pushing specific car models during peak hours in the morning and evening; delayed tasks may include but are not limited to: automatically re-ordering, replenishing coupons, adding car models, etc. These tasks are all executed by the executor. In addition, during the execution of these tasks, the connector will provide the corresponding data to the executor. In some embodiments, the executor can also push data to the connector. The executor will also interact with the restorer multiple times to further ensure the high availability of the task. For example, in the order status, the executor can record the user's behavior data during the order process and push it to the order center and data warehouse platform. The executor can obtain the user's credit information from the connection machine and determine whether to complete the order based on the user's credit information. If the order is completed, the executor can send the execution result to the SMS platform of the connection machine, and send a SMS message of successful order to the passenger through the SMS platform. To ensure high availability of the task of generating orders, if the task fails to execute, the executor can first store the user's order task on disk for persistence, and then tell the restorer to re-trigger. After receiving the task, the restorer will tell the executor to execute the task again at a certain time according to the configured strategy.
[0092] Taking the driver's order acceptance status as an example, after the asynchronous task center receives a driver's order acceptance command, it will trigger three types of tasks: real-time, scheduled, and delayed. Among them, real-time tasks may include but are not limited to: sending instant messaging messages to drivers and passengers, sending text messages to passengers, etc. Scheduled tasks may include but are not limited to: refreshing driver status, location, distance information, etc. in seconds. Delayed tasks may include but are not limited to: driver refusal identification, driver change, etc. These tasks are all executed by the executor. In addition, during the execution of these tasks, the connector will provide the corresponding data to the executor. In some embodiments, the executor can also push data to the connector. For example, in the driver's order acceptance state, when the executor executes the task of refreshing the driver's location information in seconds, it can request the third-party platform through the connection machine to obtain the driver's location data. Since the task will be refreshed in seconds, when the restorer receives the failed location acquisition task submitted by the executor, it can return the last location data to the executor for downgrade processing, and the next time the executor executes, it can automatically refresh this location data.
[0093] Taking the driver arrival status as an example, after the asynchronous task center receives a driver arrival command, it will trigger three types of tasks: real-time, scheduled, and delayed. Among them, real-time tasks may include but are not limited to: sending text messages, informing passengers through instant messaging, pop-up windows in the terminal, mobile phone vibration, etc. Scheduled tasks may include but are not limited to: refreshing the driver and passenger locations in seconds, etc. Delayed tasks may include but are not limited to: automatic cancellation due to timeout, penalty, etc. These tasks are all executed by the executor. In addition, during the execution of these tasks, the connector will provide the corresponding data to the executor. In some embodiments, the executor can also push data to the connector. For example, in the driver arrival state, when the executor executes the penalty task, if the passenger fails to get on the car and the driver cancels the order due to timeout, the partner platform will be immediately requested to obtain the fee that the passenger needs to pay. If the task fails to execute, the executor can send the data to the recoverer. Since the task involves money, high availability needs to be guaranteed. The recoverer can continue to retry and submit the task to the executor until the task is successfully executed.
[0094] Taking the start of a trip as an example, after the asynchronous task center receives a start of a trip command, it will trigger three types of tasks: real-time, scheduled, and delayed. Among them, real-time tasks may include but are not limited to: modifying the destination, emergency call for help, etc. Scheduled tasks may include but are not limited to: refreshing route information, cost information, etc. Delayed tasks may include but are not limited to: pushing trip data to the data warehouse platform, etc. These tasks are all executed by the executor. In addition, during the execution of these tasks, the connector will provide the corresponding data to the executor. In some embodiments, the executor can also push data to the connector. For example, in the start of a trip, when the executor executes the task of refreshing route information, it can request the partner platform and the navigation route calculation platform through the connection machine to obtain the driver's location information and road condition information respectively. If the task fails to execute, the executor can submit the task to the restorer. Since the task is refreshed in seconds, the restorer can downgrade the output of the last route result.
[0095] Taking the end of trip state as an example, after the asynchronous task center receives a trip end command, it will trigger three types of tasks: real-time, scheduled, and delayed. Among them, real-time tasks may include but are not limited to: pushing bill data, issuing single coupons, etc. Scheduled tasks may include but are not limited to: pushing data to the data warehouse platform, etc. Delayed tasks may include but are not limited to: delaying automatic deductions, etc. These tasks are all executed by the executor. In addition, during the execution of these tasks, the connector will provide the corresponding data to the executor. In some embodiments, the executor can also push data to the connector. For example, in the end of trip state, when the executor executes the delayed automatic deduction task, after the countdown ends, the executor will notify the cash register platform through the connection machine to automatically deduct money. If the task execution fails, the executor can submit the task to the restorer. When the restorer handles the delayed failed task, it does not simply continue to retry the delayed task, but downgrades the delayed task to a real-time task and immediately retries to ensure the successful execution of the task.
[0096] Taking the passenger payment status as an example, after the asynchronous task center receives a passenger payment command, it will trigger three types of tasks: real-time, scheduled, and delayed. Among them, real-time tasks may include but are not limited to: displaying bills, itinerary information, etc. Scheduled tasks may include but are not limited to: pushing payment data to the cash register platform, data warehouse platform, etc. Delayed tasks may include but are not limited to: account splitting, reconciliation, etc. These tasks are all executed by the executor. In addition, during the execution of these tasks, the connector will provide the corresponding data to the executor. In some embodiments, the executor can also push data to the connector. For example, in the passenger payment state, when the executor executes the account splitting task, it can connect to the partner platform and the cash register platform through the connector to obtain the payment details, and then split the account according to the proportion agreed in the contract. If the task execution fails, it will be restored through the restorer, and the restorer will downgrade the delayed task to a real-time task and submit it to the executor for retrying.
[0097] Taking the post-ride feedback state as an example, after the asynchronous task center receives a post-ride feedback command, it will trigger three types of tasks: real-time, scheduled, and delayed. Among them, real-time tasks may include but are not limited to: error recovery, complaint feedback, phone calls, etc. Scheduled tasks may include but are not limited to: pushing travel experience scores, etc. Delayed tasks may include but are not limited to: blacklisting drivers, etc. These tasks are all executed by the executor. In addition, during the execution of these tasks, the connector will provide the executor with corresponding data. In some embodiments, the executor can also push data to the connector. For example, in the post-ride feedback state, when the executor executes the blacklist driver task, it can obtain driver information and report the driver's bad behavior through the connector, and return the result after the three parties make a judgment. If the task execution fails, the executor will submit the task to the restorer, and the restorer will downgrade the delayed task to a real-time task, and then submit it to the executor for retry processing.
[0098] Taking the order completion status as an example, after the asynchronous task center receives an order completion command, it will trigger three types of tasks: real-time, scheduled, and delayed. Among them, real-time tasks may include but are not limited to: issuing coupons to users. Scheduled tasks may include but are not limited to: inviting users to fill in destination information, collecting road condition data, etc. Delayed tasks may include but are not limited to: issuing invoices, etc. These tasks are all executed by the executor. In addition, during the execution of these tasks, the connector will provide the corresponding data to the executor. In some embodiments, the executor can also push data to the connector. For example, in the order completion state, when the executor executes the invoice issuance task, it can request the partner platform through the connection machine, send an invoice request, and wait for the three parties to issue the invoice before notifying the executor of the result. If the task execution fails, the restorer will not retry when receiving the task submitted by the executor, but will return a failure result, allowing the passenger to verify the parameters, manually retry, and issue the invoice.
[0099] Taking the invalid order status as an example, after the asynchronous task center receives an invalid order command, it will trigger three types of tasks: real-time, scheduled, and delayed. Among them, real-time tasks may include but are not limited to: re-issuing orders, pushing data to disk, etc. Scheduled tasks may include but are not limited to: counting invalid orders, etc. Delayed tasks may include but are not limited to: issuing coupons to users, etc. These tasks are all executed by the executor. In addition, during the execution of these tasks, the connector will provide the corresponding data to the executor. In some embodiments, the executor can also push data to the connector. For example, in the invalid order state, when the executor counts invalid order tasks, it can connect to the data warehouse platform through the connection machine, count invalid orders for monitoring and alarm. When the task execution fails, the restorer will downgrade the task and inform the system administrator through SMS, email, phone, etc., and through manual intervention to check whether the system has faults, thereby avoiding risks.
[0100] In some embodiments, the observation machine observes the execution of asynchronous tasks at various stages through sections, and based on the execution, performs functions including but not limited to: generating logs, monitoring, and alarming. Since all asynchronous tasks are aggregated and executed in the asynchronous task center, the observation machine can observe the execution of asynchronous tasks at various stages through sections, and implement functions including but not limited to logging, monitoring, and alarming, thereby realizing visual observation of the asynchronous task center.
[0101] In some embodiments, the storage layer stores data generated during the execution of asynchronous tasks. The storage layer can use common storage components for data storage and persistence. Kafka can be used to receive large amounts of data flowing into the system. MySQL can be used to support data persistence. Redis can be used as a cache to improve system execution efficiency.
[0102] The disclosed embodiment provides an asynchronous task execution method. By scheduling an asynchronous task center, on the one hand, the upstream server does not need to pay attention to the specific implementation of the business, thus realizing module decoupling; on the other hand, the upstream server does not need to send n commands to different downstream servers, thus saving service resources and reducing the service I / O request from n to 1. The export traffic of the upstream server is migrated to the asynchronous task center, thereby reducing the export pressure of the upstream server. The execution and results of asynchronous tasks in the taxi service scenario are uniformly monitored and managed in a facet-oriented manner, thus realizing module reuse and improving system maintainability. The monitoring and alarm of asynchronous tasks ensure the reliability and availability of the tasks.
[0103] The asynchronous task execution method provided by the embodiment of the present disclosure greatly improves the throughput of each sub-module, is easy to maintain and expand, and uniformly schedules, monitors, and manages asynchronous tasks, greatly improving development efficiency.
[0104] Further references Figure 5 As an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of an asynchronous task execution device. Figure 4 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0105] like Figure 5 As shown, the asynchronous task execution device 500 of this embodiment may include: a receiving module 501, a determining module 502 and an executing module 503. The receiving module 501 is configured to receive an event request command sent by an upstream server; the determining module 502 is configured to parse the state of the taxi-hailing process in the event request command in the state machine, and determine the asynchronous task type corresponding to the state; the executing module 503 is configured to execute the asynchronous task corresponding to the asynchronous task type in the executor to obtain the asynchronous task execution result, wherein, during the execution of the asynchronous task, the connection machine provides corresponding data to the executor according to the asynchronous task type.
[0106] In this embodiment, in the asynchronous task execution device 500, the specific processing of the receiving module 501, the determining module 502 and the executing module 503 and the technical effects thereof can be referred to in Figure 4 The relevant descriptions of steps 401-403 in the corresponding embodiment are not repeated here.
[0107] In some optional implementations of this embodiment, the asynchronous task execution device 500 also includes: a recovery module, which is configured to determine a recovery strategy corresponding to the asynchronous task in a restorer after the asynchronous task fails to execute, and re-execute the asynchronous task in the executor based on the recovery strategy corresponding to the asynchronous task.
[0108] In some optional implementations of this embodiment, the status includes at least one of the following: order placement, driver acceptance of order, driver arrival, trip start, trip end, passenger payment, post-ride feedback, order completion, and invalid order.
[0109] In some optional implementations of this embodiment, the asynchronous task type includes at least one of the following: a real-time task, a scheduled task, and a delayed task.
[0110] In some optional implementations of this embodiment, the recovery module is further configured to: after the asynchronous task fails to execute, determine the re-execution time point of the asynchronous task in the recoverer, send a re-execution command to the executor at the re-execution time point, and re-execute the asynchronous task in the executor in response to the re-execution command.
[0111] In some optional implementations of this embodiment, the recovery module is further configured to: after the asynchronous task fails to execute, determine the previous execution result of the asynchronous task in the recoverer, send the previous execution result to the executor, and use the previous execution result as the current execution result of the asynchronous task in the executor.
[0112] In some optional implementations of this embodiment, the recovery module is further configured to: after the asynchronous task corresponding to the delayed task fails to execute, downgrade the delayed task to a real-time task in the recoverer, send a re-execution command to the executor, and in response to the re-execution command, immediately re-execute the asynchronous task corresponding to the real-time task in the executor.
[0113] In the technical solution disclosed herein, the acquisition, storage and application of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0114] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
[0115] Figure 6 A schematic block diagram of an example electronic device 600 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0116] like Figure 6As shown, the device 600 includes a computing unit 601, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 602 or a computer program loaded from a storage unit 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the device 600 can also be stored. The computing unit 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0117] A number of components in the device 600 are connected to the I / O interface 605, including: an input unit 606, such as a keyboard, a mouse, etc.; an output unit 607, such as various types of displays, speakers, etc.; a storage unit 608, such as a disk, an optical disk, etc.; and a communication unit 609, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 609 allows the device 600 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0118] The computing unit 601 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 601 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 601 performs the various methods and processes described above, such as the asynchronous task execution method. For example, in some embodiments, the asynchronous task execution method may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 608. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 600 via the ROM 602 and / or the communication unit 609. When the computer program is loaded into the RAM 603 and executed by the computing unit 601, one or more steps of the asynchronous task execution method described above may be executed. Alternatively, in other embodiments, the computing unit 601 may be configured to execute the asynchronous task execution method in any other appropriate manner (e.g., by means of firmware).
[0119] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0120] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0121] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0122] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0123] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0124] A computer system may include a client and a server. The client and the server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises through computer programs running on respective computers and having a client-server relationship to each other. The server may be a cloud server, a server in a distributed system, or a server combined with a blockchain.
[0125] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions provided by this disclosure can be achieved, and this document does not limit this.
[0126] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. An asynchronous task center, including a state machine, an executor and a connection machine; The state machine is used to receive the event request command sent by the upstream server, parse the state of the taxi-hailing process in the event request command, and determine the asynchronous task type corresponding to the state; The executor is used to receive the asynchronous task type corresponding to the state and execute the asynchronous task corresponding to the asynchronous task type; The connector is used to provide corresponding data to the executor according to the asynchronous task type during the execution of the asynchronous task.
2. The asynchronous task center according to claim 1, wherein: The asynchronous task center also includes a recoverer; The restorer is used to send a recovery strategy corresponding to the asynchronous task to the executor after the asynchronous task fails to be executed; The executor is used to re-execute the asynchronous task based on the recovery strategy.
3. The asynchronous task center according to claim 1, wherein: The status includes at least one of the following: order placement, driver acceptance, driver arrival, trip start, trip end, passenger payment, post-ride feedback, order completion, and invalid order.
4. The asynchronous task center according to claim 1, wherein: The asynchronous task type includes at least one of the following: a real-time task, a scheduled task, and a delayed task.
5. The asynchronous task center according to claim 2, wherein: The restorer is used to determine a re-execution time point of the asynchronous task after the asynchronous task fails to be executed, and send a re-execution command to the executor at the re-execution time point; The executor is used to re-execute the asynchronous task in response to the re-execution command.
6. The asynchronous task center according to claim 2, wherein: The restorer is used to determine the last execution result of the asynchronous task after the asynchronous task fails to be executed, and send the last execution result to the executor; The executor is used to use the last execution result as the current execution result of the asynchronous task.
7. The asynchronous task center according to claim 2, wherein: The restorer is used to downgrade the delayed task to a real-time task after the asynchronous task corresponding to the delayed task fails to be executed, and send a re-execution command to the executor; The executor is used to immediately re-execute the asynchronous task corresponding to the real-time task in response to the re-execution command.
8. An asynchronous task execution method, comprising: Receive event request commands sent by the upstream server; Parsing the state of the taxi-hailing process in the event request command in the state machine, and determining the asynchronous task type corresponding to the state; An asynchronous task corresponding to the asynchronous task type is executed in the executor to obtain an asynchronous task execution result, wherein during the execution of the asynchronous task, the connection machine provides corresponding data to the executor according to the asynchronous task type.
9. The method according to claim 8, wherein: The method further comprises: After the asynchronous task fails to be executed, a recovery strategy corresponding to the asynchronous task is determined in the restorer, and the asynchronous task is re-executed in the executor based on the recovery strategy corresponding to the asynchronous task.
10. The method according to claim 8, wherein: The status includes at least one of the following: order placement, driver acceptance, driver arrival, trip start, trip end, passenger payment, post-ride feedback, order completion, and invalid order.
11. The method according to claim 8, wherein: The asynchronous task type includes at least one of the following: a real-time task, a scheduled task, and a delayed task.
12. The method according to claim 9, wherein: After the asynchronous task fails to be executed, determining a recovery strategy corresponding to the asynchronous task in the restorer, and re-executing the asynchronous task in the executor based on the recovery strategy corresponding to the asynchronous task, includes: After the asynchronous task fails to execute, the re-execution time point of the asynchronous task is determined in the recoverer, and a re-execution command is sent to the executor at the re-execution time point, and the executor re-executes the asynchronous task in response to the re-execution command.
13. The method according to claim 9, wherein: After the asynchronous task fails to be executed, determining a recovery strategy corresponding to the asynchronous task in the restorer, and re-executing the asynchronous task in the executor based on the recovery strategy corresponding to the asynchronous task, includes: After the asynchronous task fails to execute, the last execution result of the asynchronous task is determined in the restorer, and the last execution result is sent to the executor, and the last execution result is used as the current execution result of the asynchronous task in the executor.
14. The method according to claim 9, wherein: After the asynchronous task fails to be executed, determining a recovery strategy corresponding to the asynchronous task in the restorer, and re-executing the asynchronous task in the executor based on the recovery strategy corresponding to the asynchronous task, includes: After the asynchronous task corresponding to the delayed task fails to execute, the delayed task is downgraded to a real-time task in the recoverer, and a re-execution command is sent to the executor. In response to the re-execution command, the executor immediately re-executes the asynchronous task corresponding to the real-time task.
15. An asynchronous task execution device, comprising: A receiving module, configured to receive an event request command sent by an upstream server; A determination module is configured to parse the state of the taxi-hailing process in the event request command in a state machine, and determine the asynchronous task type corresponding to the state; The execution module is configured to execute the asynchronous task corresponding to the asynchronous task type in the executor to obtain the asynchronous task execution result, wherein during the execution of the asynchronous task, the connection machine provides corresponding data to the executor according to the asynchronous task type.
16. The device according to claim 15, wherein: The device also includes: The recovery module is configured to determine a recovery strategy corresponding to the asynchronous task in the recoverer after the asynchronous task fails to execute, and re-execute the asynchronous task in the executor based on the recovery strategy corresponding to the asynchronous task.
17. The device according to claim 15, wherein: The status includes at least one of the following: order placement, driver acceptance, driver arrival, trip start, trip end, passenger payment, post-ride feedback, order completion, and invalid order.
18. The device according to claim 15, wherein: The asynchronous task type includes at least one of the following: a real-time task, a scheduled task, and a delayed task.
19. The device according to claim 16, wherein: The recovery module is further configured to: After the asynchronous task fails to execute, the re-execution time point of the asynchronous task is determined in the recoverer, and a re-execution command is sent to the executor at the re-execution time point, and the executor re-executes the asynchronous task in response to the re-execution command.
20. The device according to claim 16, wherein: The recovery module is further configured to: After the asynchronous task fails to execute, the last execution result of the asynchronous task is determined in the restorer, and the last execution result is sent to the executor, and the last execution result is used as the current execution result of the asynchronous task in the executor.
21. The device according to claim 16, wherein: The recovery module is further configured to: After the asynchronous task corresponding to the delayed task fails to execute, the delayed task is downgraded to a real-time task in the recoverer, and a re-execution command is sent to the executor. In response to the re-execution command, the executor immediately re-executes the asynchronous task corresponding to the real-time task.
22. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 8 to 14.
23. A non-transitory computer-readable storage medium storing computer instructions, the computer instructions being used to cause the computer to execute the method of any one of claims 8 to 14.
24. A computer program product comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 8 to 14.
