baetyl-function Module
Introduction
baetyl-function is a function computing framework on the baetyl framework end side. The function computing framework on the end side consists of the frontend agent and backend function runtime.
The baetyl-function provides the front end agent, which is a function entry. It is called by other services through the exposed HTTP interface and then transmits the request to the back-end function runtime module transparently.
The back end function runtime provides multiple options:
- baetyl-function-python36 provides the Python3.6 function runtime.
- baetyl-function-node10 provides the Node 10 function runtime.
- baetyl-function-sql provides the SQL function runtime, and it is compatible with the SQL92 syntax.
Users can write python, node, and SQL scripts to build their business logic and filter, transform and forward the message, which is very flexible for its use.
The function computing is set based on the event-driven programming model. Users can set the rules using the rule engine baetyl-rule module on the baetyl end side. When a message triggers a certain rule, you can call related functions within this rule. baetyl-rule will request the baetyl-function module in the following format:
https://[baetyl-function-service]/[function-service]/[function]
The baetyl-function-service
is the service address of baetyl-function. For example, baetyl-function: 50011,function-service
is the service name when the back end function runs, and function
represents the function entry. If the `function field is not specified, it will select the first function in its function list by default when the back-end function runs. The function entry represents the executive function. For Python3.6/Node 10 runtime, it consists of function script and handler name. For the SQL runtime, it consists of a function script only. It is the SQL statement written by users in the function script.
For the specific use, refer to the best practice baetyl Edge Rule Engine Practice.
Configuration
The following gives the complete configuration files of baetyl-function and explains the configuration field correspondingly:
server: # Server related settings because the request is proxied to the backend Runtimes module
address: ":50011" # Listening address
concurrency: # The number of concurrent connections on the server, if not set, the default value will be used
disableKeepalive: true # true # Whether to enable keep-alive connections, the default value is false
tcpKeepalive: false # Whether to actively send keep-alive messages, the default is false
maxRequestBodySize: # The maximum data volume of Body, the default is 4 * 1024 * 1024 Byte
readTimeout: 1h # The read timeout time of the server connection, the default value is unlimited
writeTimeout: 1h # The write timeout time of the server connection, the default value is unlimited
idleTimeout: 1h # In "keep alive" start condition, the idle timeout during which the server waits for the next message. If the value is 0, the multiplex read timeout time
ca: example/var/lib/baetyl/testcert/ca.crt # Server's CA certificate path
key: example/var/lib/baetyl/testcert/server.key # Server's server private key path
cert: example/var/lib/baetyl/testcert/server.crt # Server's server public key path
client: # Request client related settings of the backend Runtimes module
grpc: # Grpc client settings
port: 80 # Backend Runtimes port
timeout: 5m # Request timeout
retries: 3 # Request retries
logger: # Log
level: info # Log level