Overview
Introduction
A dependency contains public libraries that support the running of function code. You can encapsulate the required public libraries into a dependency for easier management, sharing, and smaller deployment sizes.
You can keep multiple versions of the same dependency for systematic management.
Function dependencies are classified into public dependencies and private dependencies. For details, see Configuring a Dependency for a Function.
Public dependencies are built in FunctionGraph and can be added to your function code to implement service logic.
Public dependencies have the following advantages over private dependencies:
- Out-of-the-box: You can directly add dependencies on the function details page and focus on code and service logic.
- Reduced latency: Public dependencies are cached on the platform, and they do not need to be obtained from storage services during cold starts.
- Simplified operations: The maximum size of a private dependency is 300 MB. For dependencies greater than 300 MB, you need to split and upload them for multiple times. Public dependencies are not subject to the 300 MB limit.
A private dependency is created by encapsulating common libraries required by service code on your local PC. For details about how to create private dependencies of each runtime, see Creating a Private Dependency for a Function.
Supported Dependency Libraries
FunctionGraph allows you to import standard libraries and some non-standard libraries to your code.
- Standard libraries
When using standard libraries, you can import them to your inline code or package and upload them to FunctionGraph.
- Built-in non-standard libraries
FunctionGraph has some non-standard libraries built in, as shown in Table 1 and Table 2. The method of using the non-standard libraries is the same as that of using standard libraries.
Table 1 Third-party components integrated with the Node.js runtime Name
Usage
Version
q
Asynchronous method encapsulation
1.5.1
co
Asynchronous process control
4.6.0
lodash
Common tool and method library
4.17.10
esdk-obs-nodejs
OBS SDK
2.1.5
express
Simplified web-based application development framework
4.16.4
fgs-express
Provides a Node.js application framework for FunctionGraph and APIG to run serverless applications and REST APIs. This component provides an example of using the Express framework to build serverless web applications or services and RESTful APIs.
1.0.1
request
Simplifies HTTP invocation and supports HTTPS and redirection.
2.88.0
The following is an example of introducing a dependency library in function code using the Node.js runtime:const ObsClient = require('esdk-obs-nodejs');
Table 2 Non-standard libraries supported by the Python runtime Library
Usage
Version
dateutil
Advanced library for handling dates and times, supporting date parsing, formatting, and time zone operations.
2.6.0
requests
HTTP library, which is used to send HTTP requests and process responses.
2.7.0
httplib2
HTTP client library, which supports HTTP/HTTPS requests, authentication, and proxies.
0.10.3
numpy
Library for scientific computing, which supports efficient array operations and mathematical functions.
Python 2.7, numpy==1.16.6
Python 3.6, numpy==1.18.5
Python 3.9, numpy==1.18.5
Python 3.10, numpy==1.24.2
redis
Library for connecting to and operating Redis databases, which supports multiple data structures.
2.10.5
ObsClient
Python client of OBS, which is used to manage object storage resources.
3.0.3
smnsdk
Python SDK of SMN, which is used to access the SMN service.
1.0.1
- Other third-party dependency libraries
Compress the dependent third-party libraries into a ZIP file, upload the ZIP file to an OBS bucket or upload it on the function console. On the Code tab page, add the dependencies so that they can be used in function code. For details, see Configuring a Dependency for a Function.
Helpful Links
Manage function dependencies through APIs. For details, see Dependency APIs.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot