Add Eventing Functions
- Capella Operational
Use the Capella UI to add Eventing Functions to the Eventing Service in your cluster.
Prerequisites
Before you add Eventing Functions to your Eventing Service, you must first deploy the Eventing Service. See Add a Service for more information.
Add a New Eventing Function
To add a new Eventing Function:
-
On the Operational Clusters page, select the cluster where you want to add a Function.
-
Go to
. -
Click Add Function.
-
Configure the Function settings.
-
Click Next.
-
To add a new binding, click Add Binding.
-
Configure the binding settings.
-
Click Next to save your binding.
-
In the code editor, customize the provided
OnUpdate
andOnDelete
JavaScript functions or enter your own JavaScript functions. You can also leave the provided code unchanged. -
Click Create Function to create your new Eventing Function in an undeployed state.
Function Settings
Field | Description |
---|---|
Name |
A unique name for your Eventing Function. The Function name must:
|
Description |
An optional description that describes the purpose of your Eventing Function. |
Listen to Location |
A bucket, scope, and collection currently defined on your cluster and where you want your Eventing Function to monitor document mutations. |
Eventing Storage |
A bucket, scope, and collection currently defined on your cluster and where you want to store system data for your Eventing Function. This is the Function’s metadata bucket. You must choose a bucket that’s not being used by any other application. You can choose to share this bucket across different Eventing Functions. You can also choose the same bucket and scope as your Listen to Location bucket and scope, but you must choose a different collection. |
Workers |
The number of worker threads per node to be allocated to the Eventing Function to process events. The minimum number of workers is The default is |
Script Timeout |
The number of seconds to elapse before the script times out and is terminated. The default is |
Time Context Max Size |
The size limit of the context for any Timer created by the Eventing Function. The default is |
SQL++ Consistency |
The default consistency level of SQL++ statements in the handler. |
Deployment Feed Boundary |
The Feed Boundary determines if the Eventing Function’s activities need to include documents that already exist.
When you set the Feed Boundary to |
Language Compatibility |
The language version of the handler for backward compatibility. |
For more information about terminology, see Eventing terminology.
Binding Settings
Your Eventing Function can have no binding, one binding, or multiple bindings. A binding is a construct that lets you separate environment-specific variables, such as bucket names, external endpoints, and credentials, from the handler source code. It helps move a handler definition from development to production environments without changing the code.
Binding names must be valid JavaScript identifiers and cannot conflict with any built-in types.
Bindings | Description |
---|---|
Bucket |
Bucket bindings allow JavaScript handlers to access Couchbase buckets from the Data Service. These buckets are accessible by the bound name as a JavaScript map in the global space of the handler. To add a Bucket binding, select Bucket, enter an alias name, and choose an access level, a bucket, a scope, and a collection. |
URL |
URL bindings are used by the cURL language construct to access external resources. They specify the endpoint, the protocol (HTTP/HTTPS), and the credentials if necessary. You can enable cookie support through URL binding when accessing trusted remote nodes. The target of a URL binding should not be a node that belongs to the Couchbase cluster. To add a URL binding, select URL, enter an alias name and a URL, choose an authentication type, and select Allow cookies and Validate SSL Certificate. |
Constant |
Constant bindings define global variables that you can use inside your Eventing Function. You can use the alias name inside your Function to use the set value of your Constant binding. To add a Constant binding, select Constant and enter an alias name and a value. Values can be integers, decimal numbers, strings, booleans, or JSON objects. |