Service scheduling method and device and computer storage medium
By obtaining and analyzing the mapping relationship between scheduling routes and service processing classes in the dynamic routing table, the problem of difficult decoupling between services in the prior art is solved, and flexible mutual scheduling between business modules is realized.
Patent Information
- Application Number
- CN202510163292.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-13
- Publication Date
- 2025-07-01
AI Technical Summary
The lack of effective inter-service decoupling scheduling solutions in the prior art, making it difficult to realize mutual scheduling between business modules.
By obtaining the scheduling route of the first service module, analyzing the dynamic routing table, extracting the mapping relationship between the scheduling route and the business processing class of the second service module, obtaining the business processing class instance, and executing business events on the instance to achieve the response.
Decoupling between business modules is realized, allowing different business modules to schedule each other, and improving the flexibility and efficiency of business processing.
Smart Images

Figure CN120238580A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer processing technologies, and particularly to a service scheduling method, apparatus, and computer storage medium. Background Art
[0002] In the prior art, the dynamic routing capabilities provided by HarmonyOS official mainly focus on the decoupling of page jumps, relying on the Navigation (the root view container for routing navigation) provided by the system to dynamically obtain and manage page jumps. However, in actual application development, there is no good solution for the decoupling scheduling between services. Summary of the Invention
[0003] To solve the above technical problems, this application proposes a service scheduling method, which includes: obtaining the scheduling route of a first service module; extracting the mapping relationship between the scheduling route and the service processing class of a second service module from a dynamic routing table; obtaining an instance of the service processing class of the second service module based on the mapping relationship; using the instance to execute the service event of the first service module, and returning the service event response result of the second service module to the first service module.
[0004] Among them, the service scheduling method further includes: in response to the running of an application program, initializing a dynamic routing framework, and reading the dynamic routing table generated by compiling the application program; writing the mapping relationship of the dynamic routing table into a memory cache.
[0005] Among them, after obtaining the scheduling route of the first service module, the service scheduling method further includes: parsing the scheduling route through the dynamic routing framework, and determining whether the scheduling route is legal; if so, determining whether there is a mapping relationship of the scheduling route in the memory cache; if so, responding to the scheduling route.
[0006] Among them, the service scheduling method further includes: in response to the compilation of the application program, traversing the files of all service modules, obtaining the service processing classes in the service modules; writing the mapping relationship between the service modules, their corresponding service processing classes, and service routes into the dynamic routing table.
[0007] Among them, obtaining the service processing classes in the service modules includes: parsing each file in the specified directory of the service module to generate a node tree; parsing each node in the node tree until it is determined that the decorator of one of the nodes is marked as a service processing class; determining the file where the node marked as a service processing class by the decorator is located as the service processing class of the service module.
[0008] After writing the mapping relationships of the service module, its corresponding service processing class, and service routing into the dynamic routing table, the service scheduling method further includes: generating a service registration class and its registration method based on the mapping relationships.
[0009] The service scheduling method further includes: creating a service processing class in each service module; marking the service processing class with a corresponding type through a custom decorator; defining service routing in the decorator parameters of the service processing class.
[0010] To solve the above technical problems, the present application provides a service scheduling device, which includes an acquisition module, a mapping module, and an execution module; the acquisition module is configured to acquire the scheduling route of a first service module; the mapping module is configured to extract the mapping relationship between the scheduling route and the service processing class of a second service module from the dynamic routing table; acquire an instance of the service processing class of the second service module based on the mapping relationship; the execution module is configured to use the instance to execute the service event of the first service module and return the service event response result of the second service module to the first service module.
[0011] To solve the above technical problems, the present application provides a service scheduling device, which includes a memory and a processor coupled to the memory; wherein, the memory is configured to store program data, and the processor is configured to execute the program data to implement the above service scheduling method.
[0012] To solve the above technical problems, the present application provides a computer storage medium, which is configured to store program data, and when the program data is executed by a computer, it is used to implement the above service scheduling method.
[0013] To solve the above technical problems, the present application provides a service scheduling device, which includes a memory and a processor coupled to the memory; wherein, the memory is configured to store program data, and the processor is configured to execute the program data to implement the above service scheduling method.
[0014] To solve the above technical problems, the present application provides a computer storage medium, which is configured to store program data, and when the program data is executed by a computer, it is used to implement the above service scheduling method.
[0015] Distinct from the prior art, the beneficial effects of the present application are as follows: The service scheduling device obtains the scheduling route of the first service module; extracts the mapping relationship between the scheduling route and the service processing class of the second service module from the dynamic routing table; obtains an instance of the service processing class of the second service module based on the mapping relationship; uses the instance to execute the service event of the first service module, and returns the service event response result of the second service module to the first service module. In the above manner, through the mapping of the dynamic routing table to parse, register, and respond to the routing table at runtime, the decoupled scheduling of services between modules is achieved, enabling different service modules to schedule each other. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of the present invention, and those of ordinary skill in the art can also obtain other drawings without creative efforts based on these drawings.
[0017] Figure 1 It is a flowchart of the first embodiment of the service scheduling method provided by the present application;
[0018] Figure 2 It is a flowchart of the second embodiment of the service scheduling method provided by the present application;
[0019] Figure 3 It is a schematic structural diagram of an embodiment of the service scheduling device provided by the present application;
[0020] Figure 4 It is a schematic structural diagram of another embodiment of the service scheduling device provided by the present application;
[0021] Figure 5 It is a schematic structural diagram of an embodiment of the computer storage medium provided by the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0022] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only some of the embodiments of the present invention, rather than all of them. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the scope of protection of the present invention.
[0023] Among them, the service scheduling method of the present application is applied to a service scheduling device. Among them, the service scheduling device of the present application can be a server or a system in which the server and the local terminal cooperate with each other. Correspondingly, each part included in the service scheduling device, such as each unit, subunit, module, and submodule, can be all set in the server or can be respectively set in the server and the local terminal.
[0024] Further, the above server can be hardware or software. When the server is hardware, it can be implemented as a distributed server cluster composed of multiple servers or as a single server. When the server is software, it can be implemented as multiple software or software modules, such as software or software modules used to provide a distributed server, or can be implemented as a single software or software module, which is not specifically limited here. In some possible implementation manners, the service scheduling method of the embodiments of the present application can be implemented by a processor calling computer-readable instructions stored in a memory.
[0025] The present application proposes a service scheduling method. In this embodiment, the service scheduling method is applied to a client. Please refer to Figure 1 , Figure 1 which is a schematic flowchart of the first embodiment of the service scheduling method provided by the present application.
[0026] As Figure 1 shown, the specific steps are as follows:
[0027] Step S11: Obtain the scheduling route of the first service module.
[0028] Among them, the first service module represents a module that can execute a certain service function. For example, the service can be image processing, audio processing, etc.
[0029] Among them, the scheduling route is used to index service processing classes in the service processing module, and the service capabilities of the service processing module are accessed by the scheduling route.
[0030] In the embodiments of the present application, after obtaining the scheduling route of the first service module, the service scheduling method further includes: parsing the scheduling route through a dynamic routing framework, and determining whether the scheduling route is legal; if so, determining whether there is a mapping relationship of the scheduling route in the memory cache; if so, responding to the scheduling route.
[0031] Among them, the dynamic routing framework refers to a mechanism in a Vue.js application to dynamically add, modify, or delete routing configurations according to specific conditions or requirements. This mechanism enables the application to dynamically adjust navigation rules according to user operations or other factors, thereby providing more flexibility and personalization.
[0032] Specifically, the dynamic routing framework will parse the scheduling route and determine whether the scheduling route is legal; if the scheduling route is legal and the relevant cached routing information can be obtained, the route will be responded to.
[0033] Step S12: Extract the mapping relationship between the scheduling route and the business processing class of the second service module from the dynamic routing table.
[0034] Among them, when the App is running, the dynamic routing framework is initialized, reads and parses the dynamically generated routing table at compile time, and the dynamic routing table stores the mapping relationship between the route and the business processing class.
[0035] Specifically, in response to the running of the application program, the service scheduling device initializes the dynamic routing framework and reads the dynamic routing table generated by compiling the application program; writes the mapping relationship of the dynamic routing table into the memory cache.
[0036] Furthermore, the present application also proposes an embodiment for obtaining the dynamic routing table. For details, please refer to Figure 2 , Figure 2 which is the schematic flowchart of the second embodiment of the service scheduling provided by the present application.
[0037] As Figure 2 shown, the specific steps are as follows:
[0038] Step S21: In response to the compilation of the application program, traverse the files of all service modules to obtain the business processing classes in the service modules.
[0039] Among them, the business processing class is a business Handler class, which is used to process the business logic capabilities provided by the corresponding business route.
[0040] In the Android development environment, Handler is a very important component for inter-thread communication and asynchronous message processing.
[0041] Specifically, in the service module, the corresponding business processing class is created. The responsibility of the business processing class is the business capabilities uniformly exposed by the service module to the outside. Each service module can have one or more business processing classes.
[0042] The business processing class is decorated with a custom decorator @LC Auto Router and can be marked as a processing class. Among them, @LC Auto Router is a custom decorator in the dynamic routing framework and is used to mark the business processing class.
[0043] Define the specific business route in the name parameter of the @LC Auto Router decorator. All subsequent business capabilities will be accessed through this route. The business processing class uniformly follows the LC Router Handle Protocol and implements the handleRoute method to handle the specific business logic corresponding to this route in this method.
[0044] Among them, LC Router Handle Protocol is a unified business route implementation protocol that standardizes the business route implementation interface and input parameters. handle Route is the route access entry provided in the dynamic route framework.
[0045] Specifically, in an embodiment of the present application, the service scheduling device obtains the business processing classes in the service module, including: parsing each file in the specified directory of the service module to generate a node tree; parsing each node in the node tree until it is determined that the decorator of one of the nodes is a business processing class; determining the file where the node with the decorator marked as the business processing class is located as the business processing class of the service module.
[0046] Furthermore, the service scheduling device creates business processing classes in each service module; marks the business processing classes with corresponding types through custom decorators; and defines business routes in the decorator parameters of the business processing classes.
[0047] When the HarmonyOS App starts to compile, the service scheduling device traverses and reads the files in the specified directories of each service module in the h vigor plugin, and parses each file to generate corresponding node tree information. Further, scan and parse each node until the identifier information is matched to the custom decorator @LC Auto Router, and if the node does not have a @Component decorator node, that is, the class file is not a view, then it is determined that the file class is a business processing class.
[0048] Each file will have a node tree, and then each node of the node tree corresponds to each line of text in the file. For example, the text of a TXT file, a file has hundreds of texts, and each node searches for each line of text. The service scheduling device determines whether the decorator of each node is a business processing class. If so, then this file is the business processing class file of this service module.
[0049] Step S22: Write the mapping relationship between the service module, its corresponding business processing class, and the business route into the dynamic route table.
[0050] In an embodiment of the present application, after writing the mapping relationship between the service module, its corresponding service processing class, and service routing into the dynamic routing table, the service scheduling device generates a service registration class and its registration method based on the mapping relationship.
[0051] In the dynamic routing framework, corresponding service modules are imported through dynamic import, and the corresponding service registration methods generated by the hvigor plugin during previous compilation are called. The hvigor plugin provides the ability to write and compile relevant services and files in the HarmonyOS framework.
[0052] Specifically, the service scheduling device writes its routing, Handler class name, and module name into the routing table file, generates relevant service registration classes and corresponding registration methods, and calls the registerHandle method of the dynamic routing framework in the registration method to bind the routing to the Handler class name. This facilitates the dynamic routing framework to call this registration method to write this mapping relationship into memory during runtime. Here, the mapping relationship is the binding relationship between the routing and the service processing class, and registerHandle is the binding interface between the routing and the service Handler class provided in the dynamic routing framework.
[0053] In the embodiment of the present application, the routing table is automatically generated by the hvigor plugin during compilation, which can reduce the maintenance workload and error probability of the routing table.
[0054] Step S13: Obtain an instance of the service processing class of the second service module based on the mapping relationship.
[0055] Step S14: Use the instance to execute the service event of the first service module and return the service event response result of the second service module to the first service module.
[0056] The service scheduling device writes the mapping relationship between the routing and the service processing class into memory, obtains an instance of this service processing class through the routing, calls the handleRoute method, and obtains the return result. Here, handleRoute is the routing access entry provided in the dynamic routing framework, and the handleRoute method usually refers to the method for handling routing requests in web development.
[0057] During runtime, the service module first determines a routing, and then searches the dynamic routing table according to the routing to see if there is a mapping relationship containing this routing. If there is, it obtains another service module related to this scheduling routing and its service processing class according to the mapping relationship. Then it uses the service processing of the second service module to complete the access event of the first service module to the second service module.
[0058] This application optimizes the input parameters of the h vigor plugin, automatically traverses the specified paths of the modules, and greatly reduces the usage cost of the plugin during development. The routing mapping relationships are all generated and responded locally, avoiding the impact of network fluctuations.
[0059] To implement the service scheduling method of the above embodiment, this application also provides a service scheduling device. For details, please refer to Figure 3 , Figure 3 which is a schematic structural diagram of an embodiment of the service scheduling device provided by this application.
[0060] As Figure 3 shown, the service scheduling device 500 of this embodiment includes an acquisition module 51, a mapping module 52, and an execution module 53.
[0061] The acquisition module 51 is configured to acquire the scheduling route of the first service module;
[0062] The mapping module 52 is configured to extract the mapping relationship between the scheduling route and the service processing class of the second service module from the dynamic routing table; and acquire an instance of the service processing class of the second service module based on the mapping relationship;
[0063] The execution module 53 is configured to use the instance to execute the service event of the first service module, and return the service event response result of the second service module to the first service module.
[0064] To implement the service scheduling method of the above embodiment, this application also provides another service scheduling device. For details, please refer to Figure 4 , Figure 4 which is a schematic structural diagram of another embodiment of the service scheduling device provided by this application.
[0065] As Figure 4 shown, the service scheduling device 600 of this embodiment includes a processor 61, a memory 62, an input / output device 63, and a bus 64.
[0066] The processor 61, the memory 62, and the input / output device 63 are respectively connected to the bus 64. The memory 62 stores a computer program, and the processor 61 is configured to execute the computer program to implement the service scheduling method of the above embodiment.
[0067] In this embodiment, the processor 61 may also be referred to as a CPU (Central Processing Unit). The processor 61 may be an integrated circuit chip with signal processing capabilities. The processor 61 may also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The processor 61 may also be a GPU (Graphics Processing Unit), also known as a display core, a visual processor, or a display chip, which is a microprocessor specifically for image computing on computers, workstations, game consoles, and some mobile devices (such as tablets, smartphones, etc.). The purpose of the GPU is to convert and drive the display information required by the computer system and provide a line scan signal to the display to control the correct display of the display. It is an important component connecting the display and the computer motherboard. The graphics card, as an important part of the computer host, undertakes the task of outputting and displaying graphics. The general-purpose processor may be a microprocessor or the processor 61 may also be any conventional processor, etc.
[0068] This application also provides a computer storage medium, such as Figure 5 As shown, the computer storage medium 700 is used to store a computer program 71. When the computer program 71 is executed by the processor, it is used to implement the method described in the embodiment of the service scheduling method of this application.
[0069] The method involved in the embodiment of the service scheduling method of this application, when implemented and existing in the form of a software functional unit and sold or used as an independent product, can be stored in a device, such as a computer-readable storage medium. Based on such an understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to enable a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes: USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs, etc., which can store program codes.
[0070] The above are only the embodiments of the present invention, and thus do not limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made by using the content of the specification and drawings of the present invention, or directly or indirectly applied in other related technical fields, shall similarly be included within the patent protection scope of the present invention.
Claims
1. A service scheduling method, characterized in that: The service scheduling method comprises: Obtaining a dispatch route for a first service module; Extracting a mapping relationship between the scheduling route and the service processing class of the second service module from the dynamic routing table; Acquire an instance of the business processing class of the second business module based on the mapping relationship; The business event of the first business module is executed by using the instance, and a business event response result of the second business module is returned to the first business module.
2. The service scheduling method according to claim 1, characterized in that: The service scheduling method further includes: In response to the application running, initializing the dynamic routing framework, and reading the dynamic routing table generated by compiling the application; The mapping relationship of the dynamic routing table is written into the memory cache.
3. The service scheduling method according to claim 2, characterized in that: After obtaining the scheduling route of the first service module, the service scheduling method further includes: Parsing the dispatch route through the dynamic routing framework to determine whether the dispatch route is legal; If so, determining whether there is a mapping relationship of the scheduling route in the memory cache; If yes, respond to the scheduling route.
4. The service scheduling method according to claim 2, characterized in that: The service scheduling method further includes: In response to the application program being compiled, traversing files of all business modules to obtain business processing classes in the business modules; The mapping relationship between the business module and its corresponding business processing class and business routing is written into the dynamic routing table.
5. The service scheduling method according to claim 4, characterized in that: The obtaining of the business processing class in the business module includes: Parse each file in the directory specified by the business module to generate a node tree; Parsing each node in the node tree until determining that a decorator of one of the nodes is marked as a business processing class; The file where the node marked as the business processing class by the decorator is located is determined to be the business processing class of the business module.
6. The service scheduling method according to claim 4, characterized in that: After writing the mapping relationship between the service module and its corresponding service processing class and service route into the dynamic routing table, the service scheduling method further includes: A service registration class and a registration method thereof are generated based on the mapping relationship.
7. The service scheduling method according to claim 1, characterized in that: The service scheduling method further includes: Create a business processing class in each business module; Modify the business processing class into a corresponding type through a custom decorator; The business route is defined in the decorator parameter of the business processing class.
8. A service scheduling device, characterized in that: The service scheduling device includes an acquisition module, a mapping module and an execution module; The acquisition module is used to acquire the scheduling route of the first service module; The mapping module is used to extract the mapping relationship between the scheduling route and the business processing class of the second business module from the dynamic routing table; and obtain an instance of the business processing class of the second business module based on the mapping relationship; The execution module is used to execute the business event of the first business module by using the instance, and return the business event response result of the second business module to the first business module.
9. A service scheduling device, characterized in that: The service scheduling device includes a memory and a processor coupled to the memory; The memory is used to store program data, and the processor is used to execute the program data to implement the service scheduling method according to any one of claims 1 to 7.
10. A computer storage medium, characterized in that: The computer storage medium is used to store program data, and when the program data is executed by a computer, it is used to implement the service scheduling method according to any one of claims 1 to 7.