Anatomy of Trillo Function

Anatomy of Trillo Function is repeated here for convenience. It is covered at other places such as Trillo Workbench Developer Guide.

Each Trillo Function has the following structures. Each method corresponds to one endpoint. You can add new methods or remove methods that are not needed. A function can be given any meaningful name. Similarly a method can be given any name. For example a function called AccountService may have a method called “makePayment”. By convention, its endpoint will be, /ds/function/shared/AccountService/makePayment.

import java.util.Map;
import com.collager.trillo.util.Api;
import com.collager.trillo.util.ServerlessFunction;

public class MyFunction extends ServerlessFunction {

  @Api(httpMethod="post")
  public Object saveValue(Map<String, Object> parameters) {
    return parameters;
  }
  
  @Api(httpMethod="put")
  public Object updateValue(Map<String, Object> parameters) {
    return parameters;
  }
  
  @Api(httpMethod="get")
  public Object getValue(Map<String, Object> parameters) {
    return parameters;
  }
  
  @Api(httpMethod="delete")
  public Object removeOverheads(Map<String, Object> parameters) {
    return parameters;
  }

}

In the following exercises, we will repeat similar code for lessons without a discussion of the above structure. It will be obvious.

The following constructs are useful and described in the append below.

Construct

Explanation

ServerlessFunction

Base class of all Trillo Functions.

Map, List & Tree

Data structures that represent an object or a collection of objects (records), a tree like structure.

Log and Audit Logs

Utilities to log messages in DB or cloud log service.

DataRequest

A special class to request a paginated list or tree.

DataResult

Result of paginated request.

DataIterator

A class to iterate to a large list.

Result

Result of API call. It is returned instead of the expected response to provide details of the error.

Last updated