Updated on 2023-11-22 GMT+08:00

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.

Event

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-ins

You can overwrite or extend the functionality of the Framework using Plug-ins. Every serverless.yml can contain a plugins: attribute, which features multiple plug-ins.
# serverless.yml

plugins:
  - serverless-huawei-functions