Function sharing system, method, apparatus, device, medium, and product
Patent Information
- Application Number
- CN202510238921.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-28
- Publication Date
- 2026-08-28
AI Technical Summary
[0004]然而,上述方法在实现的过程中,当内核代码存在更新时,代码提供方服务器需要将新版本的内核代码发布至共享仓库,然后代码消费方服务器各自从共享仓库获取最新的内核代码以对本地维护的内核代码进行更新,并需要同步更新对应的构造函数,存在更新成本高,更新效率低的问题
[0019] When a kernel provider server shares functionality with a kernel consumer server, the kernel provider server creates a shared file of the functional kernel based on the kernel constructor of the functional kernel it maintains. The kernel consumer server obtains the shared file of the functional kernel provided by the kernel provider server, instantiates the functional kernel through the kernel constructor in the shared file, and thus provides the second functional service to the second client, realizing functional sharing between servers. In this process, after the functional kernel maintained by the kernel provider server is updated, the functional kernel called by the shared file obtained by the kernel consumer server when providing the second functional service to the second client is also the latest. Therefore, the second functional service that relies on the functional kernel provided by the kernel provider server can achieve seamless upgrades, avoiding the problem in traditional solutions where both the server acting as the sharing provider and the server acting as the sharing consumer need to be updated independently, thus improving the update efficiency of functional services.
Smart Images

Figure CN122653641A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of Internet technology, and in particular to a function-sharing system, method, apparatus, equipment, medium and product. Background Technology
[0002] When providing functional services to users, different projects in an application use different frameworks, leading to code resource reuse in order to reduce development costs. For example, an application may provide a Rich Text Editor (RTE) in multiple functional projects to offer users visual text editing capabilities.
[0003] In related technologies, the code provider server publishes the kernel code of the rich text editor to a shared repository (e.g., a Git repository or a Node Package Manager (NPM) repository). The code consumer server, which needs to use the rich text editor, associates with the shared repository, obtains the kernel code of the rich text editor from the shared repository, and maintains the kernel code locally on the code consumer server. When the code consumer server provides editor functionality services to the client, it instantiates the kernel code through the constructor maintained locally, and provides editor functionality services to the client through the obtained instance.
[0004] However, in the implementation of the above method, when the kernel code is updated, the code provider server needs to publish the new version of the kernel code to the shared repository. Then, the code consumer servers each obtain the latest kernel code from the shared repository to update the kernel code they maintain locally, and also need to update the corresponding constructors synchronously. This results in high update costs and low update efficiency. Summary of the Invention
[0005] This application provides a function-sharing system, method, apparatus, device, medium, and product. The technical solution is as follows:
[0006] On the one hand, a function sharing system is provided, the system including a kernel providing server and a kernel consuming server, the kernel providing server being a server that provides functional kernels, and the kernel consuming server being a server that consumes the functional kernels;
[0007] The kernel provides a server for providing a first functional service to a first client based on the functional kernel; and for creating a shared file of the functional kernel, the shared file including a kernel constructor corresponding to the functional kernel, the kernel constructor being used to instantiate the functional kernel;
[0008] The kernel consumer server is used to obtain the shared file of the functional kernel from the kernel provider server; and to provide a second functional service to the second client by calling the functional kernel shared by the kernel provider server through the kernel constructor.
[0009] On the other hand, a function sharing method is provided, which is executed by a kernel consumer server, the method comprising:
[0010] The kernel provider server obtains a shared file of the functional kernel, the shared file including the kernel constructor corresponding to the functional kernel, the kernel constructor being used to instantiate the functional kernel, and the kernel provider server being used to provide a first functional service to the first client based on the functional kernel and to create the shared file of the functional kernel;
[0011] The kernel constructor calls the kernel to provide the functional kernel shared by the server, thus providing a second functional service to the second client.
[0012] On the other hand, a function-sharing device is provided, the device comprising:
[0013] The acquisition unit is used to acquire a shared file of a functional kernel from a kernel provider server. The shared file includes a kernel constructor corresponding to the functional kernel. The kernel constructor is used to instantiate the functional kernel. The kernel provider server is used to provide a first functional service to a first client based on the functional kernel and to create the shared file of the functional kernel.
[0014] The processing unit is used to call the kernel through the kernel constructor to provide the functional kernel shared by the server, and to provide the second functional service to the second client.
[0015] On the other hand, a computer device is provided, the computer device including a processor and a memory, the memory storing at least one instruction, at least one program, code set or instruction set, the at least one instruction, the at least one program, the code set or instruction set being loaded and executed by the processor to implement the function sharing method as described in any of the embodiments of this application above.
[0016] On the other hand, a computer-readable storage medium is provided, wherein at least one instruction, at least one program, code set, or instruction set is stored therein, wherein the at least one instruction, the at least one program, the code set, or the instruction set is loaded and executed by a processor to implement the function sharing method as described in any of the embodiments of this application above.
[0017] On the other hand, a computer program product or computer program is provided, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform any of the function-sharing methods described in the above embodiments.
[0018] The technical solution provided in this application includes at least the following beneficial effects:
[0019] When a kernel provider server shares functionality with a kernel consumer server, the kernel provider server creates a shared file of the functional kernel based on the kernel constructor of the functional kernel it maintains. The kernel consumer server obtains the shared file of the functional kernel provided by the kernel provider server, instantiates the functional kernel through the kernel constructor in the shared file, and thus provides the second functional service to the second client, realizing functional sharing between servers. In this process, after the functional kernel maintained by the kernel provider server is updated, the functional kernel called by the shared file obtained by the kernel consumer server when providing the second functional service to the second client is also the latest. Therefore, the second functional service that relies on the functional kernel provided by the kernel provider server can achieve seamless upgrades, avoiding the problem in traditional solutions where both the server acting as the sharing provider and the server acting as the sharing consumer need to be updated independently, thus improving the update efficiency of functional services. Attached Figure Description
[0020] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 This is a structural block diagram of a function-sharing system provided in an exemplary embodiment of this application;
[0022] Figure 2 This is a flowchart of a function sharing method provided in an exemplary embodiment of this application;
[0023] Figure 3 This is a data interaction diagram between devices in a function-sharing system provided by an exemplary embodiment of this application;
[0024] Figure 4 This is a schematic diagram of an editor function sharing system provided in an exemplary embodiment of this application;
[0025] Figure 5This is a schematic diagram of a mobile terminal page provided in an exemplary embodiment of this application;
[0026] Figure 6 This is a schematic diagram of a PC-side page provided in an exemplary embodiment of this application;
[0027] Figure 7 This is a schematic diagram of a web page provided in an exemplary embodiment of this application;
[0028] Figure 8 This is a timing diagram of device data interaction in an editor function sharing system provided in an exemplary embodiment of this application;
[0029] Figure 9 This is a structural block diagram of a function-sharing device provided in an exemplary embodiment of this application;
[0030] Figure 10 This is a schematic diagram of the structure of a server provided in an exemplary embodiment of this application. Detailed Implementation
[0031] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0032] In this application, the terms "first" and "second" are used to distinguish between identical or similar items that have essentially the same function. It should be understood that there is no logical or temporal dependency between "first" and "second", nor is there any limitation on the quantity or execution order.
[0033] First, a brief introduction to the terms used in the embodiments of this application will be given.
[0034] Kernel: This refers to the core component or infrastructure of a business function. It is responsible for implementing and managing the basic functions and core logic of the business function. The kernel is the core part of the business function, typically possessing a high degree of abstraction and generality, providing basic support and interfaces for functional extensions to upper-layer applications. The kernel usually consists of: a core module (implementing the core functions and logic of the business function); an interface module (providing interfaces for interaction with external systems or users); a resource management module (managing the resources required by the business function); and an extension module (supporting plugins or extensions, allowing users to customize business functions according to their needs).
[0035] Figure 1A structural block diagram of a function-sharing system 100 provided in an exemplary embodiment of this application is shown. The function-sharing system 100 includes: a first terminal 110, a second terminal 120, a kernel providing server 130, and a kernel consuming server 140.
[0036] The first terminal 110 runs an application with a first client. Optionally, the first client can be a game application, a social application, an e-commerce application, an audio / video application, a browser, etc.
[0037] The second terminal 120 runs a second client application. Optionally, the first client can be a game application, a social application, an e-commerce application, an audio / video application, a browser, etc.
[0038] Optionally, the first client and the second client can be clients provided by the same application for different platforms. For example, the first client and the second client can be at least two of a PC client, a mobile client, and an external browser client. Alternatively, they can be different clients provided for different applications. For example, the first client can be a client for a social application, and the second client can be a client for an audio or video application. This is not limited here.
[0039] In some embodiments, the first terminal 110 and the second terminal 120 can be implemented as different terminal devices or as the same terminal device, that is, the first client and the second client can run on one terminal device.
[0040] Optionally, the device types of the first terminal 110 and the second terminal 120 include at least one of the following: game console, desktop computer, smartphone, tablet computer, extended reality device, e-book reader, Moving Picture Experts Group Audio Layer III (MP3) player, Moving Picture Experts Group Audio Layer IV (MP4) player, and laptop computer.
[0041] The kernel provides server 130 to provide first functional services to the first client. Optionally, the first functional services include editor functional services, cropping functional services, drawing functional services, image insertion functional services, etc.
[0042] The kernel-providing server 130 includes at least one of a single server, multiple servers, a cloud computing platform, and a virtualization center. The kernel-providing server 130 establishes a communication connection with the first terminal 110. Optionally, the kernel-providing server 130 undertakes the primary computing task, and the first terminal 110 undertakes the secondary computing task; or, the kernel-providing server 130 undertakes the secondary computing task, and the first terminal 110 undertakes the primary computing task; or, the kernel-providing server 130 and the first terminal 110 collaborate on computing using a distributed computing architecture.
[0043] In this embodiment, the kernel providing server 130 maintains a functional kernel for the first functional service. This functional kernel provides code-level logic support for the implementation of the first functional service; that is, it is responsible for handling the basic functions and core logic of the first functional service and is a core component or infrastructure for implementing the first functional service. Illustratively, the kernel providing server 130 provides the first functional service to the first client by calling the shared functional kernel of the kernel providing server 130.
[0044] The kernel consumer server 140 is used to provide second functional services to the second client. Optionally, the second functional services include editor functional services, cropping functional services, drawing functional services, image insertion functional services, etc.
[0045] The kernel consumer server 140 includes at least one of a single server, multiple servers, a cloud computing platform, and a virtualization center. The kernel consumer server 140 establishes a communication connection with the second terminal 120. Optionally, the kernel consumer server 140 undertakes the primary computing task, and the second terminal 120 undertakes the secondary computing task; or, the kernel consumer server 140 undertakes the secondary computing task, and the second terminal 120 undertakes the primary computing task; or, the kernel consumer server 140 and the second terminal 120 collaborate on computing using a distributed computing architecture.
[0046] The first functional service and the second functional service have the same service type. In this embodiment, the service type of the first functional service and the second functional service is implemented as the editor function type for illustrative purposes.
[0047] In one example, when the first client and the second client are implemented as clients provided by the same application for different platforms, taking the first client as a PC client and the second client as a mobile client as an example, the first functional service is implemented as the editor function service provided for the account information modification interface in the PC client, and the second functional service is implemented as the editor function service provided for the account information modification interface in the mobile client.
[0048] In another example, when the first client and the second client implement different clients for different applications, taking the first client as a client for a social application and the second client as a client for an audio / video application as an example, the first functional service is the editor function service provided for the account information modification interface in the social application client, and the second functional service is the editor function service provided for the movie / video information modification interface in the audio / video application client.
[0049] It is worth noting that the kernel providing server 130 and kernel consuming server 140 mentioned above can be implemented as physical servers, cloud servers in the cloud, or nodes in a blockchain system.
[0050] Those skilled in the art will understand that the number of the aforementioned devices can be more or less. For example, there may be only one device, or there may be dozens or hundreds of devices, or even more. This application does not limit the number or type of devices.
[0051] In one example, kernel provider server 130 connects to multiple first terminals 110, and kernel consumer server 140 connects to multiple second terminals 120. In another example, kernel provider server 130 connects to multiple kernel consumer servers 140 to provide function sharing to the multiple kernel consumer servers 140.
[0052] Please refer to Figure 2 The diagram illustrates a flowchart of a function sharing method provided in an exemplary embodiment of this application, which is executed by a kernel consumer server 140 in a function sharing system 100, and includes steps 210 to 220.
[0053] Step 210: Obtain the shared files of the functional kernel from the kernel provider server.
[0054] The shared files of the functional kernel include the kernel constructor corresponding to the functional kernel. The kernel constructor is used to instantiate the functional kernel. The kernel provider server is used to provide the first functional service to the first client based on the functional kernel and to create the shared files of the functional kernel.
[0055] Schematic illustration: The kernel provides a server to offer a first functional service to a first client, and the kernel consumes a server to offer a second functional service to a second client. The second functional service and the first functional service have the same service type. Optionally, the first / second functional service may include editor functional services, cropping functional services, drawing functional services, image insertion functional services, etc.
[0056] In this embodiment, the kernel providing server is the provider of shared functionality, and the kernel consuming server is the consumer of shared functionality. That is, the capabilities provided by the functional kernel of the first functional service maintained by the kernel providing server can be shared with the kernel consuming server. The aforementioned functional kernel is used to provide code-level logic support for the implementation of the first functional service; that is, the functional kernel is responsible for handling the basic functions and core logic of the first functional service and is the core component or infrastructure for implementing the first functional service.
[0057] In some embodiments, the first functional service and the second functional service are implemented as functional services based on web services, wherein a web service is a network-based service that provides interactive services for functions or data on the network through web technologies and standard protocols.
[0058] Optionally, the aforementioned standard protocols include HyperText Transfer Protocol (HTTP), HyperText Transfer Protocol Secure (HTTPS), and other protocols.
[0059] Optionally, the kernel provider server can provide function sharing to a single kernel consumer server or to multiple kernel consumer servers.
[0060] Optionally, the shared file includes the kernel constructor of the functional kernel; or, the shared file includes the functional kernel and the kernel constructor of the functional kernel.
[0061] In this embodiment of the application, the kernel consumer server, in response to the first client's service request for the first functional service, obtains the shared files of the functional kernel from the kernel provider server.
[0062] As an illustration, the second client sends a service request to the kernel consumer server, and the kernel consumer server responds by receiving the service request and obtaining the shared files of the kernel provided by the kernel provider server.
[0063] Optionally, the second client triggering the sending of the service request can be implemented in at least one of the following ways:
[0064] 1. Open the function page
[0065] In illustrative terms, in response to the second client receiving a page opening request for a functional page, a service request is sent to the kernel consumer server, whereby the aforementioned functional page is used to provide the second functional service.
[0066] In one example, taking the second function service as the editor function service provided by the account information modification interface, in response to the second client receiving the page opening operation of the account information modification interface, the second client sends a service request to the kernel consumption server so that the kernel consumption server can obtain the shared file and provide the editor function service to the second client.
[0067] 2. Function page refresh
[0068] In illustrative terms, in response to the second client receiving a page refresh request from the functional page, a service request is sent to the kernel consumer server. The aforementioned functional page is used to provide the second functional service.
[0069] In one example, taking the second function service as the editor function service provided by the account information modification interface, the second client displays the account information modification interface. When the second client receives a page refresh operation, the second client sends a service request to the kernel consumption server so that the kernel consumption server can obtain the latest shared file and provide the latest editor function service to the second client.
[0070] 3. Second client update
[0071] As an illustration, in response to the completion of the second client's update, a service request is sent to the kernel consumer server, and the aforementioned functional page is used to provide the second functional service.
[0072] In some embodiments, the second functional service is a general functional service provided by the second client to the user. When the second client performs a client update, the second client sends a service request to the kernel consumer server to reacquire the second functional service.
[0073] In one example, taking the second client as a browser, the second functional service is the editor function service in the browser used to provide the URL input area. After the browser finishes updating, the browser sends a service request to the kernel consumer server so that the kernel consumer server can obtain the latest shared files and provide the latest editor function service to the browser's URL input area.
[0074] Alternatively, the method for obtaining shared files can be implemented in at least one of the following ways:
[0075] The first type involves shared files that the kernel consumer server obtains directly from the kernel provider server.
[0076] To illustrate, the kernel consumer server sends a data retrieval request based on the Hypertext Transfer Protocol (HTTP) to the kernel provider server; in response to the data retrieval request, it sends a shared file to the kernel consumer server based on the HTTP protocol.
[0077] In some embodiments, the kernel consumer server initiates an HTTP request to the kernel provider server to request a shared file. In one example, the process of initiating the HTTP request includes: the kernel consumer server determining the Uniform Resource Locator (URL) of the shared file, which specifies the address, path, and filename of the kernel provider server where the shared file is located; constructing an HTTP request based on the URL of the shared file; and sending the HTTP request over the network to the kernel provider server.
[0078] The second type of function-sharing system also includes an intermediary server. After the kernel provides the shared files to the intermediary server, the kernel consumes the files obtained from the intermediary server.
[0079] To illustrate, the kernel server publishes shared files to the intermediary server; the intermediary server stores the received shared files; the kernel consumer server sends a data retrieval request to the intermediary server based on the Hypertext Transfer Protocol; and the intermediary server responds to the data retrieval request by sending the shared files to the kernel consumer server based on the Hypertext Transfer Protocol.
[0080] The aforementioned intermediary server is used to provide data distribution services. In one example, the intermediary server can be implemented as a Content Delivery Network (CDN) server. A CDN is a technology and service used to optimize internet content distribution. It improves content loading speed, availability, and reliability by caching content on servers located in multiple geographical locations globally, while reducing the load on the origin server. Specifically, when multiple kernel consumer servers are distributed across different geographical locations, shared files can be stored through a CDN server to reduce the load on the kernel provider server.
[0081] In some embodiments, the kernel consumer server initiates an HTTP request to the intermediary server to request a shared file. In one example, the process of initiating the HTTP request includes: the kernel consumer server determining the URL of the shared file, which specifies the address, path, and filename of the intermediary server where the shared file is located; constructing an HTTP request based on the URL of the shared file; and sending the HTTP request to the intermediary server over the network.
[0082] Step 220: The kernel constructor is used to call the kernel to provide the server-shared kernel functionality, thus providing the second functional service to the second client.
[0083] Alternatively, the kernel consumer server can implement the kernel function by calling the kernel constructor as at least one of the following:
[0084] In the first scenario, when the shared file includes a functional kernel, the kernel consuming server obtains the functional kernel through the shared file, calls the functional kernel through the kernel constructor, and provides the second functional service to the second client.
[0085] In other words, when a functional kernel is provided in the shared file, the kernel consuming server can directly obtain the functional kernel from the shared file for invocation.
[0086] In some embodiments, when the shared file has referenced the functional kernel code in the kernel constructor during the generation process, the kernel consumer server obtains the core capabilities of the first functional service by running the kernel constructor, thereby enabling the provision of the second functional service to the second client.
[0087] Configuring a functional kernel in a shared file can reduce the number of data interactions between kernel consuming servers and kernel providing servers, thus avoiding the waste of resources transferred between servers.
[0088] The second approach involves providing a second functional service to a second client when the shared file does not include a functional kernel. This is achieved by the kernel consumer server remotely calling the functional kernel in the kernel provider server through the kernel constructor.
[0089] In other words, when a functional kernel is not provided in the shared file, the kernel consuming server can invoke the functional kernel in the kernel providing server via remote call.
[0090] In some embodiments, when a shared file is generated by referencing a directory address in the kernel server provided by the kernel functional kernel, the kernel consumer server obtains the core capabilities of the first functional service through remote calls during the kernel constructor execution, thereby enabling the provision of the second functional service to the second client.
[0091] Optionally, the remote call can be implemented by obtaining the functional kernel for local instantiation; or, it can be implemented by using the kernel consumer server as a proxy for the kernel provider server, with the kernel consumer server forwarding the data processing requests for the second functional service from the second client to the kernel provider server, and the kernel provider server implementing the data processing process indicated by the data processing request through the functional kernel.
[0092] In one example, a Remote Procedure Call (RPC) implementation is used: RPC is a technology that allows a program running on one device to call a program running on another device. Schematic, an RPC interface is defined between the kernel provider server and the kernel consumer server. The kernel provider server implements the service logic defined in the RPC interface through a functional kernel. When the kernel provider server starts the RPC service, the kernel consumer server can call the functional kernel in the kernel provider server through the RPC interface. Optionally, the kernel consumer server can obtain the functional kernel itself through the RPC interface.
[0093] By enabling remote calls to invoke the functional kernel, the kernel provider server does not need to expose the functional kernel to the kernel consumer server, thus ensuring the security of the functional kernel.
[0094] In this embodiment, the kernel consumer server is instantiated through a kernel constructor to provide a second functional service to the second client. Illustratively, the kernel consumer server instantiates a functional kernel through the kernel constructor to obtain a first functional instance; the second functional service is then provided to the second client through the first functional instance.
[0095] In this context, an instance refers to a specific object created based on a class. A class is an abstract template that defines the structure of a group of objects with the same attributes (variables) and methods (functions). Each instance has its own state (attribute values) but shares the class's methods. Instantiation refers to the process of calling the class's constructor. In this embodiment, when the kernel consumer server provides the second functional service to the second client, instantiation is achieved through the kernel constructor of the first functional service.
[0096] Indicatively, the instantiation process through the kernel constructor includes: when the kernel constructor is called, the kernel consumer server allocates memory space for the second functional service, calls the kernel constructor to initialize the member variables of the object (instance), sets the initial state of the object (including properties and methods), and obtains the first functional instance.
[0097] In some embodiments, the kernel provides a functional component locally maintained on the server corresponding to a second functional service. This functional component encapsulates at least one sub-function of the second functional service. The instantiation process of the functional kernel can then be implemented within the functional component. Illustratively, the functional component corresponding to the second functional service is obtained; the kernel constructor is imported into the functional component; the kernel constructor is called within the functional component to instantiate the functional kernel, resulting in a first functional instance; the second functional service is provided to the second client through the first functional instance.
[0098] Among them, the functional components of the second function service are components maintained in the kernel consumer server to implement the second function service, and can be implemented as independent, reusable code units.
[0099] In one example, the instantiation process of implementing the functional kernel in a functional component is as follows: import the kernel constructor into the functional component, create an empty instance within the functional component; bind the empty instance to the kernel constructor, execute the code in the kernel constructor to initialize the properties and methods in the empty instance, and obtain the first functional instance.
[0100] For example, an empty instance is created using the first keyword, implemented as the "new" keyword in one example. The "new" keyword is used to allocate memory to create the empty instance. The empty instance is then bound to the kernel constructor using the second keyword, implemented as the "this" keyword in one example. The "this" keyword is used to call the kernel constructor. For instance, taking an editor function as an example, the instantiation of the functional kernel is achieved through the code "this.kernel = new EditorKernel()", where "new EditorKernel()" calls the kernel constructor to create an instance corresponding to the functional kernel and stores it in "this.kernel".
[0101] In some embodiments, when there is a difference between the services corresponding to the first functional service and the second functional service, the kernel consumer server further performs service extension on the first functional instance to obtain the second functional instance, and provides the second functional service to the second client through the second functional instance.
[0102] When the instantiation process of the functional kernel is implemented in the functional component, the business extension is also implemented in the functional component. For example, within the functional component, business extension is performed on the first functional instance to obtain a second functional instance, which then provides the second functional service to the second client.
[0103] Business extension refers to adding new functionality or behavior to the first functional instance without modifying the original class definition. Optionally, business extension can be implemented as at least one of the following:
[0104] • Inheritance: Creates a new class (subclass) that inherits all the attributes and methods of the parent class (the class corresponding to the core functionality of the first service), and can add new attributes and methods or override the parent class's methods;
[0105] • Composition: Functionality extension is achieved by using an instance of one class (e.g., the class corresponding to the functional kernel of the first functional service) as an attribute of another class (e.g., the class corresponding to the kernel maintained by the kernel consumer server itself).
[0106] • Decorator: Dynamically attaches new functionality (e.g., functionality implemented by the kernel kernel maintained by the kernel consumer server itself) to an object (e.g., an instance obtained after instantiating the kernel kernel of the first functional service) without changing its structure;
[0107] • Interfaces or abstract classes: Extend functionality by implementing interfaces or inheriting abstract classes;
[0108] • Dynamically add properties and methods: Add properties and methods directly to the instance when the first functional instance is run.
[0109] In one example, taking the business extension implementation as combining at least one sub-function provided by the kernel consumer server locally for the second function service with the function provided by the kernel provider server, it is illustrated that the kernel of the sub-function of at least one sub-function is instantiated to obtain the third function instance; the first function instance and the third function instance are combined to obtain the second function instance.
[0110] When the instantiation process of the functional kernel is implemented in the functional component, the functional component includes at least one sub-functional kernel corresponding to a sub-function; the kernel consumer server instantiates the sub-functional kernel of at least one sub-function within the functional component to obtain a third functional instance; the first functional instance and the third functional instance are combined to obtain a second functional instance.
[0111] In other words, based on the first functional instance obtained by instantiating the functional kernel of the first functional service, business expansion is carried out according to the business requirements of the second functional service, so that the second functional instance used for the second functional service can meet the business requirements of the second functional service. At the same time, it supports the business growth of the second functional service provided by the kernel consumption server to the second client, and can provide different business resources in different business scenarios.
[0112] In some embodiments, the kernel consumer server acquires shared files by creating a receive file. Illustratively, the kernel consumer server creates a receive file, which is used to load external resources; the shared file is then loaded from the kernel provider server within the receive file. That is, the kernel consumer server creates a receive file; obtains the shared file from the kernel provider server; and stores the shared file in the receive file.
[0113] This illustration demonstrates how a module loader is used within the receiving file to retrieve shared files. The module loader is a component in the runtime environment used to load, parse, and initialize modules. Its core function is to load module code into the runtime environment and ensure that dependencies between modules are handled correctly. The module loader is used within the receiving file to retrieve shared files provided by the kernel-provided server via a specified data communication protocol.
[0114] In some embodiments, the kernel consumer server exports the kernel constructor in a modular fashion within the received file. Illustratively, after storing the shared file in the received file, the kernel consumer server exports the kernel constructor in a modular fashion within the received file, resulting in a modular kernel constructor. This modular kernel constructor is used to implement data communication through a predefined module interface.
[0115] In some embodiments, the instantiation of the functional kernel is achieved through functional components. For example, the functional component corresponding to the second functional service is obtained; the modular kernel constructor exported from the receiving file is imported into the functional component, and the functional kernel is instantiated through the functional component to obtain the first functional instance.
[0116] In one example, taking the receiving file as a JavaScript file, the module loader is implemented as a JavaScript module loader. The asynchronous method of the JavaScript module loader is used in the receiving file to obtain the shared file provided by the kernel server via HTTP. The kernel constructor is exported as a module in the shared file. The functional components import the kernel constructor obtained from the receiving file and obtain the core capabilities of the first functional service by instantiating the kernel constructor.
[0117] In other words, exporting and importing the kernel constructor through modules can improve the scalability of the functional components of the second functional service. When the first functional service is a sub-function of the second functional service, it can avoid the problem of global variable pollution in the kernel constructor of the first functional service and the code of other sub-functions in the functional components, reduce the coupling between code, and facilitate debugging and testing.
[0118] In some embodiments, the functional component performs business extensions on the first functional instance obtained by instantiating through a modular kernel constructor, and the functional component exports its own instance to obtain a second functional instance for business calls to provide the second functional service to the second client.
[0119] In some embodiments, when the functional kernel in the kernel provider server is updated, the kernel provider server creates an updated shared file based on the updated functional kernel. The updated shared file references a kernel constructor based on the updated functional kernel. When the kernel consumer server detects that a second client has a service requirement for the second functional service, the kernel consumer server obtains the updated shared file, calls the updated functional kernel through the new kernel constructor, and provides the second functional service to the second client.
[0120] In summary, when a kernel provider server shares functionality with a kernel consumer server, the kernel provider server creates a shared file of the functional kernel based on the kernel constructor of the functional kernel it maintains. The kernel consumer server obtains the shared file of the functional kernel provided by the kernel provider server and instantiates the functional kernel through the kernel constructor in the shared file, thereby providing a second functional service to the second client and realizing functional sharing between servers. In this process, after the functional kernel maintained by the kernel provider server is updated, the functional kernel called by the shared file obtained by the kernel consumer server when providing the second functional service to the second client is also the latest. Therefore, the second functional service relying on the functional kernel provided by the kernel provider server can achieve seamless upgrades, avoiding the problem in traditional solutions where both the server acting as the sharing provider and the server acting as the sharing consumer need to be updated independently, thus improving the update efficiency of functional services.
[0121] Meanwhile, when implementing functional services, both the kernel provider server and the kernel consumer server are based on the functional kernel maintained by the kernel provider server. This process can be viewed as the functional components in the runtime environments of the first client and the second client being implemented in a single web service, allowing for natural logic reuse. The services provided by the kernel provider server and the kernel consumer server can be collaboratively developed, ensuring that the functional kernels used by both the first and second functional services are the latest versions. This avoids problems caused by version inconsistencies during collaborative development and improves the efficiency of collaborative development.
[0122] Please refer to Figure 3 It illustrates a data interaction diagram between devices in a function-sharing system, which includes a kernel providing server 301 and a kernel consuming server 302. The kernel providing server 301 is a server that provides functional kernels, and the kernel consuming server 302 is a server that consumes functional kernels.
[0123] The kernel provides server 301 for providing first functional services (311) to a first client based on the functional kernel; and for creating shared files of the functional kernel (312).
[0124] The shared files of the functional kernel include the kernel constructor corresponding to the functional kernel. The kernel constructor is used to instantiate the functional kernel. The kernel provider server 301 is used to provide the first functional service to the first client based on the functional kernel and to create the shared files of the functional kernel.
[0125] The kernel provides server 301 to provide first functional services to the first client. Optionally, the first functional services include editor functional services, cropping functional services, drawing functional services, image insertion functional services, etc.
[0126] The kernel provides a functional kernel that maintains the first functional service in server 301. The functional kernel is used to provide code-level logic support for the implementation of the first functional service. That is, the functional kernel is responsible for handling the basic functions and core logic of the first functional service and is the core component or infrastructure for implementing the first functional service.
[0127] In some embodiments, the first functional service is implemented as a functional service based on a web service, wherein a web service is a network-based service that provides interactive services for functions or data over a network through web technologies and standard protocols.
[0128] Optionally, the aforementioned standard protocols include protocols such as Hypertext Transfer Protocol and Secure Hypertext Transfer Protocol.
[0129] It is worth noting that there is no fixed execution order for steps 311 and 312. That is, the kernel server 301 can first provide the first functional service to the first client through the functional kernel, and then create the shared file of the functional kernel. Alternatively, it can first create the shared file of the functional kernel, and then provide the first functional service to the first client through the functional kernel. It can also perform the provision of the first functional service and the creation of the shared file at the same time. No limitation is made here.
[0130] In some alternative embodiments, the kernel provides server 301 and is also used to create shared files based on the functional kernel. Optionally, the shared files include the kernel constructor of the functional kernel; or, the shared files include the functional kernel and its kernel constructor.
[0131] In one example, taking the kernel constructor of the functional kernel included in the shared file as an example, the process of the kernel providing server 301 to create a shared file is implemented as follows: create a first file for sharing; import the kernel constructor of the functional kernel into the first file to obtain the shared file.
[0132] In another example, taking a shared file that includes a functional kernel and its kernel constructor as an example, the process of the kernel providing server 301 to create a shared file is implemented as follows: a first file for sharing is created; the functional kernel and its kernel constructor are imported into the first file to obtain the shared file.
[0133] In some embodiments, when the shared file does not include a functional kernel, the call to the functional kernel in the kernel constructor can be implemented by referencing the directory address where the functional kernel is located in the kernel provider server 301; in other embodiments, when the shared file includes both a functional kernel and a kernel constructor, the call to the functional kernel in the kernel constructor directly references the functional kernel, that is, the code or module corresponding to the functional kernel is directly referenced in the call to the functional kernel in the kernel constructor.
[0134] In some embodiments, the shared file can be implemented as a JavaScript file, and the file format of the shared file includes .js, .jsx, .ts, .tsx, .mjs, .cjs, etc.
[0135] In some alternative embodiments, the kernel provides server 301, which is also used to create a file transfer interface for shared files, that is, to transfer shared files as the output of the file transfer interface.
[0136] Optionally, the above file transfer interface can be implemented as a Node.js interface. A Node.js interface is a reference type implemented using Node.js that defines the contract with methods, properties, indexers, and events as members.
[0137] In some optional embodiments, to avoid direct exposure of the functional kernel, the kernel providing server 301, after obtaining the shared file, obfuscates the shared file and provides the obfuscated shared file to the kernel consuming server 302. Illustratively, the kernel providing server 301 is also used to obfuscate the executable code of the shared file of the functional kernel to obtain the obfuscated shared file; and to provide the obfuscated shared file to the kernel consuming server 302.
[0138] Code obfuscation is a technique that alters the structure and form of program code to make it harder to understand. Obfuscated code retains its functionality at runtime, but the readability and understandability of the source code are greatly reduced. Therefore, it can guarantee the security of the functional constructors / functional kernels provided by shared files.
[0139] Alternatively, the code obfuscation process can be implemented as at least one of the following:
[0140] • Rename at least one function information of the kernel constructor, wherein the function information includes at least one of the kernel constructor's function name, variable name, and class name;
[0141] • Strings in the encrypted kernel constructor;
[0142] • Insert pre-defined redundant code into shared files;
[0143] • Add reflection mechanism code to the shared file, where the reflection mechanism code is used to dynamically modify at least one function information of the kernel constructor during the execution of the kernel constructor.
[0144] In some optional embodiments, the kernel providing server 301 is further configured to, when the first client has a service requirement for the first functional service, invoke the functional kernel corresponding to the first functional service to generate a fourth functional instance corresponding to the first functional service; and provide the first functional service to the first client through the fourth functional instance. That is, the kernel providing server 301 instantiates the functional kernel it maintains to obtain the fourth functional instance, thereby providing the first functional service to the first client through the fourth functional instance for business calls.
[0145] In some optional embodiments, the kernel provides server 301, which is also used for instantiation via the kernel constructor of the functional kernel. Illustratively, the instantiation process via the kernel constructor includes: when the kernel constructor is called, the kernel provides server 301 to allocate memory space for the first functional service, calls the kernel constructor to initialize the member variables of the object (instance), sets the initial state of the object, and obtains the fourth functional instance.
[0146] Kernel consumer server 302 is used to obtain shared files of functional kernel from kernel provider server 301 (321); and to provide second functional services to the second client by calling the shared functional kernel of kernel provider server 301 through kernel constructor (322).
[0147] In some optional embodiments, the kernel consumer server 302 is further configured to obtain a functional component corresponding to the second functional service, the functional component being used to encapsulate at least one sub-function of the second functional service; import the kernel constructor into the functional component, call the kernel constructor within the functional component to instantiate the functional kernel, and obtain a first functional instance; and provide the second functional service to the second client through the first functional instance.
[0148] In this context, an instance refers to a specific object created based on a class. A class is an abstract template that defines the structure of a group of objects with the same attributes (variables) and methods (functions). Each instance has its own state (attribute values) but shares the methods of the class. Instantiation refers to the process of calling the class's constructor. In this embodiment, when the kernel consumer server 302 provides the second functional service to the second client, instantiation is achieved through the kernel constructor of the first functional service.
[0149] In some optional embodiments, the kernel consumer server 302 is further configured to import the kernel constructor into the functional component, create an empty instance within the functional component, bind the empty instance to the kernel constructor, execute the code in the kernel constructor to initialize the properties and methods in the empty instance, and obtain the first functional instance.
[0150] Indicatively, when the kernel constructor is called, the kernel consumer server 302 allocates memory space for the second functional service to create an empty instance, calls the kernel constructor to initialize the member variables of the empty instance, sets the initial state of the empty instance, and obtains the first functional instance.
[0151] In some optional embodiments, the kernel consumer server 302 is further configured to perform business extension on the first functional instance to obtain a second functional instance; and to provide the second functional service to the second client through the second functional instance.
[0152] As an illustration, when there is a difference between the business logic corresponding to the first and second functional services, the kernel consumer server 302 performs business extension on the first functional instance. Business extension refers to adding new functionality or behavior to the first functional instance without modifying the original class definition. Optionally, business extension can be implemented as at least one of the following: inheritance; composition; decorator; interface or abstract class; dynamically adding properties and methods.
[0153] In some optional embodiments, the kernel consumer server 302 is further configured to instantiate a sub-functional kernel of at least one sub-function within a functional component to obtain a third functional instance; and to combine the first functional instance and the third functional instance to obtain a second functional instance.
[0154] In some optional embodiments, the kernel consumer server 302 is also used to create a receiving file; obtain a shared file of the functional kernel from the kernel provider server 301, and store the shared file of the functional kernel in the receiving file; and export the kernel constructor in a modular manner in the receiving file to obtain a modular kernel constructor, which is used to implement data communication through a predefined module interface.
[0155] Indicatively, the kernel consumer server 302 acquires shared files by creating a receiving file. The functional components of the second function service are maintained within the kernel consumer server 302 to implement this service; they can be implemented as independent, reusable code units. The module loader is a component in the runtime environment used to load, parse, and initialize modules. Its core function is to load module code into the runtime environment and ensure that dependencies between modules are handled correctly.
[0156] In one example, taking the receiving file as a JavaScript file, the module loader is implemented as a JavaScript module loader. The asynchronous method of the JavaScript module loader is used in the receiving file to obtain the shared file provided by the kernel server via HTTP 301. The kernel constructor is exported as a module in the shared file. The functional components import the kernel constructor obtained from the receiving file and obtain the core capabilities of the first functional service by instantiating the kernel constructor.
[0157] In some embodiments, the functional component performs business extensions on the first functional instance obtained by instantiating through the kernel constructor, and the functional component exports its own instance to obtain a second functional instance for business calls to provide the second functional service to the second client.
[0158] In some optional embodiments, the kernel consumer server 302 is further configured to obtain the functional kernel providing the first functional service from a shared file of the functional kernel; and to provide the second functional service to the second client through the functional kernel invoked by the kernel constructor.
[0159] As an illustration, when a functional kernel is included in the shared file, the kernel consuming server obtains the functional kernel through the shared file, invokes the functional kernel through the kernel constructor, and provides the second functional service to the second client. That is, when a functional kernel is provided in the shared file, the kernel consuming server 302 can directly obtain the functional kernel from the shared file for invocation.
[0160] In some embodiments, when the shared file has referenced the functional kernel code in the kernel constructor during the generation process, the kernel consumer server 302 obtains the core capabilities of the first functional service by running the kernel constructor, thereby enabling the provision of the second functional service to the second client.
[0161] In some optional embodiments, the kernel consumer server 302 is also used to remotely call the functional kernel in the kernel provider server 301 through the kernel constructor to provide a second functional service to the second client.
[0162] As an illustration, when the shared file does not include a functional kernel, the kernel consuming server 302 remotely invokes the functional kernel in the kernel providing server 301 through the kernel constructor to provide a second functional service to the second client. That is, when the shared file does not provide a functional kernel, the kernel consuming server 302 can invoke the functional kernel in the kernel providing server 301 through remote invocation.
[0163] In some embodiments, when a shared file is generated by referencing a functional kernel and providing a directory address in the kernel server 301, the kernel consumer server 302, during the execution of the kernel constructor, obtains the core capabilities of the first functional service through remote calls, thereby enabling the provision of the second functional service to the second client.
[0164] Optionally, the remote call can be implemented by obtaining the functional kernel for local instantiation; or, it can be implemented by using the kernel consumer server 302 as a proxy for the kernel provider server 301, with the kernel consumer server 302 forwarding the data processing request for the second functional service from the second client to the kernel provider server 301, and the kernel provider server 301 implementing the data processing process indicated by the data processing request through the functional kernel.
[0165] In one example, based on RPC: RPC is a technology that allows a program running on one device to call a program running on another device. Schematic, an RPC interface is defined between kernel provider server 301 and kernel consumer server 302. Kernel provider server 301 is used to implement the service logic defined in the RPC interface through the functional kernel. When kernel provider server 301 starts the RPC service, kernel consumer server 302 can call the functional kernel in kernel provider server 301 through the RPC interface. Optionally, kernel consumer server 302 can obtain the functional kernel itself through the RPC interface.
[0166] In some embodiments, the function sharing system further includes a second client. The second client is configured to send a service request to the kernel consumer server 302 in response to receiving a page open request for a function page, wherein the function page is used to provide a second function service. The kernel consumer server 302 is also configured to retrieve a shared file provided by the kernel provider server 301 in response to receiving the service request.
[0167] Optionally, the second client triggering the sending of a service request can be implemented in at least one of the following ways: 1. The function page is opened; 2. The function page is refreshed; 3. The second client is updated.
[0168] In some optional embodiments, the kernel consumer server 302 is further configured to send a data acquisition request based on the Hypertext Transfer Protocol to the kernel provider server 301. The kernel provider server 301 is further configured to, in response to the data acquisition request, send a shared file of the functional kernel to the kernel consumer server 302 based on the Hypertext Transfer Protocol.
[0169] In some embodiments, the kernel consumer server 302 initiates an HTTP request to the kernel provider server 301 to request a shared file. In one example, the process of initiating the HTTP request includes: the kernel consumer server 302 determining the URL of the shared file, which specifies the address, path, and filename of the kernel provider server 301 where the shared file is located; constructing an HTTP request based on the URL of the shared file; and sending the HTTP request over the network to the kernel provider server 301.
[0170] In some optional embodiments, the function-sharing system further includes an intermediary server for providing data distribution services. The kernel providing server 301 is also used to publish shared files to the intermediary server; the intermediary server is used to store received shared files; the kernel consuming server 302 is also used to send data acquisition requests based on the Hypertext Transfer Protocol to the intermediary server; the intermediary server is also used to, in response to the data acquisition requests, send the shared files of the functional kernel to the kernel consuming server 302 based on the Hypertext Transfer Protocol.
[0171] The aforementioned intermediary server is used to provide data distribution services. In one example, the intermediary server can be implemented as a CDN server. For instance, when there are multiple kernel consumer servers 302 distributed in different geographical locations, shared files can be stored through a CDN server to reduce the load on the kernel providing server 301.
[0172] In some embodiments, the kernel consumer server 302 initiates an HTTP request to the intermediary server to request a shared file. In one example, the process of initiating the HTTP request includes: the kernel consumer server 302 determining the URL of the shared file, which specifies the address, path, and filename of the intermediary server where the shared file is located; constructing an HTTP request based on the URL of the shared file; and sending the HTTP request to the intermediary server over the network.
[0173] In some optional embodiments, the kernel providing server 301 is further configured to create updated shared files based on the updated functional kernel after the functional kernel is updated, wherein the updated shared files reference a kernel constructor based on the updated functional kernel. The kernel consuming server 302 is further configured to obtain the updated shared files; and to provide second functional services to the second client by calling the updated functional kernel through the new kernel constructor.
[0174] In summary, when a kernel provider server shares functionality with a kernel consumer server, the kernel provider server creates a shared file of the functional kernel based on the kernel constructor of the functional kernel it maintains. The kernel consumer server obtains the shared file of the functional kernel provided by the kernel provider server and instantiates the functional kernel through the kernel constructor in the shared file, thereby providing a second functional service to the second client and realizing functional sharing between servers. In this process, after the functional kernel maintained by the kernel provider server is updated, the functional kernel called by the shared file obtained by the kernel consumer server when providing the second functional service to the second client is also the latest. Therefore, the second functional service relying on the functional kernel provided by the kernel provider server can achieve seamless upgrades, avoiding the problem in traditional solutions where both the server acting as the sharing provider and the server acting as the sharing consumer need to be updated independently, thus improving the update efficiency of functional services.
[0175] In some optional embodiments, the editor function type is taken as an example, using the function types of the first function service and the second function service. Figure 4 The diagram illustrates an editor function sharing system 400 provided in an exemplary embodiment of this application, which includes a kernel providing server 410 and two kernel consuming servers (including kernel consuming server A421 and kernel consuming server B422).
[0176] Among them, kernel server 410 is used to provide editor function service 412 to mobile page 411 provided to mobile client, kernel consumer server A421 is used to provide editor function service 4212 to PC page 4211 provided to PC client, and kernel consumer server B422 is used to provide editor function service 4222 to web page 4221 provided to external browser.
[0177] In one example, mobile page 411 is as follows: Figure 5 As shown, in the mobile page 411, page (a) is a page with no content and page (b) is a page with content. The runtime environment can be implemented as a WebView provided by iOS or Android.
[0178] In another example, PC page 4211 is as follows: Figure 6 As shown, in the PC version of page 4211, page (a) is a page with no content and page (b) is a page with content. The runtime environment can be implemented as a Webview for Mac or Windows.
[0179] In another example, webpage 4221 is as follows: Figure 7 As shown, in web page 4221, page (a) is a page with no content, and page (b) is a page with content. The operating environment can be an external browser.
[0180] The kernel server 410 maintains an editor kernel 413 with editor functionality 412. That is, the kernel server 410, as the host of the editor kernel, needs to implement an editor component for mobile devices based on the kernel and also provide an HTTP interface to expose the kernel constructor. Illustratively, after deploying or updating the editor kernel 413, the kernel server 410 generates a shared file 415 containing the editor kernel 413 and its corresponding kernel constructor 414.
[0181] Kernel consumer server A421 obtains shared file 415 from kernel provider server 410 via HTTP, thereby implementing editor functionality service 4212 through shared file 415. That is, kernel consumer server A421, as a consumer, obtains the editor kernel constructor via HTTP, and then implements a PC-side editor based on the kernel, providing it for PC business use.
[0182] Kernel consumer server B422 obtains shared file 415 from kernel provider server 410 via HTTP, and then uses shared file 415 to implement editor function service 4222. That is, kernel consumer server B422, as a consumer, obtains the editor kernel constructor via HTTP, and then implements the editor for the web management terminal based on the kernel, providing it for business use by the web management terminal.
[0183] This is illustrative; please refer to it. Figure 8 This illustration shows a timing diagram of device data interaction in an editor function sharing system provided by an exemplary embodiment of this application. The editor function sharing system includes a kernel providing server 801 and a kernel consuming server 802 (which can be implemented as...). Figure 4 In this embodiment of the application, the editor function sharing system also includes a CDN server 803 and a build server 804, and the interaction process between the devices includes the following steps.
[0184] Step 811: The kernel provides server 801 with maintenance editor kernel.
[0185] In illustration, the editor kernel provides code-level logic support for the implementation of editor functions. That is, the editor kernel is responsible for handling the basic functions and core logic of the editor and is the core component or infrastructure for implementing editor functions.
[0186] Optionally, the editor described above can be implemented as a text editor, code editor, graphics editor, audio editor, video editor, etc., and there is no limitation here.
[0187] Optionally, the editor kernel may include at least one of the following features:
[0188] • Data processing: The editor kernel is responsible for basic operations such as data (text, graphics, audio, video, etc.) input, editing, and formatting;
[0189] • Syntax parsing: For some editors, the editor kernel usually includes a syntax parsing module to implement functions such as syntax highlighting and problem suggestions;
[0190] • Extended functionality: The editor's core supports plugins or extensions, allowing developers to add custom features;
[0191] • Performance optimization features: The editor kernel design usually takes performance optimization into account to ensure the editor is smooth when processing large files or complex tasks.
[0192] In some embodiments, during the development phase, the editor kernel is released to a test environment for testing and debugging, and then released to the kernel provider server 801 after the tests are passed. In one example, the above test environment can be implemented as a Docker environment, where a Docker environment refers to a runtime environment built on Docker technology, which allows developers to package applications and their dependencies into a separate container.
[0193] Step 812: The kernel provides server 801 with a newly created shared file for sharing, and the shared file references the editor kernel.
[0194] In this embodiment, the shared file includes an editor kernel, that is, the kernel provides the server 801 with a newly created first file for sharing; the editor kernel and the kernel constructor of the editor kernel are imported into the first file to obtain the shared file.
[0195] In some embodiments, the shared file can be implemented as a JavaScript file. The file format of the shared file includes .js, .jsx, .ts, .tsx, .mjs, .cjs, etc. In one example, the shared file is editor-share.js.
[0196] Step 813: The kernel provides server 801 with a first file transfer interface to output the shared file.
[0197] Optionally, the aforementioned first file transfer interface can be implemented as a Node.js interface. Here, a Node.js interface is a reference type implemented using Node.js that defines the contract as members including methods, properties, indexers, and events.
[0198] Step 814: The kernel provides server 801 to submit the shared file to build server 804 through the first file transfer interface.
[0199] As an illustration, to avoid direct exposure of the functional kernel, the kernel provides server 801 to output shared files to build server 804 so that code obfuscation and packaging can be achieved through build server 804.
[0200] In other embodiments, the kernel-provided server 801 can also locally implement the obfuscation and packaging of shared files.
[0201] Step 815: The server 804 obfuscates and packages the shared files to obtain the obfuscated shared files.
[0202] Code obfuscation is a technique that alters the structure and form of program code to make it harder to understand. Obfuscated code retains its functionality at runtime, but the readability and understandability of the source code are greatly reduced.
[0203] Optionally, obfuscation of shared files in the service area 804 can be achieved in at least one of the following ways: naming obfuscation; control flow flattening; string encryption; insertion of useless code; code splitting and merging; data transformation; address obfuscation; reflection and dynamic code generation.
[0204] Packaging refers to reducing the overall size of shared files by using compression algorithms, thereby saving storage space and speeding up transmission. Optionally, the above packaging can be implemented as: compressed file packaging, binary data packaging, database backup packaging, etc.
[0205] Optionally, the obfuscated shared file can be published to CDN server 803, that is, steps 816 to 817 are executed; or, the obfuscated shared file can be sent back to kernel provider server 801, that is, steps 818 to 821 are executed.
[0206] Step 816, build server 804 to publish the obfuscated shared files to CDN server 803.
[0207] In some embodiments, the build server 804 publishes the obfuscated shared file to the build server 804, which then provides the shared file to the kernel consumer server 802.
[0208] CDN is a technology and service used to optimize the distribution of Internet content. It improves the loading speed, availability, and reliability of content by caching it on servers in multiple geographical locations around the world, while reducing the load on the origin server. In other words, when there are multiple kernel consumer servers 802 distributed in different geographical locations, shared files can be stored through CDN server 804 to reduce the load on kernel provider server 801.
[0209] Step 817: Kernel consumer server 802 obtains the obfuscated shared file from CDN server 803 via HTTP.
[0210] As an illustration, kernel consumer server 802 initiates an HTTP request to CDN server 803 to request a shared file. In one example, the HTTP request initiation process includes: kernel consumer server 802 determining the URL of the shared file, which specifies the CDN server address, path, and filename of the shared file; constructing an HTTP request based on the shared file's URL; and sending the HTTP request over the network to CDN server 803.
[0211] Step 818: The build server 804 sends the obfuscated shared file to the kernel provider server 801.
[0212] In some embodiments, the build server 804 returns the obfuscated shared file to the kernel provider server 801, which then provides the shared file to the kernel consumer server 802.
[0213] In some embodiments, the build server 804 sends the obfuscated shared file to the kernel provider server 801 through the first data transmission interface.
[0214] Step 819: The kernel provides server 801 with a second file transfer interface to output the obfuscated shared file.
[0215] Optionally, the aforementioned second file transfer interface can be implemented as a Node.js interface. Here, a Node.js interface is a reference type implemented using Node.js that defines the contract with methods, properties, indexers, and events as members.
[0216] Step 820: Kernel consumer server 802 obtains the obfuscated shared file from kernel provider server 801 via HTTP.
[0217] As an illustration, kernel consumer server 802 initiates an HTTP request to kernel provider server 801 to request a shared file. In one example, the HTTP request initiation process includes: kernel consumer server 802 determining the URL of the shared file, which specifies the address, path, and filename of the kernel provider server where the shared file resides; constructing an HTTP request based on the URL of the shared file; and sending the HTTP request over the network to kernel provider server 801.
[0218] Step 821: Kernel consumer server 802 instantiates the editor instance by running the kernel constructor through a shared file, and then provides the editor instance for business calls.
[0219] To illustrate, the execution flow of the kernel consumer server 802 for shared files is as follows: S1, create the receiving file editor-receiver.js; S2, within the receiving file editor-receiver.js, use an asynchronous method of the JavaScript module loader to retrieve the shared file editor-share.js via HTTP; S3, within the receiving file editor-receiver.js, export the editor kernel constructor as a module; S4, the editor component imports the receiving file editor-receiver.js to obtain the editor kernel constructor, and instantiates the kernel to acquire the core capabilities of the editor; S5, the editor component extends its business logic based on the kernel; S6, the editor component exports its own instance for business calls.
[0220] It should be noted that this application may display prompt interfaces, pop-ups, or output voice prompts before and during the collection of user data. These prompt interfaces, pop-ups, or voice prompts are used to inform the user that their data is being collected. This ensures that the application only begins the steps for collecting user data after receiving confirmation from the user regarding the prompt interface or pop-up; otherwise (i.e., without user confirmation), the steps for collecting user data end, meaning no user data is collected. In other words, all user data collected in this application is collected with the user's consent and authorization, and the collection, use, and processing of related user data must comply with the relevant laws, regulations, and standards of the relevant countries and regions.
[0221] Please refer to Figure 9The diagram illustrates a functional sharing device structure block diagram provided in an exemplary embodiment of this application, the device comprising the following modules:
[0222] The acquisition unit 910 is used to acquire a shared file of a functional kernel from a kernel provider server. The shared file includes a kernel constructor corresponding to the functional kernel. The kernel constructor is used to instantiate the functional kernel. The kernel provider server is used to provide a first functional service to a first client based on the functional kernel and to create the shared file of the functional kernel.
[0223] Processing unit 920 is used to call the kernel to provide the functional kernel shared by the server through the kernel constructor, and to provide the second functional service to the second client.
[0224] In some optional embodiments, the acquisition unit 910 is further configured to acquire a functional component corresponding to the second functional service, the functional component being configured to encapsulate at least one sub-function of the second functional service;
[0225] The processing unit 920 further includes:
[0226] An instantiation subunit is used to import the kernel constructor into the functional component, and call the kernel constructor within the functional component to instantiate the functional kernel, thereby obtaining a first functional instance;
[0227] The service subunit is used to provide the second function service to the second client through the first function instance.
[0228] In some optional embodiments, the instantiation subunit is further configured to import the kernel constructor into the functional component, create an empty instance within the functional component, bind the empty instance to the kernel constructor, execute the code in the kernel constructor to initialize the properties and methods in the empty instance, and obtain the first functional instance.
[0229] In some optional embodiments, the instantiation subunit is further configured to perform business extension on the first functional instance to obtain a second functional instance; and to provide the second functional service to the second client through the second functional instance.
[0230] In some optional embodiments, the instantiation subunit is further configured to instantiate the sub-function kernel of the at least one sub-function within the functional component to obtain a third functional instance; and combine the first functional instance and the third functional instance to obtain the second functional instance.
[0231] In some optional embodiments, the acquisition unit 910 is further configured to create a receiving file; acquire the shared file of the functional kernel from the kernel providing server, and store the shared file of the functional kernel in the receiving file; and export the kernel constructor in the receiving file in a modular manner to obtain a modular kernel constructor, the modular kernel constructor being used to implement data communication through a predefined module interface.
[0232] In some optional embodiments, the processing unit 920 is further configured to obtain the functional kernel from a shared file of the functional kernel; and to call the functional kernel through the kernel constructor to provide the second functional service to the second client;
[0233] or,
[0234] The processing unit 920 is also used to remotely call the functional kernel in the kernel providing server through the kernel constructor to provide the second functional service to the second client.
[0235] In some optional embodiments, the acquisition unit 910 is further configured to acquire the shared file provided by the kernel providing server in response to receiving the service request sent by the second client; the second client sends the service request to the kernel consuming server when it receives a page opening request for a function page.
[0236] In some optional embodiments, the acquisition unit 910 is further configured to send a data acquisition request based on the Hypertext Transfer Protocol to the kernel providing server; and receive the shared files of the functional kernel sent by the kernel providing server based on the Hypertext Transfer Protocol.
[0237] In some optional embodiments, the acquisition unit 910 is further configured to send a data acquisition request based on the Hypertext Transfer Protocol to the intermediary server; and receive the shared file of the functional kernel sent by the intermediary server based on the Hypertext Transfer Protocol.
[0238] The intermediary server is used to provide data distribution services and stores shared files of the functional kernels published by the kernel provider server.
[0239] In some optional embodiments, the acquisition unit 910 is further configured to, in response to a service request from the first client for the first functional service, acquire a shared file of the functional kernel from the kernel providing server.
[0240] It should be noted that the function-sharing device provided in the above embodiments is only an example of the division of the above functional modules. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the function-sharing device and the function-sharing method embodiments provided in the above embodiments belong to the same concept, and their specific implementation process can be found in the method embodiments, which will not be repeated here.
[0241] Figure 10 This illustration shows a schematic diagram of the structure of a server provided in an exemplary embodiment of this application. Specifically, it includes the following structure.
[0242] Server 1000 includes a Central Processing Unit (CPU) 1001, a system memory 1004 including Random Access Memory (RAM) 1002 and Read Only Memory (ROM) 1003, and a system bus 1005 connecting the system memory 1004 and the CPU 1001. Server 1000 also includes a mass storage device 1006 for storing the operating system 1013, application programs 1014, and other program modules 1015.
[0243] Mass storage device 1006 is connected to central processing unit 1001 via a mass storage controller (not shown) connected to system bus 1005. Mass storage device 1006 and its associated computer-readable media provide non-volatile storage for server 1000. That is, mass storage device 1006 may include computer-readable media (not shown) such as hard disk or compact disc read-only memory (CD-ROM) drive.
[0244] Without loss of generality, computer-readable media can include computer storage media and communication media. Computer storage media includes volatile and non-volatile, removable and non-removable media implemented using any method or technology for storing information such as computer-readable instructions, data structures, program modules, or other data. Computer storage media includes RAM, ROM, erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other solid-state memory technologies, CD-ROM, digital versatile disc (DVD) or other optical storage, magnetic tape cassettes, magnetic tape, disk storage, or other magnetic storage devices. Of course, those skilled in the art will recognize that computer storage media are not limited to the above-mentioned types. The system memory 1004 and mass storage device 1006 described above can be collectively referred to as memory.
[0245] According to various embodiments of this application, server 1000 can also be connected to a remote computer on a network, such as the Internet. That is, server 1000 can be connected to network 1012 via network interface unit 1011 connected to system bus 1005, or it can use network interface unit 1011 to connect to other types of networks or remote computer systems (not shown).
[0246] The aforementioned memory also includes one or more programs, which are stored in the memory and configured to be executed by the CPU.
[0247] Embodiments of this application also provide a computer device including a processor and a memory. The memory stores at least one instruction, at least one program, a code set, or an instruction set. The processor loads and executes the at least one instruction, at least one program, a code set, or an instruction set to implement the function-sharing method provided in the above-described method embodiments. Optionally, the computer device may be a terminal or a server.
[0248] Embodiments of this application also provide a computer-readable storage medium storing at least one instruction, at least one program, code set, or instruction set, wherein the at least one instruction, at least one program, code set, or instruction set is loaded and executed by a processor to implement the function sharing method provided in the above-described method embodiments.
[0249] Embodiments of this application also provide a computer program product or computer program that includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform any of the function-sharing methods described in the above embodiments.
[0250] Optionally, the computer-readable storage medium may include: read-only memory (ROM), random access memory (RAM), solid-state drives (SSDs), or optical discs, etc. The random access memory may include resistive random access memory (ReRAM) and dynamic random access memory (DRAM). The sequence numbers of the embodiments in this application are merely descriptive and do not represent the superiority or inferiority of the embodiments.
[0251] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.
[0252] The above description is merely an optional embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A function-sharing system, characterized in that, The system includes a kernel providing server and a kernel consuming server. The kernel providing server is a server that provides functional kernels, and the kernel consuming server is a server that consumes the functional kernels. The kernel provides a server for providing a first functional service to a first client based on the functional kernel; And a shared file for creating the functional kernel, the shared file including the kernel constructor corresponding to the functional kernel, the kernel constructor being used to instantiate the functional kernel; The kernel consumer server is used to obtain the shared file of the functional kernel from the kernel provider server; and to provide a second functional service to the second client by calling the functional kernel shared by the kernel provider server through the kernel constructor.
2. The system according to claim 1, characterized in that, The kernel consumer server is further configured to obtain a functional component corresponding to the second functional service, the functional component being used to encapsulate at least one sub-function of the second functional service; import the kernel constructor into the functional component; call the kernel constructor within the functional component to instantiate the functional kernel, thereby obtaining a first functional instance; and provide the second functional service to the second client through the first functional instance.
3. The system according to claim 2, characterized in that, The kernel consumer server is further configured to import the kernel constructor into the functional component, create an empty instance within the functional component, bind the empty instance to the kernel constructor, execute the code in the kernel constructor to initialize the properties and methods in the empty instance, and obtain the first functional instance.
4. The system according to claim 2 or 3, characterized in that, The functional component includes a sub-functional kernel corresponding to at least one of the sub-functions; The kernel consumer server is further configured to instantiate the kernel of the at least one sub-function within the functional component to obtain a third functional instance; combine the first functional instance and the third functional instance to obtain a second functional instance; and provide the second functional service to the second client through the second functional instance.
5. The system according to any one of claims 1 to 3, characterized in that, The kernel consumer server is also configured to create a receiving file; obtain the shared file of the functional kernel from the kernel provider server; and store the shared file of the functional kernel into the receiving file. The kernel constructor is exported in a modular manner within the received file to obtain a modular kernel constructor, which is used to implement data communication through a predefined module interface.
6. The system according to any one of claims 1 to 3, characterized in that, The kernel consumer server is also configured to obtain the functional kernel from a shared file of the functional kernel; and to call the functional kernel through the kernel constructor to provide the second functional service to the second client. or, The kernel consumer server is also used to remotely call the functional kernel in the kernel provider server through the kernel constructor to provide the second functional service to the second client.
7. The system according to any one of claims 1 to 3, characterized in that, The kernel consumer server is also used to send data acquisition requests based on the Hypertext Transfer Protocol to the kernel provider server; The kernel providing server is also configured to, in response to the data acquisition request, send the shared file of the functional kernel to the kernel consuming server based on the Hypertext Transfer Protocol.
8. The system according to any one of claims 1 to 3, characterized in that, The system also includes an intermediary server, which is used to provide data distribution services; The kernel provides a server and is also used to publish shared files of the functional kernel to the intermediary server; The intermediary server is used to store the shared files of the received functional kernel; The kernel consumer server is also used to send a data acquisition request based on the Hypertext Transfer Protocol to the intermediary server; The intermediary server is also configured to, in response to the data acquisition request, send the shared file of the functional kernel to the kernel consumer server based on the Hypertext Transfer Protocol.
9. The system according to any one of claims 1 to 3, characterized in that, The kernel consumer server is also configured to, in response to the first client's service request for the first functional service, obtain the shared file of the functional kernel from the kernel provider server.
10. The system according to any one of claims 1 to 3, characterized in that, The kernel providing server is also used to obfuscate the code of the shared files of the functional kernel to obtain obfuscated shared files; and to provide the obfuscated shared files to the kernel consuming server.
11. The system according to claim 10, characterized in that, The obfuscation of shared files in the functional kernel includes at least one of the following operations: Rename at least one function information of the kernel constructor, wherein the function information includes at least one of the function name, variable name, and class name of the kernel constructor; Encrypt the string in the kernel constructor; Insert pre-defined redundant code into the shared file of the functional kernel; Add reflection mechanism code to the shared file of the functional kernel. The reflection mechanism code is used to dynamically modify at least one function information of the kernel constructor during the execution of the kernel constructor.
12. A method for sharing functions, characterized in that, The method is executed by the kernel consumer server, and the method includes: The kernel provider server obtains a shared file of the functional kernel, the shared file including the kernel constructor corresponding to the functional kernel, the kernel constructor being used to instantiate the functional kernel, and the kernel provider server being used to provide a first functional service to the first client based on the functional kernel and to create the shared file of the functional kernel; The kernel constructor calls the kernel to provide the functional kernel shared by the server, thus providing a second functional service to the second client.
13. The method according to claim 12, characterized in that, The step of providing the second functional service to the second client by calling the kernel through the kernel constructor to provide the server-shared functional kernel includes: Obtain the functional component corresponding to the second functional service, wherein the functional component is used to encapsulate at least one sub-function of the second functional service; The kernel constructor is imported into the functional component, and the kernel constructor is called within the functional component to instantiate the functional kernel of the first functional service, thereby obtaining the first functional instance; The second function service is provided to the second client through the first function instance.
14. The method according to claim 13, characterized in that, The step of importing the kernel constructor into the functional component, and calling the kernel constructor within the functional component to instantiate the functional kernel of the first functional service to obtain the first functional instance includes: Import the kernel constructor into the functional component, and create an empty instance within the functional component; The empty instance is bound to the kernel constructor, and the code in the kernel constructor is executed to initialize the properties and methods in the empty instance, thus obtaining the first functional instance.
15. The method according to claim 13 or 14, characterized in that, The functional component includes a sub-functional kernel corresponding to at least one of the sub-functions; Providing the second functional service to the second client through the first functional instance includes: Within the functional component, the kernel of the at least one sub-function is instantiated to obtain a third functional instance; The second functional instance is obtained by combining the first functional instance and the third functional instance; The second function service is provided to the second client through the second function instance.
16. A function-sharing device, characterized in that, The device includes: The acquisition unit is used to acquire a shared file of a functional kernel from a kernel provider server. The shared file includes a kernel constructor corresponding to the functional kernel. The kernel constructor is used to instantiate the functional kernel. The kernel provider server is used to provide a first functional service to a first client based on the functional kernel and to create the shared file of the functional kernel. The processing unit is used to call the kernel through the kernel constructor to provide the functional kernel shared by the server, and to provide the second functional service to the second client.
17. A computer device, characterized in that, The computer device includes a processor and a memory, the memory storing at least one program, which is loaded and executed by the processor to implement the function sharing method as described in any one of claims 12 to 15.
18. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores at least one piece of program code, which is loaded and executed by a processor to implement the function-sharing method as described in any one of claims 12 to 15.
19. A computer program product, characterized in that, It includes a computer program or instructions that, when executed by a processor, implement the function-sharing method as described in any one of claims 12 to 15.