Function service processing method, device and electronic device
Through a function service processing method, including obtaining and compiling the source code and configuration files of the function service, building images and storing them in the warehouse, the problem of convenient development of FaaS services is solved and an efficient development and deployment process is realized.
Patent Information
- Application Number
- CN202210267570.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-17
- Publication Date
- 2025-06-10
- Estimated Expiration
- 2042-03-17
AI Technical Summary
How to conveniently develop services based on FaaS technology so that users can enjoy the convenience brought by serverless computing.
A function service processing method is proposed, including obtaining the image corresponding to the integrated development environment, creating a container based on the image, obtaining the source code and configuration files of the function service, compiling and generating service files, building the image and storing it in the warehouse.
Provide an integrated development environment without independent installation and updates during the coding stage, improve the startup rate and compilation efficiency of the integrated development environment, reduce the amount of code written by users, reduce the cost of function service development, and reduce the image acquisition time during the deployment stage.
Smart Images

Figure CN114721659B_ABST
Abstract
Description
Technical Field
[0001] One or more embodiments of this specification relate to the field of cloud computing technology, and in particular, to a function service processing method, apparatus, and electronic device. Background Art
[0002] The core of cloud computing technology is service-oriented technology. With the continuous development of cloud computing technology, from the initial infrastructure service-oriented (i.e., IaaS, Infrastructure as a Service) technology, platform service-oriented (i.e., PaaS, Platform as a Service) technology, software service-oriented (i.e., SaaS, Software as a Service) technology, more types of service-oriented technologies have emerged one after another. One type of service-oriented technology is FaaS technology.
[0003] FaaS is an abbreviation for Functions as a Service, which can be broadly understood as function service orientation or can also be interpreted as function service virtualization. When using FaaS, only the code logic needs to be concerned, without the need to pay attention to server resources. Therefore, FaaS is also closely related to Serverless (Serverless computing). Serverless computing provides a software system architecture that does not require the deployment, configuration, or management of server resources, and all server resources required to run the code are provided by the cloud platform.
[0004] With the increasingly widespread application of FaaS technology, how to develop services based on FaaS technology conveniently so that users can also enjoy the convenience brought by serverless computing when using the service has become an urgent problem to be solved. Summary of the Invention
[0005] This specification proposes a function service processing method, and the method includes:
[0006] In response to obtaining a first image corresponding to an integrated development environment from a repository for storing images, creating a first container based on the first image; wherein, the first container is used to run the integrated development environment;
[0007] Obtaining the source code corresponding to the function service to be built, and obtaining a configuration file for building a second image corresponding to the function service;
[0008] Compiling the source code based on the integrated development environment to generate a service file corresponding to the function service;
[0009] Build the second image based on the service file and the configuration file, and store the second image in the repository.
[0010] Optionally, the obtaining the source code corresponding to the function service to be built includes:
[0011] Output, through the user interface corresponding to the integrated development environment, a code framework corresponding to the service type of the function service to the user;
[0012] Obtain the code filled by the user into the code framework, and generate the source code corresponding to the function service based on the code and the code framework.
[0013] Optionally, the obtaining the configuration file for building the second image corresponding to the function service includes:
[0014] Generate a configuration file corresponding to the service type of the function service.
[0015] Optionally, the compiling the source code based on the integrated development environment to generate a service file corresponding to the function service includes:
[0016] Compile the source code based on the integrated development environment to generate an object file corresponding to the function service;
[0017] Obtain the dependency file corresponding to the function service, and determine the object file and the dependency file as the service file corresponding to the function service.
[0018] Optionally, the building the second image based on the service file and the configuration file, and storing the second image in the repository includes:
[0019] If the compilation is successful, build the second image based on the service file and the configuration file, and store the second image in the repository;
[0020] The method further includes:
[0021] If the compilation fails, output a compilation failure prompt message to the user through the user interface corresponding to the integrated development environment.
[0022] Optionally, the method further includes:
[0023] In response to obtaining the second image from the repository, create a second container based on the second image to deploy the function service and generate a corresponding deployment log; wherein, the second container is used to run the function service;
[0024] Input the preset service parameters into the function service for calculation to test the function service and generate corresponding test logs;
[0025] Visualize and display the deployment logs and the test logs to the user.
[0026] Optionally, the image is a Docker image; the container is a Docker container; the configuration file is a Dockerfile.
[0027] Optionally, the integrated development environment includes a web-based integrated development environment.
[0028] This specification also proposes a function service processing device, which includes:
[0029] A creation module, configured to create a first container based on the first image in response to obtaining the first image corresponding to the integrated development environment from the repository for storing images; wherein the first container is used to run the integrated development environment;
[0030] An acquisition module, configured to acquire the source code corresponding to the function service to be built and acquire the configuration file for building the second image corresponding to the function service;
[0031] A generation module, configured to compile the source code based on the integrated development environment to generate a service file corresponding to the function service;
[0032] A construction module, configured to build the second image based on the service file and the configuration file and store the second image in the repository.
[0033] Optionally, the acquisition module is specifically configured to:
[0034] Output, through the user interface corresponding to the integrated development environment, a code framework corresponding to the service type of the function service to the user;
[0035] Acquire the code filled in by the user into the code framework and generate the source code corresponding to the function service based on the code and the code framework.
[0036] Optionally, the acquisition module is specifically configured to:
[0037] Generate a configuration file corresponding to the service type of the function service.
[0038] Optionally, the generation module is specifically configured to:
[0039] Compile the source code based on the integrated development environment to generate an object file corresponding to the function service;
[0040] Obtain the dependency file corresponding to the function service, and determine the target file and the dependency file as the service file corresponding to the function service.
[0041] Optionally, the building module is specifically configured to:
[0042] If the compilation is successful, build the second image based on the service file and the configuration file, and store the second image in the repository;
[0043] The apparatus further includes:
[0044] A prompt module, configured to output a prompt message indicating compilation failure to the user through a user interface corresponding to the integrated development environment when the compilation fails.
[0045] Optionally, the apparatus further includes:
[0046] A deployment module, configured to, in response to obtaining the second image from the repository, create a second container based on the second image to deploy the function service and generate a corresponding deployment log; wherein, the function service runs in the second container;
[0047] A testing module, configured to input preset service parameters into the function service for calculation to test the function service and generate a corresponding test log;
[0048] A display module, configured to visually display the deployment log and the test log to the user.
[0049] Optionally, the image is a Docker image; the container is a Docker container; the configuration file is a Dockerfile.
[0050] Optionally, the integrated development environment includes a web-based integrated development environment.
[0051] This specification also proposes an electronic device, including:
[0052] A processor;
[0053] A memory for storing executable instructions of the processor;
[0054] Wherein, the processor runs the executable instructions to implement the steps of the method as described in any one of the above.
[0055] This specification also proposes a computer-readable storage medium, on which computer instructions are stored, and when the instructions are executed by a processor, the steps of the method as described in any one of the above are implemented.
[0056] In the above technical solution, first, the image corresponding to the integrated development environment can be downloaded to the host in advance, and subsequently, the integrated development environment running in the form of a container can be used to build the image corresponding to the function service. In this way, during the coding stage, an integrated development environment that does not require the user to install and update independently on the device can be provided; and during the building stage, the startup rate and compilation efficiency of the integrated development environment can be improved, thereby improving the building speed of the image corresponding to the function service.
[0057] Second, the code framework corresponding to the service type of the function service to be built can be preset in the above integrated development environment. In this way, during the coding stage, the amount of code that the user needs to write can be reduced, thereby reducing the development cost of the function service.
[0058] Third, the integrated development environment running in the form of a container can be a web-based integrated development environment. Therefore, during the coding stage, various additional functions can be provided for the user by the plug-ins built in the integrated development environment.
[0059] Finally, when deploying the built function service, the image corresponding to the function service can be downloaded to the host in advance. Subsequently, the function service running in the form of a container can be tested, and the deployment log and test log corresponding to the function service can be visually displayed to the user. In this way, during the deployment stage, the time consumed waiting to obtain the image corresponding to the function service can be reduced, and the user can understand the deployment process of the function service and make corresponding adjustments to the function service according to the test results. Description of the Drawings
[0060] Figure 1 is a schematic diagram of a Docker software architecture shown in an exemplary embodiment of this specification.
[0061] Figure 2 is a schematic diagram of the architecture of a function service processing system shown in an exemplary embodiment of this specification.
[0062] Figure 3 is a schematic diagram of a function service processing method shown in an exemplary embodiment of this specification.
[0063] Figure 4 is a flowchart of another function service processing method shown in an exemplary embodiment of this specification.
[0064] Figure 5 is a hardware structure diagram of the electronic device where a function service processing device is located shown in an exemplary embodiment of this specification.
[0065] Figure 6It is a block diagram of a function service processing device shown in an exemplary embodiment of this specification. Detailed implementation manners
[0066] Here, the exemplary embodiments will be described in detail, and the examples are shown in the accompanying drawings. When the following description refers to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementation manners described in the following exemplary embodiments do not represent all the implementation manners consistent with one or more embodiments of this specification. On the contrary, they are only examples of devices and methods consistent with some aspects of one or more embodiments of this specification as detailed in the appended claims.
[0067] It should be noted that: in other embodiments, the steps of the corresponding methods are not necessarily executed in the order shown and described in this specification. In some other embodiments, the steps included in the method may be more or less than those described in this specification. In addition, a single step described in this specification may be decomposed into multiple steps for description in other embodiments; and multiple steps described in this specification may also be combined into a single step for description in other embodiments.
[0068] In practical applications, for FaaS (Functions as a Service), the FaaS technology is a technology that can achieve serverless computing. When using FaaS, only the code logic needs to be concerned, and there is no need to concern about server resources. Therefore, FaaS is also closely related to Serverless (Serverless computing). Serverless computing provides a software system architecture that does not require the deployment, configuration, or management of server resources, and all the server resources required to run the code are provided by the cloud platform.
[0069] That is to say, the FaaS technology allows users to build, run, and manage application programs in the form of functions without maintaining their own software system architectures.
[0070] For application programs, the operation of application programs usually depends on the underlying operating system and related environments. To improve the deployment efficiency of application programs and reduce the workload of users when deploying application programs, there is usually a problem of needing to focus on the application programs themselves while reusing the underlying operating system and related environments. For example: after installing the operating system and related environments on a device and successfully deploying the application program on this device, if it is necessary to transplant the application program to another device, it is hoped that there is no need to install the operating system and the related environments on this other device either. In this case, container technology emerged as the times require.
[0071] Container technology is a lightweight operating system-level virtualization technology for the kernel. In related technologies, common container technologies usually include Docker, Kubernetes, CoreOS, etc. Taking Docker as an example, Docker is an open-source application container engine that enables the files of the application itself and the dependency files corresponding to the application to be packaged into a portable image, and the image can be published to any device running the Linux operating system or the Windows operating system to achieve virtualization.
[0072] For containers, a container is a relatively independent running environment. Containers fully adopt the sandbox mechanism (also known as a sand box), and there will be no interfaces between them. In addition, within the container, the impact on the outside world should be minimized. For example, resource control is performed on the container, that is, the host cannot use all the resources in the container.
[0073] A container contains a complete running environment. In addition to the application files included in the application itself, the dependency files required to run the application can all be packaged into the image. By packaging the application itself and its dependencies, the underlying operating system and related environments can be abstracted.
[0074] A container has an independent file system. Since the container uses system resources, there is no need for kernel-related code or tools in the independent file system. As long as the file set in the image is available, the container created based on the image can run.
[0075] Based on this, users can write code to implement specific functions and generate an application based on these codes. The application can run in a container completely managed by the platform. Among them, the platform is usually located in the cloud. In this case, the application can be regarded as a FaaS service (hereinafter referred to as a function service).
[0076] Taking Docker as an example below, the software architecture in container technology will be described. Please refer to Figure 1 , Figure 1 which is a schematic diagram of a Docker software architecture shown in an exemplary embodiment of this specification.
[0077] As Figure 1 shown, the Docker client communicates with the Docker daemon using the Docker SDK through a command-line tool or other tools;
[0078] The Docker host is a physical or virtual device used to run the Docker daemon and Docker containers;
[0079] Docker images are templates used to create Docker containers;
[0080] A Docker container is one or a group of applications that run independently and is the entity when a Docker image runs;
[0081] A Docker registry is used to store Docker images.
[0082] Docker adopts a C / S (Client / Server) architecture. Specifically, the Docker client can be regarded as the client in the C / S architecture, and the Docker host can be regarded as the server in the C / S architecture. In this case, users can enter various Docker commands in the Docker client, and these commands will be sent to the Docker daemon running on the Docker host. The Docker daemon is responsible for implementing various Docker functions according to these commands.
[0083] In addition to the command-line interface of the Docker client, Docker also provides other ways to communicate with the Docker daemon, such as through the Remote API. Users can interact with custom applications (such as applications written in programming languages like C++ or Java), and these applications can communicate with the Docker daemon by calling the Remote API.
[0084] Please refer to Figure 2 , Figure 2 which is a schematic diagram of the architecture of a function service processing system shown in an exemplary embodiment of this specification.
[0085] As Figure 2 shown, the system may include a network 10, a server 11, and several electronic devices, such as mobile phones 12, 13, and 14, etc.
[0086] The server 11 can be a physical server containing an independent host, or the server 11 can be a virtual server, cloud server, etc. hosted by a host cluster. Mobile phones 12 - 14 are just one type of electronic device that users can use. In fact, users can obviously also use the following types of electronic devices: tablet devices, laptops, PDAs (Personal Digital Assistants), wearable devices (such as smart glasses, smart watches, etc.), etc. One or more embodiments of this specification do not limit this. The network 10 can include various types of wired or wireless networks.
[0087] Taking Docker as an example, the Docker client or a user-defined application can be deployed on Mobile Phones 12 - 14 to communicate with Server 11 which acts as a Docker host. Alternatively, the Docker client or a user-defined application can be directly deployed on Server 11 which acts as a Docker host.
[0088] Please refer to Figure 3 , Figure 3 which is a flowchart of a function service processing method shown in an exemplary embodiment of this specification.
[0089] The above function service processing method can be applied to Server 11 as shown in Figure 2 . Server 11 can act as a host in container technology, for example: a Docker host. The function service processing method can implement the construction of an image corresponding to the function service, including the following steps:
[0090] Step 301, in response to obtaining a first image corresponding to an integrated development environment from a repository for storing images, create a first container based on the first image; wherein, the first container is used to run the integrated development environment.
[0091] In practical applications, users can develop and compile applications through an Integrated Development Environment (IDE). Among them, an integrated development environment is an application for providing a development environment, generally including tools such as a code editor, a compiler, and a user interface, and is an integrated application development software integrating functions such as code writing and compilation.
[0092] In this embodiment, for the convenience of users to use the integrated development environment, an image (which can be called the first image) can be pre-constructed based on the integrated development environment and the constructed first image can be stored in a repository for storing images. Subsequently, the above host can, in response to obtaining the first image from the repository, create a container (which can be called the first container) based on the first image; at this time, the application running in the first container is the integrated development environment. In this case, since the integrated development environment can be run in the form of a container, therefore, it is not necessary for the user to independently install and update the integrated development environment on the device, but the applicable operating system and related environment for the integrated development environment can be provided through the container.
[0093] In practical applications, if the number of images stored in the above repository is small, the repository can be directly deployed in the above host to facilitate the host to obtain images from the repository.
[0094] However, if there are a large number of images stored in the above-mentioned repository, the repository will occupy a large amount of storage resources. To save the storage resources of the above-mentioned host, the repository can be deployed on other devices independent of the host. In this case, the host needs to communicate with the device where the repository is located to obtain images from the repository. To reduce the time consumed waiting for the above-mentioned first image to be transferred from the device where the repository is located to the host before creating the above-mentioned first container on the host, the host can pre-obtain the first image from the repository and store the obtained first image locally.
[0095] In an illustrated embodiment, the above integrated development environment may be a web-based integrated development environment (which may be referred to as a web-IDE), that is, the web-IDE application is a web application.
[0096] For a container, the port provided by the container for the web application running therein can be mapped to the port of the host on which the container is running. In this case, the mapped port of the host can be accessed through a browser to access the web application. For example, assume that the port provided by the above-mentioned first container for the above-mentioned web-IDE is 5000, the port mapping is the port 32796 of the above-mentioned host, and the IP address of the host is 192.168.239.130. Then, the web-IDE can be accessed by entering 192.168.239.130:32796 in the address bar of the browser.
[0097] It should be noted that the above browser can be a browser provided by the host itself or a browser provided by other devices communicating with the host. This specification does not limit this.
[0098] Since the above web-IDE is a web application, plugins (such as browser plugins) can be built into the web-IDE for the web-IDE to call, so that the web-IDE can provide users with more functions related to application development, such as LSP, Debug, and other functions.
[0099] Step 302, obtain the source code corresponding to the function service to be built, and obtain the configuration file for building the second image corresponding to the function service.
[0100] In practical applications, when a user needs to build a function service for implementing specific functions, the user can write code for these functions and generate an application program as the function service based on the code written by the user; at this time, these codes are the source codes corresponding to the function service.
[0101] Since the function service can be an application running in a container, it is possible to build an image corresponding to the function service based on the configuration file corresponding to the image used to build the above function service, and store the built image in the above repository, so that subsequently, a container for running the function service can be created based on the image obtained from the repository to implement the running of the function service.
[0102] In this embodiment, for the function service to be built, on the one hand, the above host can obtain the source code corresponding to the function service, and on the other hand, it can obtain the configuration file for building the image (which can be called the second image) corresponding to the function service.
[0103] Specifically, on the one hand, the user can input the source code corresponding to the above function service through the user interface provided by the above integrated development environment for writing code.
[0104] On the other hand, taking Docker as an example, the above host can be a Docker host, the above image can be a Docker image, the above container can be a Docker container, and the above repository can be a Docker repository. In this case, the above configuration file can be a Dockerfile. Among them, the Dockerfile is a text file used to build an image, and the text content in the Dockerfile usually contains the commands and instructions required for building the image.
[0105] In order to facilitate the user in writing the source code corresponding to the function service, in one shown embodiment, multiple code frameworks can be preset.
[0106] For any one code framework, the code framework can correspond to a service type of the function service. Since the source code corresponding to the function services belonging to the same service type usually contains more duplicate code, this part of the duplicate code can be used as the code framework corresponding to the service type.
[0107] Subsequently, through the user interface corresponding to the above integrated development environment, the code framework corresponding to the service type of the above function service to be built can be output to the user, so that the user can fill in the specific source code corresponding to the function service in the code framework in the user interface, such as function input parameters, function judgment expressions, etc.
[0108] When the above host obtains the code filled by the user into the above code framework, it can further generate the source code corresponding to the above function service based on the code filled by the user and the code framework.
[0109] Similarly, in one shown embodiment, multiple configuration files can be preset.
[0110] For any configuration file, the configuration file can correspond to a service type of the function service. Since the configuration files used to build the images corresponding to the function services belonging to the same service type are usually the same or highly similar, a corresponding configuration file can be set for this service type.
[0111] Subsequently, the above host can generate a configuration file corresponding to the service type of the above function service to be built, and determine this configuration file as the configuration file for building the above second image corresponding to this function service.
[0112] Step 303: Compile the source code based on the integrated development environment to generate a service file corresponding to the function service.
[0113] In practical applications, taking the Linux operating system using the C language as an example, generating an application program based on the source code usually requires two main processes. First, the source code can be compiled to generate an object file corresponding to the application program (Object File, usually an.o file, that is, the file extension is o); subsequently, the generated object file can be linked with the static library file corresponding to the application program (usually an.a file, that is, the file extension is a), and the linked object file can be regarded as an executable file; since an application program usually includes multiple executable files and multiple dynamic library files (usually.so files, that is, the file extension is so) required for normal operation, these executable files and these dynamic library files can be packaged to generate this application program.
[0114] In this embodiment, when the above host obtains the source code corresponding to the above function service to be built, it can compile the source code based on the above integrated development environment to generate a service file corresponding to this function service. Among them, the service file corresponding to this function service can include object files, executable files, dynamic library files, etc.
[0115] In an illustrated implementation manner, after compiling the source code corresponding to the above function service to be built based on the above integrated development environment, an object file corresponding to this function service can be generated. In addition, a dependency file corresponding to this function service can also be obtained. Among them, the dependency file corresponding to this function service can be a.so file in the C language or a jar package in the Java language, and this specification does not limit this. In this case, both the object file corresponding to this function service and the dependency file corresponding to this function service can be determined as the service file corresponding to this function service.
[0116] It should be noted that the above-dependent files can be stored in the above host, or can be stored in other devices communicating with the host and pre-downloaded to the host. This specification does not limit this.
[0117] Step 304: Build the second image based on the service file and the configuration file, and store the second image in the repository.
[0118] In this embodiment, when the above host generates a service file corresponding to the function service to be built through compilation by the above integrated development environment and obtains a configuration file for building the second image corresponding to the function service, it can further build the second image based on the service file and the configuration file, and store the built second image in the above repository.
[0119] For the above second image, the above host can, in response to obtaining the second image from the repository, create a container based on the second image; at this time, the application program running in the container is the above function service. In this case, since the function service can be run in the form of a container, it is not necessary for the user to install and update the function service on the device independently, but the applicable operating system and related environment for the function service can be provided through the container, so that serverless computing can be achieved.
[0120] In an illustrated implementation manner, if the compilation is successful, the second image can be directly built based on the service file and the configuration file, and the built second image is stored in the above repository.
[0121] However, if the compilation fails, a prompt message indicating the compilation failure can be output to the user to prompt that there may be a problem with the source code corresponding to the above function service, or an exception occurs during the compilation process. For example, a prompt message indicating the compilation failure can be output to the user through the user interface corresponding to the above integrated development environment.
[0122] Please refer to Figure 4 , Figure 4 which is a flowchart of another function service processing method shown in an exemplary embodiment of this specification.
[0123] The above function service processing method can be applied to a server 11 as shown in Figure 2 ; the server 11 can be used as a host in container technology, for example: a Docker host. The function service processing method can, after building an image corresponding to the function service, implement the deployment of the function service based on the image.
[0124] It should be noted that as Figure 4The host used to deploy the above function service in the shown function service processing method, and the host used to build the function service in the function service processing method shown in Figure 3 can be the same host or different hosts, and this specification does not limit this.
[0125] The above function service processing method may include the following steps:
[0126] Step 401: In response to obtaining the second image from the repository, create a second container based on the second image to deploy the function service and generate corresponding deployment logs; wherein, the second container is used to run the function service.
[0127] In this embodiment, when the above host builds the above second image corresponding to the above function service and stores the built second image in the above repository, it can further respond to obtaining the second image from the repository and create a container (which can be called the second container) based on the second image, that is, deploy the function service; at this time, the application program running in the second container is the function service.
[0128] It should be noted that in order to reduce the time consumed waiting for the second image to be transmitted from the device where the repository is located to the host before creating the second container on the above host, the host can pre-obtain the second image from the repository and store the obtained second image locally.
[0129] In addition, the above host can also record the data generated during the deployment process and generate corresponding deployment logs.
[0130] Step 402: Input preset service parameters into the function service for calculation to test the function service and generate corresponding test logs.
[0131] In this embodiment, the preset service parameters can be input into the above function service, and the function service calculates based on the input service parameters to test the function service.
[0132] In addition, the above host can also record the data generated during the test process and generate corresponding test logs.
[0133] Step 403: Visually display the deployment logs and the test logs to the user.
[0134] In this embodiment, the above host can visually display the above deployment logs and the above test logs to the user, so that the user can understand the deployment process of the above function service and make corresponding adjustments to the function service according to the test results.
[0135] It should be noted that for a certain function service, multiple versions of images corresponding to the function service can be stored in the above-mentioned repository. In this case, multi-version control for the function service can be achieved, that is, multiple versions of the function service can be deployed simultaneously, and the size of the traffic processed by different versions of the function service can be controlled, so that the function service can be smoothly upgraded.
[0136] In the technical solution shown in the above embodiment, first, the image corresponding to the integrated development environment can be downloaded to the host in advance, and subsequently, the integrated development environment running in the form of a container can be used to build the image corresponding to the function service. By adopting this method, an integrated development environment that does not need to be independently installed and updated on the device can be provided for users during the coding stage; and during the building stage, the startup rate and compilation efficiency of the integrated development environment can be improved, thereby improving the building speed of the image corresponding to the function service.
[0137] Secondly, a code framework corresponding to the service type of the function service to be built can be preset in the above-mentioned integrated development environment. By adopting this method, the amount of code that the user needs to write can be reduced during the coding stage, thereby reducing the development cost of the function service.
[0138] Thirdly, the integrated development environment running in the form of a container can be a web-based integrated development environment. Therefore, during the coding stage, various additional functions can be provided for users by the plugins built in the integrated development environment.
[0139] Finally, when deploying the built function service, the image corresponding to the function service can be downloaded to the host in advance, and subsequently, the function service running in the form of a container can be tested, and the deployment log and test log corresponding to the function service can be visually displayed to the user. By adopting this method, during the deployment stage, the time consumed waiting to obtain the image corresponding to the function service can be reduced, and the user can understand the deployment process of the function service and make corresponding adjustments to the function service according to the test results.
[0140] Corresponding to the embodiment of the foregoing function service processing method, this specification also provides an embodiment of a function service processing device.
[0141] The embodiment of the function service processing device in this specification can be applied to an electronic device. The device embodiment can be implemented by software, or by hardware or a combination of software and hardware. Taking software implementation as an example, as a logically meaningful device, it is formed by the processor of the electronic device where it is located reading the corresponding computer program instructions in the non-volatile memory into the memory and running. From the hardware level, such as Figure 5As shown, it is a hardware structure diagram of an electronic device where the function service processing device of this specification is located. In addition to Figure 5 the processor, memory, network interface, and non-volatile memory shown, in embodiments, the electronic device where the device is located may usually include other hardware according to the actual functions of the function service processing, which will not be elaborated here.
[0142] Please refer to Figure 6 , Figure 6 which is a block diagram of a function service processing device shown in an exemplary embodiment of this specification.
[0143] The above function service processing device can be applied to Figure 5 the electronic device shown, on which a container system is deployed. The function service processing device may include:
[0144] A creation module 601, configured to create a first container based on the first image in response to obtaining the first image corresponding to the integrated development environment from a repository for storing images; wherein, the first container is used to run the integrated development environment;
[0145] An acquisition module 602, configured to acquire the source code corresponding to the function service to be built, and acquire the configuration file for building the second image corresponding to the function service;
[0146] A generation module 603, configured to compile the source code based on the integrated development environment to generate a service file corresponding to the function service;
[0147] A construction module 604, configured to build the second image based on the service file and the configuration file, and store the second image in the repository.
[0148] Optionally, the acquisition module 602 is specifically configured to:
[0149] Output, through a user interface corresponding to the integrated development environment, a code framework corresponding to the service type of the function service to the user;
[0150] Acquire the code filled in by the user into the code framework, and generate the source code corresponding to the function service based on the code and the code framework.
[0151] Optionally, the acquisition module 602 is specifically configured to:
[0152] Generate a configuration file corresponding to the service type of the function service.
[0153] Optionally, the generation module 603 is specifically configured to:
[0154] Compile the source code based on the integrated development environment to generate an object file corresponding to the function service;
[0155] Obtain a dependency file corresponding to the function service, and determine the object file and the dependency file as service files corresponding to the function service.
[0156] Optionally, the building module 604 is specifically configured to:
[0157] If the compilation is successful, build the second image based on the service file and the configuration file, and store the second image in the repository;
[0158] The device further includes:
[0159] A prompting module 605, configured to output a compilation failure prompt message to a user through a user interface corresponding to the integrated development environment when the compilation fails.
[0160] Optionally, the device further includes:
[0161] A deployment module 606, configured to, in response to obtaining the second image from the repository, create a second container based on the second image to deploy the function service and generate a corresponding deployment log; wherein, the function service runs in the second container;
[0162] A testing module 607, configured to input preset service parameters into the function service for calculation to test the function service and generate a corresponding test log;
[0163] A display module 608, configured to visually display the deployment log and the test log to the user.
[0164] Optionally, the image is a Docker image; the container is a Docker container; the configuration file is a Dockerfile.
[0165] Optionally, the integrated development environment includes a web-based integrated development environment.
[0166] For the specific implementation process of the functions and roles of each module in the above device, please refer to the implementation process of the corresponding steps in the above method for details, which will not be elaborated here.
[0167] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to the descriptions of the method embodiments. The device embodiments described above are only illustrative. The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed to multiple network modules. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution in this specification. Those of ordinary skill in the art can understand and implement it without creative efforts.
[0168] The systems, devices, modules or units described in the above embodiments can be specifically implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, and the specific form of the computer can be a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email transceiver device, a game console, a tablet computer, a wearable device, or a combination of any several of these devices.
[0169] In a typical configuration, a computer includes one or more processors (CPUs), an input / output interface, a network interface, and a memory.
[0170] The memory may include non-permanent memory in the computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of, for example, read-only memory (ROM) or flash memory (flash RAM). The memory is an example of a computer-readable medium.
[0171] The computer-readable medium includes permanent and non-permanent, removable and non-removable media, and information storage can be achieved by any method or technology. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of the storage media of a computer include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette tapes, disk storage, quantum memory, graphene-based storage media or other magnetic storage devices, or any other non-transmission media that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transitory media such as modulated data signals and carrier waves.
[0172] It should also be noted that the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, such that a process, method, commodity or device comprising a series of elements not only includes those elements but also includes other elements not expressly listed, or further includes elements inherent to such process, method, commodity or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, commodity or device comprising said element.
[0173] The specific embodiments of this specification have been described above. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve the desired result. Additionally, the processes depicted in the figures do not necessarily require the particular order or sequential order shown to achieve the desired result. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0174] The terms used in one or more embodiments of this specification are for the purpose of describing specific embodiments only and are not intended to limit one or more embodiments of this specification. The singular forms "a", "the" and "said" used in one or more embodiments of this specification and the appended claims are also intended to include the plural forms unless the context clearly dictates otherwise. It should also be understood that the term "and / or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.
[0175] It should be understood that although the terms first, second, third, etc. may be used in one or more embodiments of this specification to describe various information, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from each other. For example, without departing from the scope of one or more embodiments of this specification, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "when" or "upon" or "in response to determining".
[0176] The above description is only the preferred embodiment of one or more embodiments of this specification and is not intended to limit one or more embodiments of this specification. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of one or more embodiments of this specification shall be included within the scope of protection of one or more embodiments of this specification.
Claims
1. A method for processing function services, the method comprises: In response to obtaining a first image corresponding to an integrated development environment from a repository for storing images, creating a first container based on the first image; wherein, the first container is used to run the integrated development environment; Obtaining source code corresponding to a function service to be built, and obtaining a configuration file for building a second image corresponding to the function service; Compiling the source code based on the integrated development environment to generate a service file corresponding to the function service; Building the second image based on the service file and the configuration file, and storing the second image in the repository.
2. The method according to claim 1, wherein the obtaining the source code corresponding to the function service to be built comprises: Outputting, through a user interface corresponding to the integrated development environment, a code framework corresponding to the service type of the function service to the user; Obtaining the code filled in by the user into the code framework, and generating source code corresponding to the function service based on the code and the code framework.
3. The method according to claim 1, wherein the obtaining the configuration file for building a second image corresponding to the function service comprises: Generating a configuration file corresponding to the service type of the function service.
4. The method according to claim 1, wherein the compiling the source code based on the integrated development environment to generate a service file corresponding to the function service comprises: Compiling the source code based on the integrated development environment to generate an object file corresponding to the function service; Obtaining a dependency file corresponding to the function service, and determining the object file and the dependency file as a service file corresponding to the function service.
5. The method according to claim 1, wherein the building the second image based on the service file and the configuration file, and storing the second image in the repository comprises: If the compilation is successful, building the second image based on the service file and the configuration file, and storing the second image in the repository; The method further comprises: If the compilation fails, outputting a prompt message indicating compilation failure to the user through a user interface corresponding to the integrated development environment.
6. The method according to claim 1, the method further comprises: In response to obtaining the second image from the repository, creating a second container based on the second image to deploy the function service and generate a corresponding deployment log; wherein, the second container is used to run the function service; Inputting preset service parameters into the function service for calculation to test the function service and generate a corresponding test log; Visualizing and displaying the deployment log and the test log to the user.
7. According to the method of claim 1, the image is a Docker image; the container is a Docker container; the configuration file is a Dockerfile file.
8. According to the method of claim 1, the integrated development environment includes a web-based integrated development environment.
9. A function service processing device, the device comprises: a creation module, configured to create a first container based on a first image in response to obtaining, from a repository for storing images, the first image corresponding to an integrated development environment; wherein, the first container is used to run the integrated development environment; an acquisition module, configured to acquire source code corresponding to a function service to be built, and acquire a configuration file for building a second image corresponding to the function service; a generation module, configured to compile the source code based on the integrated development environment to generate a service file corresponding to the function service; a construction module, configured to build the second image based on the service file and the configuration file, and store the second image in the repository.
10. The device according to claim 9, the device further comprises: a deployment module, configured to create a second container based on the second image in response to obtaining the second image from the repository, so as to deploy the function service and generate a corresponding deployment log; wherein, the function service runs in the second container; a testing module, configured to input preset service parameters into the function service for calculation to test the function service and generate a corresponding test log; a display module, configured to visually display the deployment log and the test log to a user.
11. An electronic device, comprises: a processor; a memory for storing processor-executable instructions; wherein, the processor realizes the method according to any one of claims 1 to 8 by running the executable instructions.
12. A computer-readable storage medium, on which computer instructions are stored, and when the instructions are executed by a processor, the method according to any one of claims 1 to 8 is realized.
Citation Information
Patent Citations
Local deployment method of Serverless function stream
CN117519842A