Introduction
The Serverless Framework helps you develop and deploy serverless applications using FunctionGraph. It is a CLI that offers structure, automation, and best practices out-of-the-box, allowing you to focus on building sophisticated, event-driven, serverless architectures, comprised of Function and Events.
The Serverless Framework is different from other application frameworks because:
- It manages your code as well as your infrastructure.
- It supports multiple languages (Node.js, Python, Java, and more).
Core Concepts
Here are the main concepts of the Framework and how they pertain to FunctionGraph.
Function
Function refers to a Huawei Cloud FunctionGraph function. It is an independent unit of deployment, like a microservice. It is merely code deployed in the cloud and mostly written to perform a single job such as:
- Saving a user to the database
- Processing files in the database
You can perform multiple tasks in your code, but we do not recommend doing so without good reason. Separation of concerns is best and the Framework is designed to help you easily develop and deploy functions, as well as manage them.
Events
Anything that triggers a Huawei Cloud FunctionGraph function to execute is regarded by the Framework as an Event. Events are platform events on Huawei Cloud FunctionGraph including API Gateway (APIG) service and API (for example, REST API), OBS bucket (for example, image uploaded into a bucket).
When you define an event for your FunctionGraph in the Serverless Framework, the Framework will automatically translate the event with its function into the corresponding cloud resources. This way the event is configured so that your functions can listen to it.
Service
Service is the Framework's unit of organization. You can consider it as a project file, though you can have multiple services for a single application. It is where you define your functions, the events that trigger them, and the resources your functions use, all in one file entitled serverless.yml (or serverless.json).
# serverless.yml
service: fgs
functions: # Your "Functions"
hello_world:
events: # The "Events" that trigger this function
- apigw:
env_id: DEFAULT_ENVIRONMENT_RELEASE_ID
env_name: RELEASE
req_method: GET
path: /test
name: API_test
When you deploy with the Framework by running serverless deploy, everything in serverless.yml is deployed at once.
Plug-in
# serverless.yml plugins: - serverless-huawei-functions
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