Functions

Introduction

Functions is a Catalyst Serverless component that are custom-built coding structures which contain the intense business logic of your application. Functions allow you to store the functionality of the application in a centralized and secure place, rather than storing it within the application’s main code. The application uses APIs to invoke functions from the Catalyst servers when needed.

Catalyst offers support to develop server-side functions in three programming environments:

  1. Java
  2. Node.js
  3. Python

You can refer to Java SDK documentation, Node.js SDK documentation and Python SDK documentation to learn about these SDK packages.

Catalyst Functions is one of the basic project components of a Catalyst application, along with the client. You can seamlessly access Catalyst components with functions and provide the powerful backend that the application or microservice requires. You can use them to automate tasks, perform memory-intensive computations, integrate with third-party services, and more.

You can create five types of server-side functions in Catalyst for different purposes. All five types of functions can be created in Java, Node.js and Python programming environments.

  • Basic I/O Functions: Simple functions used for basic input and output operations, passing a String as the I/O parameter
  • Advanced I/O Functions: Advanced HTTP functions that support Headers, and Native Request and Response objects
  • Event Functions: Event-driven functions that are invoked by specific events configured using Event Listeners
  • Cron Functions: Cron based functions that are invoked one time or periodically, based on the cron job’s configured schedule
  • Integration Functions: Functions that enable you to integrate with other Zoho services and write backends for them easily
Note:
  • The main function file in Java, Node.js and Python are initialized with different default code for each function type, such as including different modules, when the function is created. Therefore, you must avoid copying code from a different function type. You must ensure that you initialize the appropriate modules for each function type.

  • Integration functions is currently not available to Catalyst users accessing from the EU, AU, IN, or CA data centers.

Catalyst provides various components and tools to manage functions and view their performance statistics:

  • Security Rules: Default security configuration of your Basic I/O and Advanced I/O functions that enables you to define their invocation and access rules

  • API Gateway: Enables you to create APIs for your Basic I/O and Advanced I/O functions, and handle the routing, throttling, authentication of client requests

  • Logs: Provides logs of all function executions along with details of log levels, responses, statuses, and other information

  • Application Performance Monitoring: Provides in-depth stats and performance reports of all function executions that enable you to identify and resolve bugs

  • Circuits: Workflow automation tool that enables you to design and orchestrate Basic I/O function executions, and handle data flow between multiple functions

You can either work with functions using the Catalyst CLI and an external IDE, or work with them directly from the Catalyst web console. This document explains the concepts related to functions and working with them from the Catalyst web console. To learn about working with them in a local environment, refer to the next section for links to relevant CLI help pages.

Note: Catalyst Java and Python functions can only be created and coded using the Catalyst CLI and an external editor, and deployed or uploaded to the web console. You cannot code them directly in the web console as of now.

Steps to work with Functions from a Local Environment

You can create, build, and deploy a function from the local environment as described below. Refer to the links given in each step for detailed help on the CLI actions.

  1. Initialize the function from the CLI: When you initialize a function from the CLI, the function directory and the boilerplate code structure for each file are created based on its stack, type, and whether you chose to install the Catalyst SDK.

  2. Set up the function in your project directory any time: You can choose to set up the function any time after you initialize the project from the CLI.

  3. Code the function using an external editor:If you initialize the function from the CLI, you can code it using an external editor. You can also upload a function’s bundle to the Catalyst console any time and code it using Catalyst’s editor.

  4. Test the function in the CLI: You can test and debug functions of all types, except Advanced I/O functions, by launching a Node shell for it from the CLI.

  5. Serve the function from a local host: Besides launching a Node shell, you can also serve a Basic I/O or an Advanced I/O function from a local host, and test its execution.

Note: You will not be able to serve functions of the other types, as they are invoked internally.
  1. Deploy the function to the Catalyst console: You can then deploy the function from your local machine to the Catalyst remote console from the CLI.

  2. Delete the function from the CLI: You can also delete the function remotely from the CLI. This will delete it from the console as well.

Note:
  • You can also work on a Catalyst function independently without initializing it in the Catalyst CLI, and upload it to the Catalyst remote console directly. In this case, you must ensure that you create the required configuration files in the function’s directory manually, and include the necessary code in them in the standard structure. You can refer to the Project Directory Structure help page for details.

  • You can also deploy functions to the Catalyst remote console from your GitHub repository directly. To learn more, refer to the GitHub Integration help page.

Check out Catalyst tutorials to practice working with Functions.

Last Updated 2024-03-22 17:59:45 +0530 +0530