Introduction

Functions

 

Introduction

Catalyst Functions 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 two programming environments:

  1. Java
  2. Node.js

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

Catalyst Functions is one of the two 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 functions for different purposes in Catalyst, in both Java and Node.js platforms:

  • 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

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
  • LogsProvides 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 this section for links to relevant CLI help pages.

Note: Catalyst Java 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.
  6. 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.
  7. 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.

Share this post : FacebookTwitter

Still can't find what you're looking for?

Write to us: support@zohocatalyst.com