Categorygithub.com/trendyol/cbef
repository
1.0.2
Repository: https://github.com/trendyol/cbef.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

cbef (Couchbase Eventing Functions)

Release GoDoc Tag Push GitHub License

cbef is a simple, gitops capability provider for Couchbase eventing functions.

cbef

Table of Contents

Why?

In production projects where code reliability is a key consideration, it is essential to control and review the implemented processes using Git.

cbef facilitates GitOps support for the operations performed within eventing functions.

Moreover, to ensure the seamless functionality of eventing functions before deploying to the live environment, testing support is provided. This testing ensures that the functions operate as expected, offering confidence in their reliability.

In contrast to operations carried out through the UI, transitioning to a new function version is designed to be zero-downtime, allowing for rapid rollback if needed. The inclusion of revision history support further enhances the ability to track and manage changes effectively.

Quickstart

Local

Note: Precompiled cbef for all arch types is available in the releases page.

Clone the cbef repository from the given GitHub URL

git clone https://github.com/trendyol/cbef

Change the current working directory to the cbef directory

cd cbef

Update function settings

nano ./examples/functions/basic.json

Note: JavaScript eventing code file is found automatically.

Update function file

nano ./examples/functions/basic.js

Note: If you need to example eventing functions code, click here to read official Couchbase documentation.

Download dependencies

go mod tidy

Set the environment variable CONFIG_FILE to the path of the basic.json configuration file

export CONFIG_FILE=./examples/functions/basic.json

Set the environment variable CI_COMMIT_AUTHOR to the value foo, representing the author of the commit

export CI_COMMIT_AUTHOR=foo

Run the Go program located in the cmd directory

go run ./cmd

Docker

Pull latest image

docker pull ghcr.io/trendyol/cbef:1.0.2-amd64

Run latest image

docker run --platform=linux/amd64 ghcr.io/trendyol/cbef:1.0.2-amd64

Note: All images available in the packages page.

GitLab

Just open a new repository and copy the examples folder.

The structure in examples/.gitlab-ci.yml will help you deploy your eventing function.

Also, you can store cluster connection secrets as masked and protected in ci/cd variables.

Function Configurations

Configurations that can be used in files with .json extension located in the functions folder

FieldDescriptionValue TypeRequiredOptions
clusterCouchbase connection configurationsobject
cluster.connection_stringCouchbase cluster connection stringstringenv supported with {{ENV}}
cluster.userUsername for cluster authenticationstringenv supported with {{ENV}}
cluster.passPassword for cluster authenticationstringenv supported with {{ENV}}
nameFunction namestring
metadata_keyspaceMetadata keyspace configurationsobject
metadata_keyspace.bucketMetadata bucket namestring
metadata_keyspace.scopeMetadata scope namestring
metadata_keyspace.collectionMetadata collection namestring
source_keyspaceSource keyspace configurationsobject
source_keyspace.bucketSource bucket namestring
source_keyspace.scopeSource scope namestring
source_keyspace.collectionSource collection namestring
bucket_bindingsBucket bindings configurationsobject array
bucket_bindings.aliasAlias for bucket bindingstring
bucket_bindings.bucketTarget bucket name for bindingstring
bucket_bindings.scopeTarget scope name for bindingstring
bucket_bindings.collectionTarget collection name for bindingstring
bucket_bindings.accessAccess level for bindingstringr (read-only), rw (read-write)
url_bindingsURL bindings configurationsobject array
bucket_bindings.hostnameHostname for URL bindingstring
bucket_bindings.aliasAlias for URL bindingstring
bucket_bindings.allow_cookiesAllow cookies for URL bindingbool
bucket_bindings.validate_ssl_certificateValidate SSL certificate for URL bindingbool
bucket_bindings.authAuthentication configurations for URL bindingobject
bucket_bindings.auth.typeAuthentication type for URL bindingstringbasic, digest, bearer
bucket_bindings.auth.userUsername for URL binding authenticationstring
bucket_bindings.auth.passPassword for URL binding authenticationstring
bucket_bindings.auth.tokenToken for URL binding authenticationstring
constant_bindingsConstant bindings configurationsobject array
constant_bindings.aliasAlias for constant bindingstring
constant_bindings.literalLiteral value for constant bindingstring
settingsFunction configurationsobject
settings.dcp_stream_boundaryThe preferred deployment time feed boundary for the functionstringeverything, from_now
settings.descriptionDescription for functionstring
settings.log_levelGranularity of system events being captured in the logstringINFO, ERROR, WARNING, DEBUG, TRACE
settings.query_consistencyConsistency level of N1QL statements in the functionuint1 (NotBounded), 2 (RequestPlus)
settings.worker_countNumber of workers per node to process the eventsuint
settings.language_compatibilityLanguage compatibility of the functionstring6.0.0, 6.5.0, 6.6.2
settings.execution_timeoutTime after which the function's execution will be timed outuint (seconds)
settings.timer_context_sizeMaximum allowed value of the timer context size in bytesuint