A method, device, electronic device and storage medium for loading a micro-application queue

By building micro-application loading components in the micro front-end architecture and using the queue mechanism to orderly process micro-application loading requests, the problems of resource competition and creation failure in the existing technology are solved, and system stability is improved.

CN119271309BActive Publication Date: 2025-02-25CIVIL AVIATION CHENGDU INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411794360.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-09
Publication Date
2025-02-25
Estimated Expiration
2044-12-09

AI Technical Summary

Technical Problem

In the micro front-end architecture, the existing technology lacks an effective management mechanism to coordinate the loading order of multiple micro applications, resulting in resource competition and creation failures, affecting user experience and system stability.

Method used

By building micro-application loading components, including the micro-application array to be loaded, the queue function and the queue function, receive the micro-application loading request and load it to the end of the queue, process the request in an orderly manner according to the task execution identifier, and call the loading execution function to load micro-application loading application.

Benefits of technology

It realizes orderly management of micro-application loading requests, avoids resource competition and conflicts, reduces the risk of micro-application failure creation, and improves the overall stability of micro-application management system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119271309B_ABST
    Figure CN119271309B_ABST
Patent Text Reader

Abstract

The present application provides a loading method, device, electronic device and storage medium of a micro-application queue, which is applied to the main application in the micro-front-end architecture, and constructs a micro-application loading component including a micro-application array to be loaded, an entry queue function and an exit queue function; a micro-application loading request is received and the entry queue function is called to load to the end of the micro-application array to be loaded; if the task execution mark is no loading task, the exit queue function is called to take out the target micro-application loading request at the head of the micro-application array to be loaded, and the task execution mark is set to be loaded in progress; the loading execution function included in the target micro-application loading request is called, the target micro-application loading request is executed and the corresponding target micro-application is loaded. The loading request of the micro-application can be managed in an orderly manner, resource competition and conflict caused by disordered loading can be avoided, and the risk of failure to create the micro-application is reduced, and the overall stability of the micro-application management system is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of micro-application technology, and in particular to a method, device, electronic device and storage medium for loading a micro-application queue. Background Art

[0002] With the rapid development of front-end technology, micro-frontend architecture has gradually become the preferred solution for large-scale front-end projects. In the micro-frontend architecture, each micro-application can be independently developed, deployed, and upgraded, effectively improving the flexibility and maintainability of the project. However, how to effectively manage the routing jumps between these micro-applications and ensure the accuracy and consistency of routing information has become a problem that needs to be solved in the micro-frontend architecture.

[0003] In the field of micro-application management, loading and creating micro-applications is a critical process. Existing technologies usually process by directly responding to micro-application loading requests, lacking an effective management mechanism to coordinate the loading order of multiple micro-applications. When multiple micro-applications initiate loading requests at the same time, the system may fail to create some micro-applications due to resource competition or insufficient processing power, thus affecting user experience and system stability. Summary of the invention

[0004] The embodiments of the present application at least provide a method, device, electronic device and storage medium for loading a micro-application queue. The beneficial effects of the present application are: it can manage the loading requests of micro-applications in an orderly manner, avoid resource competition and conflicts caused by disordered loading, and at the same time reduce the risk of failure in creating micro-applications, thereby improving the overall stability of the micro-application management system.

[0005] The embodiment of the present application provides a method for loading a micro-application queue, which is applied to a main application in a micro-frontend architecture, and the method includes:

[0006] Constructing a micro-application loading component, wherein the micro-application loading component includes an array of micro-applications to be loaded, an entry queue function, and an exit queue function;

[0007] Receive a micro-application loading request sent by the micro-application to be loaded, and call the queue entry function to load the micro-application loading request to the end of the micro-application array to be loaded;

[0008] Determine the task execution identifier corresponding to the micro-application array to be loaded, and if the task execution identifier indicates that there is no loading task, call the dequeue function to take out the target micro-application loading request at the head of the micro-application array to be loaded, and set the task execution identifier to loading in progress;

[0009] The load execution function included in the target micro-application load request is called to execute the target micro-application load request and load the corresponding target micro-application.

[0010] In an optional implementation, after calling the load execution function included in the target micro-application load request, executing the target micro-application load request and loading the corresponding target micro-application, the method further includes:

[0011] Determine the loading result status code returned by the loading execution function;

[0012] If the loading result status code indicates that the loading is successful, the task execution flag is set to loading completion, and the dequeue function is repeatedly called to take out the target micro-application loading request at the head of the micro-application array to be loaded until the data in the micro-application array to be loaded is empty.

[0013] In an optional implementation manner, the method further includes:

[0014] If the loading result status code indicates that the loading failed, re-execute the target micro-application loading request according to a preset retry interval to load the target micro-application, and simultaneously monitor the number of retries;

[0015] If the number of retries is greater than a preset retry number threshold, the task execution flag is set to no loading task, and the next micro-application loading request in the array of micro-applications to be loaded is processed continuously.

[0016] In an optional implementation manner, constructing the micro-application loading component specifically includes:

[0017] Define the array of micro-applications to be loaded as an empty array, and set the task execution flag as a no-load task;

[0018] Configure the preset retry interval and the preset retry number threshold;

[0019] A micro-queue object including the array of micro-applications to be loaded, the queue entry function and the queue exit function is constructed as the micro-application loading component.

[0020] In an optional implementation, calling the load execution function included in the target micro-application load request, executing the target micro-application load request and loading the corresponding target micro-application specifically includes:

[0021] Construct a loaded micro-application list, wherein the loaded micro-application list stores the loaded micro-applications in the form of key-value pairs, where the key is an identity identifier or path corresponding to the loaded micro-application, and the value is a loaded micro-application instance;

[0022] Calling the load execution function to trigger the execution of the target micro-application load request, extracting the micro-application configuration information carried in the target micro-application load request, and searching for the target micro-application that matches the micro-application configuration information;

[0023] Calling a preset micro-application loading method in the micro-frontend framework, loading and initializing the target micro-application, and receiving the loaded micro-application instance returned by the preset micro-application loading method;

[0024] Parse the loading result attribute corresponding to the loaded micro-application instance, and send the loading result corresponding to the loading result attribute to the loading execution function, and the loading execution function generates the loading result status code according to the loading result.

[0025] In an optional implementation, after determining the task execution identifier corresponding to the micro-application array to be loaded, the method for loading the micro-application queue further includes:

[0026] If the task execution flag is loading in progress, the execution of the dequeue function is stopped until the task execution flag is changed to no loaded task.

[0027] The embodiment of the present application further provides a loading device for a micro-application queue, which is applied to a main application in a micro-frontend architecture. The loading device for the micro-application queue includes:

[0028] A micro-application loading component construction module is used to construct a micro-application loading component, wherein the micro-application loading component includes an array of micro-applications to be loaded, an entry queue function, and an exit queue function;

[0029] A request enqueue module, used to receive a micro-application loading request sent by a micro-application to be loaded, and call the enqueue function to load the micro-application loading request to the end of the micro-application array to be loaded;

[0030] A request dequeue module is used to determine the task execution identifier corresponding to the micro-application array to be loaded. If the task execution identifier is that there is no loading task, the dequeue function is called to take out the target micro-application loading request at the head of the micro-application array to be loaded, and set the task execution identifier to be loading in progress;

[0031] The loading execution module is used to call the loading execution function included in the target micro-application loading request, execute the target micro-application loading request and load the corresponding target micro-application.

[0032] In an optional implementation manner, the loading device of the micro-application queue is further used to:

[0033] Determine the loading result status code returned by the loading execution function;

[0034] If the loading result status code indicates that the loading is successful, the task execution flag is set to loading completion, and the dequeue function is repeatedly called to take out the target micro-application loading request at the head of the micro-application array to be loaded until the data in the micro-application array to be loaded is empty.

[0035] An embodiment of the present application also provides an electronic device, including: a processor, a memory and a bus, the memory storing machine-readable instructions executable by the processor, when the electronic device is running, the processor and the memory communicate through the bus, and when the machine-readable instructions are executed by the processor, the above-mentioned micro-application queue loading method, or the steps in any possible implementation of the above-mentioned micro-application queue loading method.

[0036] An embodiment of the present application also provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the computer program executes the above-mentioned method for loading a micro-application queue, or the steps of any possible implementation of the above-mentioned method for loading a micro-application queue.

[0037] An embodiment of the present application also provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the above-mentioned micro-application queue loading method, or the steps in any possible implementation of the above-mentioned micro-application queue loading method.

[0038] A method, device, electronic device and storage medium for loading a micro-application queue provided by an embodiment of the present application are applied to a main application in a micro-front-end architecture, wherein the method comprises: constructing a micro-application loading component, wherein the micro-application loading component comprises an array of micro-applications to be loaded, an entry queue function and an exit queue function; receiving a micro-application loading request sent by a micro-application to be loaded, calling the entry queue function to load the micro-application loading request to the end of the micro-application array to be loaded; determining a task execution identifier corresponding to the micro-application array to be loaded, if the task execution identifier is no loading task, calling the exit queue function to take out the target micro-application loading request at the head of the micro-application array to be loaded, and setting the task execution identifier to loading in progress; calling the loading execution function included in the target micro-application loading request, executing the target micro-application loading request and loading the corresponding target micro-application. The loading request of the micro-application can be managed in an orderly manner, resource competition and conflict caused by disordered loading can be avoided, while reducing the risk of failure to create the micro-application, and improving the overall stability of the micro-application management system.

[0039] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present application and are used together with the specification to illustrate the technical solutions of the present application. It should be understood that the following drawings only illustrate certain embodiments of the present application and should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can also be obtained based on these drawings without creative work.

[0041] Figure 1 A flowchart of a method for loading a micro-application queue provided in an embodiment of the present application is shown;

[0042] Figure 2 A flowchart of a method for loading and executing a micro-application provided in an embodiment of the present application is shown;

[0043] Figure 3 A schematic diagram of a micro-application queue loading device provided in an embodiment of the present application is shown;

[0044] Figure 4 A schematic diagram of an electronic device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION

[0045] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. The components of the embodiments of the present application generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.

[0046] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.

[0047] The term "and / or" herein only describes an association relationship, indicating that three relationships may exist. For example, A and / or B may represent the following three situations: A exists alone, A and B exist at the same time, and B exists alone. In addition, the term "at least one" herein represents any combination of at least two of any one or more of a plurality of. For example, including at least one of A, B, and C may represent including any one or more elements selected from the set consisting of A, B, and C.

[0048] Research has found that with the rapid development of front-end technology, micro-frontend architecture has gradually become the preferred solution for large-scale front-end projects. In the micro-frontend architecture, each micro-application can be independently developed, deployed, and upgraded, effectively improving the flexibility and maintainability of the project. However, how to effectively manage the routing jumps between these micro-applications and ensure the accuracy and consistency of routing information has become a problem that needs to be solved in the micro-frontend architecture.

[0049] In the field of micro-application management, loading and creating micro-applications is a critical process. Existing technologies usually process by directly responding to micro-application loading requests, lacking an effective management mechanism to coordinate the loading order of multiple micro-applications. When multiple micro-applications initiate loading requests at the same time, the system may fail to create some micro-applications due to resource competition or insufficient processing power, thus affecting user experience and system stability.

[0050] Based on the above research, the present application provides a method, device, electronic device and storage medium for loading a micro-application queue, which is applied to the main application in the micro-front-end architecture. The method includes: constructing a micro-application loading component, wherein the micro-application loading component includes a micro-application array to be loaded, an entry queue function and an exit queue function; receiving a micro-application loading request sent by a micro-application to be loaded, calling the entry queue function to load the micro-application loading request to the end of the micro-application array to be loaded; determining the task execution identifier corresponding to the micro-application array to be loaded, if the task execution identifier is no loading task, calling the exit queue function to take out the target micro-application loading request at the head of the micro-application array to be loaded, and setting the task execution identifier to loading in progress; calling the loading execution function included in the target micro-application loading request, executing the target micro-application loading request and loading the corresponding target micro-application. The loading request of the micro-application can be managed in an orderly manner, resource competition and conflict caused by disordered loading can be avoided, while reducing the risk of failure to create the micro-application, and improving the overall stability of the micro-application management system.

[0051] To facilitate understanding of this embodiment, a method for loading a micro-application queue disclosed in an embodiment of the present application is first introduced in detail. The execution subject of the method for loading a micro-application queue provided in the embodiment of the present application is the main application in the micro-front-end architecture, which generally includes the main application and the sub-application. The main application is the entry point and central coordination point of the entire front-end application, which aggregates the various micro-applications together to form a complete front-end application. The sub-application may contain one or more pages or functional modules. The main application is responsible for loading and managing all sub-applications, and provides a mechanism to integrate and coordinate all sub-applications to achieve a unified user experience.

[0052] See also Figure 1 As shown, it is a flowchart of a method for loading a micro-application queue provided in an embodiment of the present application, and the method includes steps S101 to S104, wherein:

[0053] S101. Construct a micro-application loading component, wherein the micro-application loading component includes an array of micro-applications to be loaded, an entry queue function, and an exit queue function.

[0054] In the specific implementation, a micro-application loading component is first built through the front-end script file. The loading component is used to manage the loading order and process of the micro-application. The queue mechanism is used to ensure that the micro-applications are processed in the order they are received, reducing the risk of resource conflicts and loading failures.

[0055] Here, the micro-application loading component includes an array of micro-applications to be loaded, an entry queue function, and an exit queue function. The array of micro-applications to be loaded is used to store received micro-application loading requests, and each request object contains micro-application configuration information and a loading execution function; the entry queue function receives a micro-application loading request and pushes it to the end of the array of micro-applications to be loaded; the exit queue function takes a loading request from the head of the array of micro-applications to be loaded and executes the loading execution function therein.

[0056] Specifically, the construction of the micro-application loading component can be achieved through the following steps 1 to 3:

[0057] Step 1: Define the array of micro-applications to be loaded as an empty array, and set the task execution flag to no loading task.

[0058] Step 2: Configure the preset retry interval and the preset retry count threshold.

[0059] Step 3: Construct a micro-queue object including an array of micro-applications to be loaded, an entry queue function, and an exit queue function as a micro-application loading component.

[0060] In the specific implementation, in the micro-frontend main application, first initialize the micro-application loading component and define the array of micro-applications to be loaded as an empty array. Then set the task execution flag as no loading task, and configure the preset retry interval and preset retry threshold such as the maximum number of retries and retry interval during the initialization process according to specific needs to handle the subsequent failure of micro-application loading. Finally, create a micro-queue object in the micro-frontend main application according to the above configuration content, which is responsible for the management of the micro-application loading queue.

[0061] S102: Receive a micro-application loading request sent by the micro-application to be loaded, and call the queue entry function to load the micro-application loading request to the end of the array of micro-applications to be loaded.

[0062] In a specific implementation, when the micro-frontend main application receives a micro-application loading request, the micro-application loading request is pushed to the end of the micro-application array to be loaded by calling the queue entry function in the micro-application loading component.

[0063] Here, in the queue entry function, the task execution identifier corresponding to the micro-application array to be loaded is first checked. If the task execution identifier is no loading task, that is, it is confirmed that there is no loading task in progress, then the queue exit function is immediately called to start processing the first request at the head of the micro-application array to be loaded; if the task execution identifier is loading in progress, the micro-application loading request is pushed into the micro-application array to be loaded and wait for the current loading task to be completed.

[0064] S103, determining the task execution identifier corresponding to the micro-application array to be loaded, if the task execution identifier indicates that there is no loading task, calling the dequeue function to take out the target micro-application loading request at the head of the micro-application array to be loaded, and setting the task execution identifier to loading in progress.

[0065] In a specific implementation, if the task execution flag corresponding to the micro-application array to be loaded is no loading task, the dequeue function is called to retrieve the target micro-application loading request at the head of the micro-application array to be loaded, and the task execution flag is set to loading in progress, indicating that the loading task is currently in progress.

[0066] Here, if the task execution is marked as no loading task, the dequeue function takes out a target micro-application loading request from the head of the micro-application array to be loaded (i.e., the position with index 0). The micro-application loading request can be an object that contains the configuration information of the micro-application and the loading execution function.

[0067] Among them, after taking out the target micro-application loading request, the dequeue function sets the task execution flag to loading in progress to indicate that there is currently a loading task in progress, ensuring that no new loading requests will be processed immediately before the loading task is completed.

[0068] It should be noted that the dequeue function needs to be an internal function of the array of micro-applications to be loaded, and avoid direct external calls. Preferably, closures or non-export of ES6 modules can be used to ensure the internality of the function.

[0069] S104: Call the load execution function included in the target micro-application load request, execute the target micro-application load request and load the corresponding target micro-application.

[0070] In a specific implementation, after the dequeue function takes out the target micro-application loading request, the loading execution function in the target micro-application loading request is called to execute the loading task of the micro-application.

[0071] After this, the loading result status code returned by the loading execution function can also be determined; if the loading result status code indicates that the loading is successful, the task execution flag is set to loading completion, and the dequeue function is repeatedly called to take out the target micro-application loading request at the head of the micro-application array to be loaded until the data in the micro-application array to be loaded is empty.

[0072] Furthermore, if the loading result status code indicates that the loading failed, the target micro-application loading request is re-executed according to the preset retry interval to load the target micro-application, and the number of retries is monitored at the same time; if the number of retries is greater than the preset retry threshold, the task execution flag is set to no loading task, and the next micro-application loading request in the array of micro-applications to be loaded is continued to be processed.

[0073] Here, after the load execution function is executed, a load result status code or result object will be returned to indicate the success or failure of the load. The dequeue function needs to receive and process the load result status code or result object. If the load is successful, the dequeue function can continue to process the next request in the queue; if the load fails, the dequeue function needs to decide whether to retry the load based on the configured retry strategy.

[0074] If the loading is successful, the task execution flag is set to no loading task, indicating that the current loading task has been completed. Then, the dequeue function will continue to process the next request in the queue until the queue is empty. If the loading fails, the error message is recorded and the user is notified. Based on the configured retry strategy (such as the number of retries, retry interval, etc.), you can choose whether to retry the loading. During the retry period, the retry count and status are maintained to ensure that the maximum number of retries is not exceeded.

[0075] It should be noted that if the load is successful or fails due to exhaustion of retries, the task execution flag should be set to no load task to allow new load requests to be processed. If retrying, the task execution flag should remain as loading in progress.

[0076] As a possible implementation, see Figure 2 As shown, it is a flowchart of a method for loading and executing a micro-application provided in an embodiment of the present application, and the method includes steps S1041 to S1044, wherein:

[0077] S1041. Build a loaded micro-application list, wherein the loaded micro-application list stores the loaded micro-applications in the form of key-value pairs, where the key is an identity identifier or path corresponding to the loaded micro-application, and the value is the loaded micro-application instance.

[0078] S1042: Call the loading execution function to trigger the execution of the target micro-application loading request, extract the micro-application configuration information carried in the target micro-application loading request, and search for the target micro-application that matches the micro-application configuration information.

[0079] S1043. Call the preset micro-application loading method in the micro-front-end framework to load and initialize the target micro-application, and receive the loaded micro-application instance returned by the preset micro-application loading method.

[0080] S1044. Analyze the loading result attribute corresponding to the loaded micro-application instance, and send the loading result corresponding to the loading result attribute to the loading execution function, and the loading execution function generates the loading result status code according to the loading result.

[0081] In the specific implementation, the main application needs to maintain a variable of the loaded micro-application list, which is preferably a Map structure, with the key being a unique identifier such as the micro-application name, and the value being the micro-application instance, so as to facilitate retrieval based on the micro-application identifier to determine whether the micro-application is currently loaded.

[0082] Here, the main application provides a function for finding a matching target micro-application according to the micro-application configuration information corresponding to the target micro-application loading request, such as findMicroAppByPath(appName) to find the micro-application configuration information according to the path or name.

[0083] Furthermore, it is necessary to call the micro-frontend framework or the self-developed micro-application loading method to load and initialize the micro-application, such as the loadMicroApp function. After the preset micro-application loading method is called, a loaded micro-application instance will be returned, for example, the name is defined as app, and it will be added to the loaded micro-application list object. It should be noted that although the instance is created at this time, it does not mean that the micro-application has been loaded and initialized successfully, and it needs to be judged by its loading result attributes such as mountPromise.

[0084] Here, the loading result attribute can be a Promise type attribute, and there is a corresponding then or catch method to identify whether the micro-application loading is successful. If the micro-application is successfully loaded, its loading result needs to be notified to the loading execution function, and the loading execution function generates the loading result status code according to the loading result.

[0085] Optionally, the loading result can be fed back to the micro-frontend main application and the user. When the loading is successful, the micro-frontend main application can automatically enter the target page of the micro-application; when the loading fails, an error message can be displayed or a retry button can be provided for the user to choose.

[0086] A loading method of a micro-application queue provided by an embodiment of the present application is applied to a main application in a micro-frontend architecture, and the method includes: constructing a micro-application loading component, wherein the micro-application loading component includes a micro-application array to be loaded, an entry queue function, and an exit queue function; receiving a micro-application loading request sent by a micro-application to be loaded, calling the entry queue function to load the micro-application loading request to the end of the micro-application array to be loaded; determining the task execution identifier corresponding to the micro-application array to be loaded, if the task execution identifier is no loading task, calling the exit queue function to take out the target micro-application loading request at the head of the micro-application array to be loaded, and setting the task execution identifier to loading in progress; calling the loading execution function included in the target micro-application loading request, executing the target micro-application loading request and loading the corresponding target micro-application. The loading request of the micro-application can be managed in an orderly manner, resource competition and conflict caused by disordered loading can be avoided, while reducing the risk of failure to create the micro-application, and improving the overall stability of the micro-application management system.

[0087] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.

[0088] Based on the same inventive concept, the embodiment of the present application also provides a loading device for a micro-application queue corresponding to the loading method for a micro-application queue. Since the principle of solving the problem by the device in the embodiment of the present application is similar to the loading method for the micro-application queue in the embodiment of the present application, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.

[0089] See also Figure 3 , Figure 3 A schematic diagram of a loading device for a micro-application queue provided in an embodiment of the present application. Figure 3 As shown in , the loading device 300 of the micro-application queue provided in the embodiment of the present application is applied to the main application in the micro-frontend architecture, including:

[0090] The micro-application loading component construction module 310 is used to construct a micro-application loading component, wherein the micro-application loading component includes an array of micro-applications to be loaded, an entry queue function, and an exit queue function.

[0091] The request enqueue module 320 is used to receive a micro-application loading request sent by the micro-application to be loaded, and call the enqueue function to load the micro-application loading request to the end of the micro-application array to be loaded.

[0092] The request dequeue module 330 is used to determine the task execution identifier corresponding to the micro-application array to be loaded. If the task execution identifier is no loading task, the dequeue function is called to take out the target micro-application loading request at the head of the micro-application array to be loaded, and set the task execution identifier to loading in progress.

[0093] The loading execution module 340 is used to call the loading execution function included in the target micro-application loading request, execute the target micro-application loading request and load the corresponding target micro-application.

[0094] Optionally, the micro-application queue loading device 300 is further used for:

[0095] Determine the loading result status code returned by the loading execution function;

[0096] If the loading result status code indicates that the loading is successful, the task execution flag is set to loading completion, and the dequeue function is repeatedly called to take out the target micro-application loading request at the head of the micro-application array to be loaded until the data in the micro-application array to be loaded is empty.

[0097] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference may be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.

[0098] A loading device for a micro-application queue provided by an embodiment of the present application is applied to a main application in a micro-front-end architecture, and the method includes: constructing a micro-application loading component, wherein the micro-application loading component includes a micro-application array to be loaded, an entry queue function, and an exit queue function; receiving a micro-application loading request sent by a micro-application to be loaded, calling the entry queue function to load the micro-application loading request to the end of the micro-application array to be loaded; determining the task execution identifier corresponding to the micro-application array to be loaded, if the task execution identifier is no loading task, calling the exit queue function to take out the target micro-application loading request at the head of the micro-application array to be loaded, and setting the task execution identifier to loading in progress; calling the loading execution function included in the target micro-application loading request, executing the target micro-application loading request and loading the corresponding target micro-application. The loading request of the micro-application can be managed in an orderly manner, resource competition and conflict caused by disordered loading can be avoided, while reducing the risk of failure to create the micro-application, and improving the overall stability of the micro-application management system.

[0099] Corresponds to Figure 1 The micro-application queue loading method in the present application embodiment also provides an electronic device 400, such as Figure 4 FIG. 4 is a schematic diagram of the structure of an electronic device 400 provided in an embodiment of the present application, including:

[0100] Processor 41, memory 42, and bus 43; memory 42 is used to store execution instructions, including memory 421 and external memory 422; memory 421 here is also called internal memory, which is used to temporarily store operation data in processor 41 and data exchanged with external memory 422 such as hard disk. Processor 41 exchanges data with external memory 422 through memory 421. When the electronic device 400 is running, the processor 41 communicates with the memory 42 through bus 43, so that the processor 41 executes Figure 1 Steps of the loading method of the micro-application queue in.

[0101] The embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the method for loading the micro-application queue described in the above method embodiment are executed. The storage medium can be a volatile or non-volatile computer-readable storage medium.

[0102] An embodiment of the present application also provides a computer program product, which includes computer instructions. When the computer instructions are executed by a processor, the steps of the micro-application queue loading method described in the above method embodiment can be executed. For details, please refer to the above method embodiment, which will not be repeated here.

[0103] The computer program product may be implemented in hardware, software or a combination thereof. In one optional embodiment, the computer program product is implemented as a computer storage medium. In another optional embodiment, the computer program product is implemented as a software product, such as a software development kit (SDK).

[0104] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. In the several embodiments provided in the present application, it should be understood that the disclosed device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0105] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0106] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0107] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, and other media that can store program codes.

[0108] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present application, which are used to illustrate the technical solutions of the present application, rather than to limit them. The protection scope of the present application is not limited thereto. Although the present application is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present application, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims

1. A method for loading a micro-application queue, characterized in that: Applied to the main application in the micro front-end architecture, the method includes: Constructing a micro-application loading component, wherein the micro-application loading component includes an array of micro-applications to be loaded, an entry queue function, and an exit queue function; Receive a micro-application loading request sent by the micro-application to be loaded, and call the queue entry function to load the micro-application loading request to the end of the micro-application array to be loaded; Determine the task execution identifier corresponding to the micro-application array to be loaded, and if the task execution identifier indicates that there is no loading task, call the dequeue function to take out the target micro-application loading request at the head of the micro-application array to be loaded, and set the task execution identifier to loading in progress; Calling the load execution function included in the target micro-application load request, executing the target micro-application load request and loading the corresponding target micro-application; Determine the loading result status code returned by the loading execution function; If the loading result status code indicates that the loading is successful, the task execution flag is set to loading completed, and the dequeue function is repeatedly called to take out the target micro-application loading request at the head of the micro-application array to be loaded, until the data in the micro-application array to be loaded is empty; Constructing the micro-application loading component specifically includes: defining the array of micro-applications to be loaded as an empty array, and setting the task execution identifier as no loading task; configuring a preset retry interval and a preset retry number threshold; constructing a micro-queue object including the array of micro-applications to be loaded, the queue entry function, and the queue exit function as the micro-application loading component; Call the load execution function included in the target micro-application load request, execute the target micro-application load request and load the corresponding target micro-application, specifically including: constructing a loaded micro-application list, wherein the loaded micro-application list stores the loaded micro-applications in the form of key-value pairs, the key is the identity or path corresponding to the loaded micro-application, and the value is the loaded micro-application instance; calling the load execution function to trigger the execution of the target micro-application load request, extracting the micro-application configuration information carried in the target micro-application load request, and searching for the target micro-application that matches the micro-application configuration information; calling the preset micro-application loading method in the micro-front-end framework, loading and initializing the target micro-application, and receiving the loaded micro-application instance returned by the preset micro-application loading method; parsing the loading result attribute corresponding to the loaded micro-application instance, and sending the loading result corresponding to the loading result attribute to the load execution function, and the load execution function generates the loading result status code according to the loading result.

2. The method for loading a micro-application queue according to claim 1, characterized in that: The method further includes: if the loading result status code indicates that the loading has failed, re-executing the target micro-application loading request according to a preset retry interval to load the target micro-application, and simultaneously monitoring the number of retries; If the number of retries is greater than a preset retry number threshold, the task execution flag is set to no loading task, and the next micro-application loading request in the array of micro-applications to be loaded is processed continuously.

3. The method for loading a micro-application queue according to claim 1, characterized in that: After determining the task execution identifier corresponding to the micro-application array to be loaded, the loading method of the micro-application queue further includes: If the task execution flag is loading in progress, the execution of the dequeue function is stopped until the task execution flag is changed to no loaded task.

4. A loading device for a micro-application queue, characterized in that: The main application used in the micro front-end architecture includes: A micro-application loading component construction module is used to construct a micro-application loading component, wherein the micro-application loading component includes an array of micro-applications to be loaded, an entry queue function, and an exit queue function; A request enqueue module, used to receive a micro-application loading request sent by a micro-application to be loaded, and call the enqueue function to load the micro-application loading request to the end of the micro-application array to be loaded; A request dequeue module is used to determine the task execution identifier corresponding to the micro-application array to be loaded. If the task execution identifier is that there is no loading task, the dequeue function is called to take out the target micro-application loading request at the head of the micro-application array to be loaded, and set the task execution identifier to be loading in progress; A loading execution module, used to call the loading execution function included in the target micro-application loading request, execute the target micro-application loading request and load the corresponding target micro-application; The device is also used for: Determine the loading result status code returned by the loading execution function; If the loading result status code indicates that the loading is successful, the task execution flag is set to loading completed, and the dequeue function is repeatedly called to take out the target micro-application loading request at the head of the micro-application array to be loaded, until the data in the micro-application array to be loaded is empty; The micro-application loading component construction module is specifically used to define the micro-application array to be loaded as an empty array, and set the task execution identifier as no loading task; configure a preset retry interval and a preset retry number threshold; construct a micro-queue object including the micro-application array to be loaded, the queue entry function and the queue exit function as the micro-application loading component; Call the load execution function included in the target micro-application load request, execute the target micro-application load request and load the corresponding target micro-application, specifically including: constructing a loaded micro-application list, wherein the loaded micro-application list stores the loaded micro-applications in the form of key-value pairs, the key is the identity or path corresponding to the loaded micro-application, and the value is the loaded micro-application instance; calling the load execution function to trigger the execution of the target micro-application load request, extracting the micro-application configuration information carried in the target micro-application load request, and searching for the target micro-application that matches the micro-application configuration information; calling the preset micro-application loading method in the micro-front-end framework, loading and initializing the target micro-application, and receiving the loaded micro-application instance returned by the preset micro-application loading method; parsing the loading result attribute corresponding to the loaded micro-application instance, and sending the loading result corresponding to the loading result attribute to the load execution function, and the load execution function generates the loading result status code according to the loading result.

5. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor and the memory communicate via the bus. When the machine-readable instructions are executed by the processor, the steps of the method for loading a micro-application queue as described in any one of claims 1 to 3 are performed.

6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed by a processor, executes the steps of the method for loading a micro-application queue as described in any one of claims 1 to 3.

Citation Information

Patent Citations

  • Micro-application pre-loading method and device

    CN112631679A

  • Preloading method and device, equipment and storage medium

    CN117667247A