Disclosure of Invention
The embodiment of the invention provides a method, a device, a server and a storage medium for calling a software development kit (Software Development Kit, SDK), which can solve the problems of long development time, high labor cost and poor universality in the related technology. The technical scheme is as follows:
in one aspect, there is provided an SDK calling method, the method including:
Acquiring a Software Development Kit (SDK) which comprises a functional program and interface configuration information corresponding to multiple ends;
configuring a target interface based on a function program included in the SDK and interface configuration information corresponding to a current end;
And calling a function program of the SDK based on the target interface to execute the function corresponding to the SDK.
In one aspect, there is provided an SDK calling device, the device including:
the system comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for acquiring a Software Development Kit (SDK) which comprises a function program and interface configuration information corresponding to multiple ends;
The configuration module is used for configuring a target interface based on the functional program included in the SDK and interface configuration information corresponding to the current end;
And the calling module is used for calling the function program of the SDK based on the target interface so as to execute the function corresponding to the SDK.
In one possible implementation, the plurality of functional programs includes a style configuration program and a business logic program;
The configuration module is used for:
Configuring a display interface based on a style configuration program included in the SDK and interface configuration information corresponding to a current end;
And configuring a service processing interface based on the service logic program included in the SDK and the interface configuration information corresponding to the current end.
In one possible implementation, the apparatus further includes:
and the updating module is used for updating the function program included in the SDK when receiving the updating request of the SDK.
In one possible implementation, the functional program included in the SDK may be implemented based on a syntax abstract tree;
and the updating module is used for updating the structure of the grammar abstract tree based on the content of the updating request when receiving the updating request of the SDK.
In one possible implementation, the apparatus further includes:
The acquiring module, the configuring module or the calling module is further configured to execute the steps of acquiring the software development kit SDK, configuring and calling when a call request to the SDK is received, where the call request is triggered based on an interaction operation performed on a plugin corresponding to any function program of the SDK, and the call request includes information of the plugin;
the calling module is used for calling any function program corresponding to the plug-in of the SDK based on the information of the target interface and the plug-in, and executing the function corresponding to the any function program.
In one aspect, a server is provided that includes one or more processors and one or more memories having at least one instruction stored therein, the instructions loaded and executed by the one or more processors to implement operations performed by the SDK invocation method.
In one aspect, a computer-readable storage medium having stored therein at least one instruction that is loaded and executed by a processor to implement the operations performed by the SDK calling method is provided.
The embodiment of the invention realizes the same function at multiple ends by adopting the mode of calling the SDK, and can configure the interfaces according to the function program and the interface configuration information corresponding to each end in the calling process, thereby directly calling the function program of the SDK to realize the corresponding function, and the development time and the labor cost are greatly reduced without developing an engineering file for each of different ends.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the present invention more apparent, the embodiments of the present invention will be described in further detail with reference to the accompanying drawings.
Fig. 1 is an implementation environment of an SDK call method provided in an embodiment of the present invention, and referring to fig. 1, the implementation environment may include a plurality of servers 101 and a code repository 102. Wherein the code repository 102 may be stored in one or more servers. Each server 101 may serve respective ends of the same network service. For example, the respective terminals may include a Web page (Web) terminal, an applet terminal, a light Application terminal, and an Application (APP) terminal.
In the embodiment of the present invention, the code repository 102 is used to provide a Software Development Kit (SDK), and each server 101 may obtain the SDK from the code repository 102 and call the SDK in the running process to implement the same function at different ends.
Fig. 2 is a flowchart of an SDK calling method according to an embodiment of the present invention, where the method may be applied to a server, and the server may be the server 101 shown in fig. 1. Referring to fig. 2, the method may include the steps of:
201. each server obtains the SDK from the code repository.
Wherein each server may refer to each end of the same network service. In the embodiment of the present invention, only the SDK is obtained from the code repository by each end, and the SDK is called for illustration, and for any end, the steps of the same principle can be executed, which is not limited by the embodiment of the present invention.
The SDK may include a function program and multi-terminal corresponding interface configuration information. The function program is a program corresponding to a function that can be realized by the SDK, and by executing the function program, a corresponding function can be realized. The SDK is suitable for multiple terminals, and can be called and function realized on a server where the multiple terminals are located through the interface configuration information corresponding to the multiple terminals.
For example, in some scenarios, the SDK may create a collection of application software development tools for a software package, software framework, hardware platform, operating system, etc. provided by a third party developer, and the SDK may be applied as a plug-in to existing products, such as advertisement plug-ins, chart plug-ins, voting plug-ins, weather plug-ins, or other custom plug-ins, etc. to corresponding projects and products.
The steps required to be executed by each server can also be different when the SDK is called because the running environments of different ends are different. Therefore, each server can acquire the information of each end first, and a corresponding processing mode is adopted based on the information of each end. For a server, the information of the current end can be acquired first, and corresponding steps are adopted based on the information of the current end.
In one possible implementation, the obtaining of the SDK from the code repository by the respective servers may be triggered based on a call request to the SDK, and for either end, the user may perform an operation, and the server detects the operation of the user, and calls the SDK based on the operation.
In a specific possible embodiment, the SDK may include one function program or may include a plurality of function programs, and each function program may correspond to one function. Any function program can be displayed in a display interface provided by the server in a corresponding plug-in mode, so that a user can perform interactive operation on the plug-in, and further trigger the call request for the SDK.
The call request can be triggered based on the interaction operation performed on the plugin corresponding to any function program of the SDK, and the call request comprises the information of the plugin. Thus, in the steps 201 to 203, each server may call any one of the function programs corresponding to the plug-in of the SDK based on the information of the target interface and the plug-in, and execute the function corresponding to the any one of the function programs.
202. Each server configures the target interface based on the function program included in the SDK and the interface configuration information corresponding to each end.
After each server obtains the SDK, the function program of the SDK is encapsulated in the SDK, and if the function program of the SDK is required to be called, the configuration is required.
In one possible implementation, after each server obtains the SDK, the SDK may be initialized before executing the function program, before this step 202. For example, in the initialization process, the execution environment of the SDK may be initialized, header files required for calling the SDK may be imported, execution parameters may be initialized, and then the target interface may be configured after the SDK is initialized.
In a specific possible embodiment of step 201, the SDK may include a plurality of functional programs. Wherein each functional program may correspond to a different target interface. The step 202 may be that each server configures each target interface in the multiple target interfaces based on each function program included in the SDK and the interface configuration information corresponding to each end, where each target interface corresponds to each function program. For any end, the server at the end can configure each target interface in the multiple target interfaces based on each function program included in the SDK and the interface configuration information corresponding to the current end.
When the target interface is configured, the interface configuration information of the SDK can be written into the target interface, parameters of the target interface can be adjusted through the writing step, and then the SDK can be called through the target interface after the parameters are adjusted. Of course, if the SDK includes a plurality of functional programs, when configuring a plurality of target interfaces, information of each functional program may be written into a corresponding target interface, and a corresponding relationship is established between the two, and the corresponding functional program may be called based on the target interface.
In a specific possible embodiment, the plurality of functional programs includes a style configuration program and a business logic program. The style configuration program may be used to indicate a display style. The business logic program is used to indicate the processing logic that needs to be executed. For example, if a display style of a certain plug-in is determined, its display style may be determined based on the style configuration program. From a server perspective, after the user performs an interactive operation, the server may determine an interactive result of feedback required for the interactive operation based on the business logic program.
In this embodiment, the server may perform different configuration processing for different functional programs, where the server may configure the display interface based on the style configuration program included in the SDK and the interface configuration information corresponding to the current end, and configure the service processing interface based on the service logic program included in the SDK and the interface configuration information corresponding to the current end.
203. And each server calls the function program of the SDK based on the target interface so as to execute the function corresponding to the SDK.
After each server configures the target interface, the function program of the SDK can be called based on the target interface to realize the corresponding function.
In the implementation manner that the SDK includes a plurality of functional programs, each server may call, based on any one of the target interfaces, a functional program corresponding to the any one of the target interfaces according to the configuration parameters of the any one of the target interfaces, and execute a function corresponding to the functional program. For one end, the server at the end can be based on any target interface, and can call the function program corresponding to any target interface according to the configuration parameters of any target interface, and execute the function corresponding to the function program.
For example, in a specific example, as shown in fig. 3, taking the example of invoking the SDK at the Web side, after the SDK is initialized, the target interface may be configured. In this example, each function program is taken as a function module, and the SDK includes a User Interface (UI) rendering module, an event binding module, a service logic module, and a data reporting module, and may further include a morphological configuration. For the plurality of functional modules, the morphological configuration is the style configuration program, and based on the morphological configuration, a display style when UI rendering is performed can be determined. For the plug-in unit of UI rendering display, if the user carries out interactive operation on the plug-in unit, the processing mode of the event binding of the interactive operation can be determined according to the event configuration module, so that the business logic module is called to carry out corresponding business processing, and after the processing, data can be reported to a server or fed back to a user interaction result. The Web interfaces (target interfaces) may include a display interface (Render Application Programming Interface, RENDER API), an event binding interface (API), a business logic API, and a data reporting API. And when the target interfaces are configured, the corresponding relation between each functional module and the API can be configured, and each functional module can be called through each target interface to realize the corresponding function.
In the above specific example, as shown in fig. 4, the specific flow of the SDK call may specifically be the following steps, and in the following flow, the Web end is taken as an example, and the functions of the server are named according to the different functions executed by the server. The method comprises the following steps:
Step one, a user accesses a Web end product and enables a specific plug-in. The specific plug-in is the functional plug-in corresponding to the SDK.
Step two, the SDK initializing module initializes the SDK environment of the plug-in, namely, initializes the SDK, and after the initialization is successful, the SDK initializing module can return the initialization success.
And thirdly, initializing a framework by the SDK initializing module through a Web interface.
And fourthly, the SDK initialization module registers the multi-terminal isomorphic framework in a Web interface.
The third and fourth steps are the steps of configuring the target interface.
And fifthly, after the configuration is successful, the multi-terminal isomorphic framework can read the style configuration to perform UI rendering and event binding.
And step six, the UI rendering is successful, namely, the plug-in is displayed for the user to watch, and the user can perform interactive operation on the plug-in.
And step seven, the functional modules in the multi-terminal isomorphic framework can determine to respond to the event of the interactive operation, process the event according to the service logic and report the data to the server.
And step eight, returning an interaction result to the user based on the Web interface.
With the above, as shown in fig. 5, the call procedure of the SDK may support multi-port call, for example, a WEB port, a applet port, and other platforms. The SDK can be installed on each platform as a plug-in, and is used for realizing a certain service. The SDK can be initialized, and the interface realization of each platform can be carried out, and in the calling process carried out by any platform, the SDK provides the interface realization of the current platform according to the specification of the multi-terminal isomorphic framework. For example, a WEB interface implementation, a applet interface implementation, a small game interface implementation or other interface implementation, through which registration and call of a multi-terminal isomorphic framework can be completed, so as to realize call of an SDK, wherein the multi-terminal shares the same SDK, or the multi-terminal shares the same multi-terminal isomorphic framework, and unified service logic can be realized.
In contrast, as shown in fig. 6, in the related art, a developer typically develops a framework, where the framework may include front-end logic codes, and uses an abstract syntax tree to disassemble the code conversion into a template (template) file, a business logic file, and a style configuration file, so that the files are constructed as a process by an engineering builder and deployed at different ends. When in deployment, frame conversion is needed according to the end to be deployed, a frame applicable to the end is constructed, and deployment is completed. The framework must be developed in its entirety in the deployment process usage field Jing Shouxian in the related art, and cannot be applied to the product development of plug-in classes as the SDK calling method provided by the embodiment of the present invention, and cannot be introduced into existing products. And the development of the framework in the related technology is generally aimed at a certain platform or a certain platforms, and some platforms are not supported, so that a developer needs to re-develop a new framework. The access of new features in the related technology is limited, and for the new features newly supported by each platform, a developer can only wait for updating of a frame version or can only manually modify the existing frame source code, and the complexity of the frame source code is extremely high, so that the developer is difficult to modify.
The method provided by the embodiment of the invention uniformly manages the universal business logic in the framework, is beneficial to reducing the development time and labor cost, and is beneficial to the maintenance of program codes and the long-term development of products. For example, in an application scenario of an advertisement plug-in, assuming that the advertisement plug-in supports three different platforms, respectively, 5 persons/day are required to develop a new advertisement style or a new function on each platform on average, the sum of the development amounts of the three platforms is 15 persons/day by means of the above-described related art. In the method provided by the embodiment of the invention, as the style configuration and the business logic are uniformly managed by the isomorphic framework, a developer only needs to realize a new advertisement style or a new function in the framework, and the total development amount only needs 5 people/day.
In addition, in the method provided by the embodiment of the invention, each platform respectively provides the realization of the interface, and the framework is only responsible for unified scheduling, so that the method is beneficial to the access of a new platform and new characteristics and the rapid development of products.
204. When receiving the update request of the SDK, each server updates the function program included in the SDK.
If the function program in the SDK is updated, each server can directly update the function program in the SDK without waiting for platform version update or redevelopment as in the related art, and the update is convenient and quick.
In one possible implementation, the function program included in the SDK may be further implemented based on a syntax abstract tree, and this step 204 may be that, when receiving the update request of the SDK, each server updates the structure of the syntax abstract tree based on the content of the update request. The abstract grammar tree mode is very beneficial to the updating of the functional program by a developer specially developing the business logic program. For any end, the steps of the same principle can be performed, which will not be repeated.
The embodiment of the invention realizes the same function at multiple ends by adopting the mode of calling the SDK, and can configure the interfaces according to the function program and the interface configuration information corresponding to each end in the calling process, thereby directly calling the function program of the SDK to realize the corresponding function, and the development time and the labor cost are greatly reduced without developing an engineering file for each of different ends.
Any combination of the above optional solutions may be adopted to form an optional embodiment of the present invention, which is not described herein.
Fig. 7 is a schematic structural diagram of an SDK calling device according to an embodiment of the present invention, referring to fig. 7, the device may include:
An obtaining module 701, configured to obtain a software development kit SDK, where the SDK includes a function program and interface configuration information corresponding to multiple ends;
a configuration module 702, configured to configure a target interface based on a function program included in the SDK and interface configuration information corresponding to a current end;
And a calling module 703, configured to call a function program of the SDK based on the target interface, so as to execute a function corresponding to the SDK.
In one possible implementation, the SDK includes a plurality of functional programs;
the configuration module 702 is configured to configure each target interface of the plurality of target interfaces based on each function program included in the SDK and interface configuration information corresponding to the current end, where each target interface corresponds to each function program.
In one possible implementation, the plurality of functional programs includes a style configuration program and a business logic program;
The configuration module 702 is configured to:
Configuring a display interface based on a style configuration program included in the SDK and interface configuration information corresponding to a current end;
And configuring a service processing interface based on the service logic program included in the SDK and the interface configuration information corresponding to the current end.
In one possible implementation, the apparatus further includes:
and the updating module is used for updating the function program included in the SDK when receiving the updating request of the SDK.
In one possible implementation, the functional program included in the SDK may be implemented based on a syntax abstract tree;
and the updating module is used for updating the structure of the grammar abstract tree based on the content of the updating request when receiving the updating request of the SDK.
In one possible implementation, the apparatus further includes:
The obtaining module 701, the configuring module 702 or the calling module 703 is further configured to execute the steps of obtaining the software development kit SDK, configuring and calling when a call request to the SDK is received, where the call request is triggered based on an interaction performed on a plug-in corresponding to any function program of the SDK, and the call request includes information of the plug-in;
The calling module 703 is configured to call, based on the information of the target interface and the plug-in, the arbitrary function program corresponding to the plug-in of the SDK, and execute a function corresponding to the arbitrary function program.
The device provided by the embodiment of the invention realizes the same function at multiple ends by adopting the mode of calling the SDK, and can configure the interfaces according to the function program and the interface configuration information corresponding to each end in the calling process, thereby directly calling the function program of the SDK to realize the corresponding function, and the development time and the labor cost are greatly reduced without developing an engineering file for each of different ends.
It should be noted that, when the SDK is called, the SDK calling device provided in the foregoing embodiment only uses the division of the foregoing functional modules to illustrate, in practical application, the foregoing functional allocation may be completed by different functional modules according to needs, that is, the internal structure of the server is divided into different functional modules to complete all or part of the functions described above. In addition, the SDK calling device and the SDK calling method embodiment provided in the foregoing embodiments belong to the same concept, and specific implementation processes thereof are detailed in the method embodiment, and are not described herein again.
Fig. 8 is a schematic structural diagram of a server according to an embodiment of the present invention, where the server 800 may include one or more processors (central processing units, CPU) 801 and one or more memories 802, where the one or more memories 802 store at least one instruction, and the at least one instruction is loaded and executed by the one or more processors 801 to implement the SDK calling method provided in the foregoing method embodiments. Of course, the server 800 may also have a wired or wireless network interface, a keyboard, an input/output interface, and other components for implementing the functions of the device, which are not described herein.
In an exemplary embodiment, a computer readable storage medium, such as a memory including instructions executable by a processor to perform the SDK invocation method of the above embodiments is also provided. For example, the computer readable storage medium may be Read-Only Memory (ROM), random-access Memory (Random Access Memory, RAM), compact disc Read-Only Memory (CD-ROM), magnetic tape, floppy disk, optical data storage device, and the like.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program for instructing relevant hardware, where the program may be stored in a computer readable storage medium, and the above storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
The foregoing description of the preferred embodiments of the invention is not intended to be limiting, but rather is intended to cover all modifications, equivalents, alternatives, and improvements that fall within the spirit and scope of the invention.