Service transfer method and device, electronic equipment and storage medium

By setting dependency and data verification files in BFF, the problem of unstable forwarding of BFF service is solved, the accuracy and stability of data transmission are achieved, and the complexity of data processing logic is avoided.

CN120406937APending Publication Date: 2025-08-01BEIJING XIAOMI MOBILE SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410130203.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-01-30
Publication Date
2025-08-01

AI Technical Summary

Technical Problem

During the communication between the front-end and the back-end, BFF cannot effectively guarantee the health and stability of service forwarding, resulting in confusion in data summary processing logic and abnormal display.

Method used

By setting the dependency between service requests and back-end service functions in BFF, and verifying the target data based on the data verification file, ensuring data accuracy and completeness, avoiding data errors or missing.

Benefits of technology

It improves the stability of BFF's forwarding capabilities, avoids complex and redundant data processing logic, and ensures that the front-end receives correct data feedback.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120406937A_ABST
    Figure CN120406937A_ABST
Patent Text Reader

Abstract

The invention provides a service transfer method and device, electronic equipment and a storage medium. The service transfer method comprises the following steps: in response to a received service request sent by a front end, obtaining a dependency relationship and a data verification file of a target service function of a back end corresponding to the service request, the service request being used for requesting to call one or more service functions in the back end; calling target data corresponding to the target service function in the rear end, and verifying the target data based on the dependency relationship and the data verification file; and feeding back the verified target data to the front end. Through the service transfer method, the problem that corresponding feedback cannot be sent to the front end due to the fact that part of data in the called data is wrong or the corresponding data cannot be obtained is avoided, and the stability of the forwarding capability of the BFF is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of electronic devices, and in particular, to a service transfer method, apparatus, electronic device, and storage medium. Background Art

[0002] With the development of technology and user needs, there are more and more display ends of electronic devices, such as terminal web pages, personal computer (PC) web pages, PC clients, and application program ends of PCs. The page designs of different display ends are different, and the data they require is also different. Moreover, in order to achieve a better user interface (UI) rendering effect, a large amount of Polyfill code usually needs to be added. However, the snowball-like growth of the code may bring a mental burden to the subsequent continuous iteration of the business.

[0003] Therefore, by constructing an intermediate layer, the front end (i.e., the client) can be separated from the back end (i.e., the server end), so that the front end and the back end can each perform corresponding functions, thereby enabling more convenient access to the back-end services, reducing the real requests to the server end, and achieving cost reduction and efficiency improvement. This intermediate layer can be called the Backend For Frontend (BFF).

[0004] In related technologies, the front end can communicate with the BFF to receive the requests sent by the front end. Based on its own forwarding, aggregation, and other capabilities, the BFF processes the front-end requests, communicates with the APIs of the back end, obtains the corresponding data, and returns it to the front end after processing. However, for the data obtained corresponding to the requests forwarded by the BFF, it cannot guarantee the health and stability of the requests, and it is easy to cause chaos in the data aggregation processing logic, resulting in abnormal display on the display end. Summary of the Invention

[0005] To overcome the problems existing in related technologies, the present disclosure provides a service transfer method, apparatus, electronic device, and storage medium.

[0006] According to the first aspect of the embodiments of the present disclosure, a service transfer method is provided, including:

[0007] In response to receiving a service request sent by the front end, obtaining the dependency relationship and data verification file of the target service function corresponding to the back end of the service request, where the service request is used to request to call one or more service functions in the back end; calling the target data corresponding to the target service function in the back end, and verifying the target data based on the dependency relationship and the data verification file; and feeding back the verified target data to the front end.

[0008] In one implementation, the dependency includes a first dependency and a second dependency. The first dependency is used to represent a strong coupling relationship between the service function and the service request, and the second dependency is used to represent a weak coupling relationship between the service function and the service request. The data verification file contains all the key data corresponding to the target service function. Verifying the target data based on the dependency and the data verification file includes: obtaining, based on the data verification file, one or more first key data of the service function corresponding to the first dependency from all the key data, and obtaining one or more second key data of the service function corresponding to the second dependency from all the key data; verifying the target data based on the first key data and the second key data.

[0009] In one implementation, verifying the target data based on the first key data and the second key data includes: if the target data contains all the first key data and one or more of the second key data, the target data verification is successful; if the target data does not contain all the first key data and one or more of the second key data, the target data verification fails.

[0010] In one implementation, feeding back the verified target data to the front end includes: feeding back the target data with successful verification to the front end.

[0011] In one implementation, the method further includes: if the target data verification fails, sending a termination instruction to the front end.

[0012] In one implementation, obtaining the dependency and the data verification file of the target service function corresponding to the service request at the back end includes: obtaining, based on the database, the dependency corresponding to the service request and the data verification file. The database contains the dependency and the data verification file stored in advance.

[0013] In one implementation, the method further includes: in response to monitoring an update of the back-end address, obtaining the updated address of the back end and sending it to the front end.

[0014] In one implementation, the method further includes: setting, based on the permission setting function, a user for adjusting the dependency and the data verification file.

[0015] In one implementation, the method further includes: based on the alarm function, monitoring the service requests sent by the front end; if the service requests are abnormal or time out, triggering an alarm. According to the second aspect of the embodiments of the present disclosure, a service transfer device is provided, including:

[0016] An acquisition unit, configured to acquire the dependency relationship and data verification file of the target service function of the backend corresponding to the service request in response to receiving the service request sent by the front end, where the service request is used to request to invoke one or more service functions in the backend; a verification unit, configured to retrieve the target data corresponding to the target service function in the backend, and verify the target data based on the dependency relationship and the data verification file; a sending unit, configured to feedback the verified target data to the front end. In an implementation manner, the dependency relationship includes a first dependency relationship and a second dependency relationship, the first dependency relationship is used to represent a strong coupling relationship between the service function and the service request, the second dependency relationship is used to represent a weak coupling relationship between the service function and the service request, and the data verification file contains all key data corresponding to the target service function; the verification unit verifies the target data based on the dependency relationship and the data verification file in the following manner: based on the data verification file, acquire one or more first key data of the service function corresponding to the first dependency relationship included in all the key data, and acquire one or more second key data of the service function corresponding to the second dependency relationship included in all the key data; verify the target data based on the first key data and the second key data.

[0017] In an implementation manner, the verification unit verifies the target data based on the first key data and the second key data in the following manner: if the target data contains all the first key data and one or more of the second key data, the target data verification is successful; if the target data does not contain all the first key data and one or more of the second key data, the target data verification fails.

[0018] In an implementation manner, the sending unit feeds back the verified target data to the front end in the following manner, including: feeding back the target data with successful verification to the front end. In an implementation manner, the sending unit is further configured to: if the target data verification fails, send a termination instruction to the front end. In an implementation manner, the acquisition unit acquires the dependency relationship and data verification file of the target service function of the backend corresponding to the service request in the following manner: based on the database, acquire the dependency relationship and the data verification file corresponding to the service request, where the database contains the dependency relationship and the data verification file stored in advance.

[0019] In an implementation manner, the device further includes: an update unit, configured to acquire the updated address of the backend and send it to the front end in response to monitoring the update of the backend address.

[0020] In one implementation, the device includes: a permission management unit configured to set a user for adjusting the dependency relationship and the data verification file based on a permission setting function.

[0021] In one implementation, the device further includes: an alarm unit configured to monitor a service request sent by the front end based on an alarm function; and trigger an alarm if the service request is abnormal or times out.

[0022] According to a third aspect of the embodiments of the present disclosure, there is provided an electronic device, including:

[0023] a processor;

[0024] a memory for storing instructions executable by the processor;

[0025] wherein the processor is configured to execute the method described in the first aspect or any implementation manner of the first aspect.

[0026] According to a fourth aspect of the embodiments of the present disclosure, there is provided a storage medium storing instructions that, when executed by a processor of a terminal, enable the terminal to execute the service transfer method described in the first aspect or any implementation manner of the first aspect.

[0027] The technical solutions provided by the embodiments of the present disclosure may include the following beneficial effects: By setting the dependency relationship between the target service request and the backend target service function, and verifying the backend target data retrieved based on the service request according to the dependency relationship and the data verification file, it is possible to avoid problems such as partial data errors in the retrieved target data or failure to obtain partial data corresponding to the service request, resulting in the inability to send corresponding feedback to the front end, thereby improving the stability of the forwarding ability of the BFF and avoiding the problem of complex and redundant data processing logic caused by further decoupling of the BFF.

[0028] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and cannot limit the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] The accompanying drawings herein are incorporated into the specification and form a part of the specification, showing embodiments consistent with the present disclosure and used together with the specification to explain the principles of the present disclosure.

[0030] Figure 1 is a schematic diagram of an RPC call method shown according to an exemplary embodiment.

[0031] Figure 2 A schematic diagram of a PRC data transmission method shown according to an exemplary embodiment.

[0032] Figure 3Schematic diagram showing the implementation of BFF based on message queue according to an exemplary embodiment.

[0033] Figure 4 Schematic diagram showing the structural division of a BFF system according to an exemplary embodiment.

[0034] Figure 5 Flowchart of a service transfer method shown according to an exemplary embodiment.

[0035] Figure 6 Flowchart of a service transfer method shown according to an exemplary embodiment.

[0036] Figure 7 Flowchart of a service transfer method shown according to an exemplary embodiment.

[0037] Figure 8 Schematic diagram of the coverage path of a service transfer method shown according to an exemplary embodiment.

[0038] Figure 9 Schematic diagram of the functions of the application layer and the basic layer in a service transfer method shown according to an exemplary embodiment.

[0039] Figure 10 Schematic diagram of the system architecture corresponding to a service transfer method shown according to an exemplary embodiment.

[0040] Figure 11 Flowchart of a service transfer method shown according to an exemplary embodiment.

[0041] Figure 12 Flowchart of a service transfer method shown according to an exemplary embodiment.

[0042] Figure 13 Effect diagram of a service transfer method shown according to an exemplary embodiment.

[0043] Figure 14 Effect diagram of a service transfer method shown according to an exemplary embodiment.

[0044] Figure 15 Effect diagram of a service transfer method shown according to an exemplary embodiment.

[0045] Figure 16 Block diagram of a service transfer device shown according to an exemplary embodiment.

[0046] Figure 17 [[ID=~]]Block diagram of a device for service transfer shown according to an exemplary embodiment. Detailed implementation

[0047] Exemplary embodiments will be described in detail herein, and examples thereof are shown in the accompanying drawings. When the following description refers to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure.

[0048] With the development of electronic device technology, the same back-end system may need to be displayed on multiple types of electronic devices simultaneously. However, due to different requirements of the display devices, there may be significant differences in data acquisition and assembly on the front end. Moreover, the system can be divided into multiple different services according to functional modules, and each service only manages its own data, while the front-end display layer may require a combination of data from different services. Therefore, a BFF can be established to receive front-end requests, and the BFF aggregates and forwards the front-end requests to the back end, so that the back end can retrieve the data of the aggregated services, process it, and then return it to the front end.

[0049] Among them, the three most core parts of the BFF include: Distributed Remote Procedure Call (RPC), cache, and Message Queue (MQ). Figure 1 It is a schematic diagram of an RPC call method shown according to an exemplary embodiment. RPC can be understood as a call method. As Figure 1 shown, RPC can be based on the Transmission Control Protocol (TCP) or the Hypertext Transfer Protocol (HTTP) to obtain the results of the execution of a program running on a remote machine, so that the effect of calling a remote method can be achieved without difference from calling a local method. And Figure 2 It is a schematic diagram of a PRC data transmission method shown according to an exemplary embodiment. As Figure 2 shown, when transmitting data over a network, since the data to be transmitted must be binary data. Therefore, in the RPC framework, it is necessary to convert the parameters of the call request into transmittable binary data through reversible serialization and deserialization, so that the data can be transmitted over the network.

[0050] The BFF supports interface caching. When requests with the same attributes arrive, accessing the cache can effectively relieve the pressure on the downstream server. Among them, the pressure on the backend Central Processing Unit (CPU) and Input / Output (I / O) can be relieved through interface caching. For example, the running results can be stored, or the content that needs to be tried extremely can be calculated in advance, or the common data can be reused, thus saving CPU computing power. Or change the read and write access to slower media such as the network and disk to access to faster media such as memory, and change the read and write access to a single-point component (such as a database) to access to a scalable component (such as a cache middleware), thereby improving the response performance by the way.

[0051] The message queue in BFF mainly solves problems such as asynchronous messages and traffic peak shaving. Figure 3 A schematic diagram showing the implementation of functions of BFF based on a message queue according to an exemplary embodiment. As Figure 3 shown, when BFF receives multiple user requests at the same time, the requests can be written into the message queue, and then the backend service can process the requests at an appropriate time, thereby relieving the pressure brought by the instantaneous peak traffic, and thus realizing a high-performance, highly available, scalable and eventually consistent system architecture. However, in the related art, when BFF performs service forwarding, it lacks the ability to ensure the health and stability of service forwarding, and the data aggregation processing logic is complex and the risk is high. It can be understood that in the related art, when there are partial errors in all the backend data obtained by BFF based on the service request or some data corresponding to the request cannot be obtained, BFF will not be able to send the data corresponding to the request to the front end, resulting in an error display on the front end.

[0052] Therefore, in the embodiments of the present disclosure, a technical solution is provided: by setting the dependency relationship between the service request and one or more service functions of the backend in BFF, and verifying the backend data retrieved based on the service request based on the dependency relationship and the data verification file, so as to avoid the problem that there are partial data errors in the retrieved data or some data corresponding to the service request cannot be obtained, resulting in the inability to send the corresponding feedback to the front end, thereby improving the stability of the forwarding ability of BFF and avoiding the problem of complex and redundant data processing logic caused by further decoupling of BFF.

[0053] In the embodiments of the present disclosure, Figure 4 A schematic diagram showing the system structure division of BFF according to an exemplary embodiment. As Figure 4 shown, based on the related functions of BFF, the BFF system, that is Figure 4The shown rearview mirror system is divided into a basic layer, a basic service layer (bff-service), an application layer, i.e., a user management background service layer (bff-cms-server), and a management layer, i.e., a user management background (bff-cms). Among them, the basic layer can be used to implement communication functions, including communicating with the front end and other layers in the BFF. The application layer can be used to send service requests to the backend and receive data corresponding to the service requests sent by the backend. And the application layer can also be used to verify the data corresponding to the service requests. The management layer can be used for relevant technicians to configure dependency relationships and data verification files.

[0054] Figure 5 is a flowchart of a service transfer method shown according to an exemplary embodiment, as Figure 5 shown, the service transfer method includes the following steps.

[0055] In step S11, in response to receiving a service request sent by the front end, obtain the dependency relationship and data verification file of the target service function of the backend corresponding to the service request.

[0056] Among them, the service request is used to request to invoke the target service function corresponding to the service request in the backend. Among them, the target service function may include one or more service functions in the backend. Among them, the target service function can be understood as the function corresponding to the program of the backend for implementing the service request.

[0057] In the embodiments of the present disclosure, the BFF basic layer can receive the service request sent by the front end, and the BFF basic layer can send the service request to the BFF application, so that the BFF application layer performs subsequent operations based on the service request.

[0058] In the embodiments of the present disclosure, after the BFF basic layer receives the service request sent by the front end, it can determine the service function of the backend that needs to be invoked included in the service request. Among them, the service function can be one or more.

[0059] In the embodiments of the present disclosure, the BFF can send the information of one or more service functions of the backend that need to be invoked included in the service request to the BFF application layer.

[0060] In the embodiments of the present disclosure, the dependency relationship can be used to represent the coupling relationship between the service request and the backend service function. It can be understood that the dependency relationship can indicate whether the backend service function is necessary for implementing the service request.

[0061] In the embodiments of the present disclosure, a service request may correspond to one or more service functions at the backend. For example, for retrieving a book, the retrieval can be performed by retrieving the book title and the publication date of the book. Among them, the service function for obtaining the corresponding book title can be used as one dependency corresponding to the service request of retrieving the book, and the service function for obtaining the publication date of the book can be used as another dependency corresponding to the service request of retrieving the book. It can be understood that the dependency relationships between different service functions and service requests can be different. And the dependency relationships between the same service function and different service requests can be different.

[0062] In the embodiments of the present disclosure, a data verification file corresponds to a service request, and different service requests may have different data verification files. Among them, the data verification file contains key data for implementing one or more service functions of the service request. In one example, the key data of the service function can be the valid value corresponding to the service function. In another example, the key data of the service function can be the data point corresponding to the service function.

[0063] In step S12, the target data corresponding to the target service function in the backend is retrieved, and the target data is verified based on the dependency relationship and the data verification file.

[0064] In the embodiments of the present disclosure, the target data can be verified based on the dependency relationship and the data verification file, and the target data is sent to the BFF basic layer.

[0065] In the embodiments of the present disclosure, the BFF application layer can send a request to the backend to retrieve the data of the corresponding service function.

[0066] In step S13, the verified target data is fed back to the front end.

[0067] In the embodiments of the present disclosure, the BFF application layer can aggregate the data verified by the BFF basic layer into an API to form a complete data set and send it to the front end.

[0068] In the embodiments of the present disclosure, by setting the dependency relationship between the service request and one or more service functions at the backend in the BFF, and verifying the data retrieved from the backend based on the service request according to the dependency relationship and the data verification file, the problem that some of the retrieved data is incorrect or some data corresponding to the service request fails to be obtained, resulting in the inability to send the corresponding feedback to the front end, is avoided. Thus, the stability of the forwarding ability of the BFF is improved, and the problem of complex and redundant data processing logic caused by further decoupling of the BFF is avoided.

[0069] In the embodiments of the present disclosure, the dependency relationship may include different coupling relationships between a service request and a backend service function. Among them, the dependency relationship may include a strong coupling relationship between a service request and a backend service function and a weak coupling relationship between a service request and a backend service function. In the embodiments of the present disclosure, for convenience of description, the strong coupling relationship between a service request and a backend service function is referred to as a first dependency relationship, and the weak coupling relationship between a service request and a backend service function is referred to as a second dependency relationship.

[0070] In the embodiments of the present disclosure, a service request may correspond to one or more backend service functions. Therefore, it can be understood that there may be multiple different dependency relationships in a service request.

[0071] In the embodiments of the present disclosure, the service function corresponding to the first dependency relationship can be understood as the service function necessary to implement the service request, and the service function corresponding to the second dependency relationship can be understood as the service function non-necessary to implement the service request.

[0072] In the embodiments of the present disclosure, the data verification file may contain the key data of all service functions corresponding to the service request. Among them, one or more key data may be included in different services.

[0073] Figure 6 is a flowchart of a service transfer method shown according to an exemplary embodiment, as Figure 6 shown, the service transfer method includes the following steps.

[0074] In step S21, based on the data verification file, obtain one or more first key data whose all key data include the service function corresponding to the first dependency relationship, and obtain one or more second key data whose all key data include the service function corresponding to the second dependency relationship.

[0075] In the embodiments of the present disclosure, based on the dependency relationship, the key data corresponding to the first dependency relationship and the key data corresponding to the second dependency relationship in the data verification file can be determined.

[0076] In the embodiments of the present disclosure, the key data can be understood as that if the key data exists, the service function corresponding to the data is successfully executed. Otherwise, it is regarded as the service function execution fails or there is no corresponding service function.

[0077] In the embodiments of the present disclosure, the first key data can be understood as the key data of the service function necessary to implement the service request, and the second key data can be understood as the key data of the service function non-necessary to implement the service request.

[0078] In step S22, verify the target data based on the first key data and the second key data.

[0079] In the embodiments of the present disclosure, the backend target data can be compared with the data verification file based on the service request, so as to achieve the purpose of data verification. It can be understood that verifying the target data can be to compare the retrieved data with the first key data and the second key data, so as to determine whether the target data contains the first key data and the second key data.

[0080] In the embodiments of the present disclosure, by verifying the called data with the first key data and the second key data, the data contained in the target data is determined, so that it can be accurately judged whether the service function executes the corresponding function or whether there is a corresponding service function.

[0081] In the embodiments of the present disclosure, different called data correspond to different verification results.

[0082] Figure 7 It is a flowchart of a service transfer method shown according to an exemplary embodiment. As Figure 7 shown, the service transfer method includes the following steps.

[0083] In step S31, based on the data verification file, one or more first key data of the service functions corresponding to the first dependency relationship included in all the key data are obtained, and one or more second key data of the service functions corresponding to the second dependency relationship included in all the key data are obtained.

[0084] In step S32, the target data is verified based on the first key data and the second key data.

[0085] In step S331, if the target data contains all the first key data and one or more second key data, the target data verification is successful.

[0086] In step S332, if the target data does not contain all the first key data and one or more second key data, the target data verification fails.

[0087] In the embodiments of the present disclosure, steps S31, S32 are the same as steps S21 and S22, and will not be elaborated here.

[0088] In the embodiments of the present disclosure, if the target data contains all the first key data, it can be understood that the target data contains the key data of the service functions necessary to implement the service request.

[0089] In the embodiments of the present disclosure, if the target data contains one or more second key data, it can be understood that the target data contains the key data of the service functions that are not necessary to implement the service request.

[0090] In an embodiment of the present disclosure, only when all the first key data is included in the target data can it be determined that the data retrieval verification is successful. It can be understood that the influence of the second key data on the corresponding function of the service request is less than that of the first key data. Therefore, the verified and successful call data may not include the second key data, or may include one or more pieces of the second key data.

[0091] In an embodiment of the present disclosure, if all the first key data is not included in the target data, the verification of the called data fails, that is, the target data cannot implement the service request. For example, a book can be searched by determining the book title and the publisher, that is, the book title and the data publisher have a first dependency relationship for the service request of searching for a book. If the target data cannot include the key data about the book title and the key data about the book publisher at the same time, the corresponding book cannot be searched.

[0092] In an embodiment of the present disclosure, by verifying whether all the necessary data for implementing the service request is included in the target data, it is determined whether the target data can implement the service request. This avoids the situation where the target data lacks non-essential data for implementing the service request, resulting in the inability to send the corresponding data set to the front end, and further causing the front end to be unable to normally implement the function corresponding to the service request.

[0093] In an embodiment of the present disclosure, BFF can feedback the data with successful verification to the front end. For example, after the target data is successfully verified by the BFF application layer, the data with successful verification can be sent to the BFF basic layer, and the BFF basic layer aggregates the target data based on its aggregation ability and feedbacks it to the front end.

[0094] In an embodiment of the present disclosure, if the verification of the target data fails, a termination instruction is sent to the front end. For example, after the target data is verified as failed by the BFF application layer, the data with verification failure can be sent to the BFF basic layer, and the BFF basic layer sends a termination instruction to the front end, such as interrupting the front-end service.

[0095] In an embodiment of the present disclosure, BFF also includes a permission setting function, and among them, the permission management function can be included in the BFF management layer. As Figure 4 shown, the BFF management layer also includes a permission function. Among them, the permission function can be used to set the users who can be used to adjust the dependency relationship and the data verification file, and can also be used to set the objects that can be adjusted, including the dependency relationship and the data verification file. It can be understood that if a user is set to have permissions, the dependency relationship between the service request and one or more service functions of the back end can be adjusted. And the key data corresponding to the service function can also be adjusted.

[0096] In the embodiments of the present disclosure, the adjusted dependency relationship and the data verification file can be stored in a database. The database can be a database independent of the original BFF database. For example, the database can be a mongo database.

[0097] In the embodiments of the present disclosure, the BFF application layer can obtain the dependency relationship and the data verification file corresponding to the service request by retrieving the database. The database can store the dependency relationship and the data verification file preset by the user with set permissions in advance.

[0098] In the embodiments of the present disclosure, BFF can also be used to monitor the update of the backend address, obtain the updated backend address, and send it to the front end. It can be the BFF basic layer. As Figure 4 shown, there is system I / O (Input / Output) in the BFF basic layer. Through the system I / O, the updated backend address can be obtained and stored in the BFF, thus avoiding the need for the front end to restart to obtain backend data.

[0099] In one example, when the code in the local file is updated, a change can be captured by a Node File Watcher, and finally a certain shell script is executed to restart the service. However, in actual applications, if the startup port is 3000, the health check of the group system Matrix container is based on the externally exposed port 3000. Once there is a jitter, it may cause the container to restart. To prevent the container from restarting, it is necessary to dynamically update the routing stack at the JS runtime. Figure 8 It is a schematic diagram of the coverage path of a service transfer method shown according to an exemplary embodiment. Therefore, as Figure 8 shown, the basic layer can be built based on Koa. When the Node application program runs, the routing information will be pushed into the memory. When an upstream message is received, a local File file is generated and a corresponding routing information is generated at the same time, and updated to the routing stack of the current runtime, then the runtime hot update can be completed.

[0100] In the embodiments of the present disclosure, hot update can be understood as obtaining the address of the backend modification content and feeding back the address to the front end. Thus, it can avoid resource waste and also avoid service restart.

[0101] In the embodiments of the present disclosure, the BFF also includes an alarm function. As Figure 4 shown, the BFF management layer also includes an alarm function. When the BFF management layer monitors that the service request sent by the front end is abnormal or times out, an alarm is triggered.

[0102] In one example, the time usually configured for the Group SRE Nginx (Site Reliability Engineering) is generally 30s. Inside the BFF, the service timeout limit can be 5s. When the downstream service, such as the backend, takes more than 5s to process, the BFF management layer will trigger the timeout reconnection mechanism. When the second reconnection times out, the BFF management layer can, on the grounds of interface timeout, return an abnormal error code value and reason to the upstream, such as the frontend.

[0103] In the embodiments of the present disclosure, through the alarm function of the BFF management layer, the result corresponding to the service request can be accurately obtained, improving the user experience of the frontend.

[0104] In the embodiments of the present disclosure, the service transfer method will be described in combination with the following examples.

[0105] In the embodiments of the present disclosure, the centralized BFF layer centrally configures and maintains scattered traffic, reducing redundant waste of service resources. However, once there is a configuration exception or service exception, it may cause multiple services to become paralyzed. Therefore, multiple service functions can be divided in the overall BFF architecture design. Among them, external traffic is generally concentrated on the basic service, that is, the service layer. The basic service environment depends on local files to run, and the environment is relatively isolated. Changing the basic service configuration can only be controlled by the application service, that is, the application layer through one-way message passing.

[0106] In the embodiments of the present disclosure, the BFF can be divided into an application layer, a basic layer, and a management layer based on related BFF functions. Figure 9 It is a schematic diagram of the functions of the application layer and the basic layer in a service transfer method shown according to an exemplary embodiment. As Figure 9 shown, the application layer can be used to provide interface capabilities for the BFF and can implement interactions with the backend, that is, the downstream. The basic layer can be used to forward the aggregated service, that is, the aggregated data, to the frontend. In addition, the management side existing in the BFF can be used to configure dependency relationships and data verification files.

[0107] Figure 10 It is a schematic diagram of the system architecture corresponding to a service transfer method shown according to an exemplary embodiment. Figure 11 And Figure 12 It is a flowchart of a service transfer method shown according to an exemplary embodiment. As Figure 10 shown, the service transfer method can be implemented through the interaction between the application layer, the basic layer, and the management layer in the BFF. By Figure 10 、 Figure 11 And Figure 12Describe the service transfer method. The BFF basic layer (bff-service) can receive service requests sent by the front end. Among them, the service request can be a service request processed based on the relevant functions of the access layer. After receiving the service request, the basic layer can obtain the corresponding dependency relationship and data verification file from the database, such as a Mongo cluster. Among them, the dependency relationship and data verification file can be pre-stored in the server based on BFF-CMS. The application layer (bff-cms-server) can retrieve the corresponding data from the backend and verify the retrieved data based on the dependency relationship and data verification.

[0108] In the embodiments of the present disclosure, in the basic layer and the service layer, corresponding service requests can be stored based on the event queue, that is, the bff-service cluster or the bff-cms-server cluster, so as to improve the load balancing ability for large traffic and sudden traffic increase scenarios.

[0109] In the embodiments of the present disclosure, the service transfer method involved can be visually orchestrated, including GraphQL Editor and AntV G6, to detect whether each service function of BFF, that is, the application layer, the basic layer, and the management layer, is running normally. Among them, the visual orchestration can be a visual pipeline of input source, process processing, and result output generated based on AntV G6. In the process processing, a visual GraphQL Schema is implemented based on GraphQL Editor, and the service request is used as the data source to combine with GraphQLSchema for data recasting, and finally the API is exposed externally.

[0110] Figure 13 , Figure 14 and Figure 15 is an effect diagram of a service transfer method shown according to an exemplary embodiment. As Figure 13 shown, the built visual interface contains a file address. The display situation of this address determines whether data has been updated at the backend. As Figure 14 shown, the built visual interface contains domain name management. Among them, the domain name management column contains a domain name ID list and an environment list. The IDs in the domain name ID list are different, and the environment column is all production environments. Thus, it can be reflected that when searching, there are different dependency relationships. It can be understood that the environment has a strong dependency relationship with the service request, so the content searched out is all production environments. The domain name ID has a weak dependency relationship with the service request. Therefore, the domain name IDs searched out can be different. As Figure 15 shown, the built visual interface has user management, and through user management, users who can adjust the dependency relationship can be added or deleted.

[0111] Based on the same concept, embodiments of the present disclosure also provide a service transfer device.

[0112] It can be understood that, in order to implement the above functions, the service transfer device provided by the embodiments of the present disclosure includes the corresponding hardware structures and / or software modules for executing each function. Combining the units and algorithm steps of the various examples disclosed in the embodiments of the present disclosure, the embodiments of the present disclosure can be implemented in the form of hardware or a combination of hardware and computer software. Whether a certain function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the technical solution of the embodiments of the present disclosure.

[0113] Figure 16 is a block diagram of a service transfer device shown according to an exemplary embodiment. Referring to Figure 16 , the device 100 includes an acquisition unit 101, a verification unit 102, and a sending unit 103.

[0114] The acquisition unit 101 is configured to, in response to receiving a service request sent by the front end, acquire the dependency relationship and data verification file of the target service function corresponding to the service request, where the service request is used to request to call one or more service functions in the back end.

[0115] The verification unit 102 is configured to retrieve the target data corresponding to the target service function in the back end, and verify the target data based on the dependency relationship and the data verification file.

[0116] The sending unit 103 is configured to feedback the verified target data to the front end.

[0117] In one implementation, the dependency relationship includes a first dependency relationship and a second dependency relationship. The first dependency relationship is used to represent the strong coupling relationship between the service function and the service request, and the second dependency relationship is used to represent the weak coupling relationship between the service function and the service request. The data verification file contains all the key data corresponding to the target service function. The verification unit verifies the target data based on the dependency relationship and the data verification file in the following manner: based on the data verification file, acquire one or more first key data of the service function corresponding to the first dependency relationship among all the key data, and acquire one or more second key data of the service function corresponding to the second dependency relationship among all the key data; verify the target data based on the first key data and the second key data.

[0118] In one implementation, the verification unit verifies the target data based on the first key data and the second key data in the following manner: If the target data contains all the first key data and one or more second key data, the target data is successfully verified; if the target data does not contain all the first key data and one or more second key data, the target data verification fails.

[0119] In one implementation, the sending unit feeds back the verified target data to the front end in the following manner, including: feeding back the target data with successful verification to the front end. In one implementation, the sending unit is further configured to: if the target data verification fails, send a termination instruction to the front end. In one implementation, the obtaining unit obtains the dependency relationship and data verification file of the target service function corresponding to the service request in the following manner: based on the database, obtain the dependency relationship and data verification file corresponding to the service request, and the database contains the pre-stored dependency relationship and data verification file.

[0120] In one implementation, the device further includes: an update unit 104, configured to, in response to monitoring the update of the back-end address, obtain the updated address of the back end and send it to the front end.

[0121] In one implementation, the device includes: a permission management unit 105, configured to set a user for adjusting the dependency relationship and data verification file based on the permission setting function.

[0122] In one implementation, the device further includes: an alarm unit 106, configured to monitor the service request sent by the front end based on the alarm function; if the service request is abnormal or times out, trigger an alarm.

[0123] Regarding the device in the above embodiments, the specific manners in which each module performs operations have been described in detail in the embodiments related to the method, and will not be elaborated here.

[0124] Figure 17 It is a block diagram of a device 200 for service transfer shown according to an exemplary embodiment. For example, the device 200 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.

[0125] Refer to Figure 17 , the device 200 may include one or more of the following components: a processing component 202, a memory 204, a power component 206, a multimedia component 208, an audio component 210, an input / output (I / O) interface 212, a sensor component 214, and a communication component 216.

[0126] The processing component 202 generally controls the overall operation of the device 200, such as operations associated with display, phone calls, data communication, camera operations, and recording operations. The processing component 202 may include one or more processors 220 to execute instructions to complete all or part of the steps of the above - mentioned methods. In addition, the processing component 202 may include one or more modules to facilitate the interaction between the processing component 202 and other components. For example, the processing component 202 may include a multimedia module to facilitate the interaction between the multimedia component 208 and the processing component 202.

[0127] The memory 204 is configured to store various types of data to support the operation of the device 200. Examples of such data include instructions for any application or method operating on the device 200, contact data, phone book data, messages, pictures, videos, etc. The memory 204 can be implemented by any type of volatile or non - volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read - only memory (EEPROM), erasable programmable read - only memory (EPROM), programmable read - only memory (PROM), read - only memory (ROM), magnetic memory, flash memory, magnetic disk, or optical disk.

[0128] The power component 206 provides power to various components of the device 200. The power component 206 may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power for the device 200.

[0129] The multimedia component 208 includes a screen that provides an output interface between the device 200 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen can be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors can not only sense the boundaries of touch or swipe actions, but also detect the duration and pressure associated with the touch or swipe operations. In some embodiments, the multimedia component 208 includes a front - facing camera and / or a rear - facing camera. When the device 200 is in an operation mode, such as a shooting mode or a video mode, the front - facing camera and / or the rear - facing camera can receive external multimedia data. Each front - facing camera and rear - facing camera can be a fixed optical lens system or have focal length and optical zoom capabilities.

[0130] The audio component 210 is configured to output and / or input audio signals. For example, the audio component 210 includes a microphone (MIC) that is configured to receive external audio signals when the device 200 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals can be further stored in the memory 204 or transmitted via the communication component 216. In some embodiments, the audio component 210 further includes a speaker for outputting audio signals.

[0131] The I / O interface 212 provides an interface between the processing component 202 and peripheral interface modules, and the peripheral interface modules may be a keyboard, a click wheel, buttons, etc. These buttons can include but are not limited to: a home button, a volume button, a power button, and a lock button.

[0132] The sensor component 214 includes one or more sensors for providing status assessments of various aspects of the device 200. For example, the sensor component 214 can detect the on / off state of the device 200, the relative positioning of components, such as the display and keypad of the device 200. The sensor component 214 can also detect a change in the position of the device 200 or a component of the device 200, the presence or absence of user contact with the device 200, the orientation or acceleration / deceleration of the device 200, and the temperature change of the device 200. The sensor component 214 can include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor component 214 can also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor component 214 can further include an acceleration sensor, a gyro sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0133] The communication component 216 is configured to facilitate communication between the device 200 and other devices in a wired or wireless manner. The device 200 can access a wireless network based on communication standards, such as WiFi, 2G, or 3G, or a combination thereof. In an exemplary embodiment, the communication component 216 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 216 further includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.

[0134] In an exemplary embodiment, device 200 may be implemented by one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components for performing the above method.

[0135] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as memory 204 including instructions, and the above instructions can be executed by processor 220 of device 200 to complete the above method. For example, the non-transitory computer-readable storage medium may be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, and an optical data storage device, etc.

[0136] It can be understood that "a plurality of" in the present disclosure means two or more, and other quantifiers are similar thereto. "And / or" describes the association relationship of associated objects and indicates that three relationships may exist. For example, A and / or B may represent: A exists alone, A and B exist simultaneously, and B exists alone. The character " / " generally represents an "or" relationship between the associated objects before and after. The singular forms of "a", "the", and "said" are also intended to include the plural forms unless the context clearly indicates otherwise.

[0137] Furthermore, it can be understood that the terms "first", "second", etc. are used to describe various information, but this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other and do not represent a specific order or degree of importance. In fact, the expressions such as "first" and "second" can be used interchangeably. For example, without departing from the scope of the present disclosure, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information.

[0138] Furthermore, it can be understood that the orientation or positional relationship indicated by the terms "center", "longitudinal", "transverse", "front", "rear", "upper", "lower", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", etc. is based on the orientation or positional relationship shown in the drawings, and is only for the convenience of describing this embodiment and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation.

[0139] Furthermore, it can be understood that unless otherwise specified, "connection" includes direct connection between two without other components therebetween, and also includes indirect connection between two with other elements therebetween.

[0140] It can be further understood that although the operations are described in a specific order in the drawings in the embodiments of the present disclosure, it should not be construed as requiring the operations to be performed in the specific order shown or in a serial order, or requiring all the operations shown to obtain the desired result. In certain environments, multitasking and parallel processing may be advantageous.

[0141] Those skilled in the art will readily conceive of other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure, which follow the general principles of the present disclosure and include well-known knowledge or conventional technical means in the technical field not disclosed in the present disclosure.

[0142] It should be understood that the present disclosure is not limited to the exact structures described above and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present disclosure is only limited by the appended claims.

Claims

1. A service transfer method, characterized in that, Including: In response to receiving a service request sent by the front end, obtain the dependency relationship and data verification file of the target service function corresponding to the backend of the service request, where the service request is used to request to invoke one or more service functions in the backend; Invoke the target data corresponding to the target service function in the backend, and verify the target data based on the dependency relationship and the data verification file; Feed back the verified target data to the front end.

2. The service transfer method according to claim 1, wherein The dependency relationship includes a first dependency relationship and a second dependency relationship. The first dependency relationship is used to represent the strong coupling relationship between the service function and the service request, and the second dependency relationship is used to represent the weak coupling relationship between the service function and the service request. The data verification file contains all the key data corresponding to the target service function; The verifying the retrieved data based on the dependency relationship and the data verification file includes: Based on the data verification file, obtain one or more first key data of the service function corresponding to the first dependency relationship among all the key data, and obtain one or more second key data of the service function corresponding to the second dependency relationship among all the key data; Verify the target data based on the first key data and the second key data.

3. The method according to claim 2, wherein The verifying the target data based on the first key data and the second key data includes: If the target data contains all the first key data and one or more of the second key data, the target data verification is successful; If the target data does not contain all the first key data and one or more of the second key data, the target data verification fails.

4. The method according to any one of claims 1 to 3, characterized in that The feeding back the verified target data to the front end includes: Feed back the data with successful verification to the front end.

5. The method according to claim 4, wherein The method further includes: If the target data verification fails, send a termination instruction to the front end.

6. The method according to claim 1, wherein The obtaining the dependency relationship and data verification file between the target service functions corresponding to the service request of the backend includes: Based on the database, obtain the dependency relationship and the data verification file corresponding to the service request. The database contains the pre-stored dependency relationship and the data verification file.

7. The method according to claim 1, characterized in that The method further includes: In response to monitoring the update of the backend address, obtain the updated address of the backend and send it to the front end.

8. The method according to claim 1, wherein The method further includes: Based on the permission setting function, set the user for adjusting the dependency relationship and the data verification file.

9. The method according to claim 1, wherein The method further includes: Based on the alarm function, monitor the service request sent by the front end; If the service request is abnormal or times out, trigger an alarm.

10. A service transfer device, characterized in that, Including: An obtaining unit, configured to, in response to receiving a service request sent by the front end, obtain the dependency relationship and data verification file of the target service function corresponding to the backend of the service request, where the service request is used to request to invoke one or more service functions in the backend; A verifying unit, configured to control the invocation of the target data corresponding to the target service function in the backend, and verify the target data based on the dependency relationship and the data verification file; A sending unit, configured to feed back the verified target data to the front end.

11. An electronic device, characterized in that, Comprising: A processor; A memory for storing instructions executable by the processor; Wherein, the processor is configured to execute the service transfer method according to any one of claims 1-9.

12. A storage medium, characterized in that, Instructions are stored in the storage medium, and when the instructions in the storage medium are executed by a processor of a terminal, the terminal is enabled to execute the method according to any one of claims 1-9.