Functions and Invokers

This topic explains the relationship between functions and the infrastructure code that calls them.

Functions

A function is a unit of code that performs a specific task.

Even though functions are isolated from the infrastructure code, they can rely on external dependencies such as Spring.

Functions are typically built from source and can leverage dependency management solutions for their language of choice, for example, Maven or NPM. For more information, see PFS Buildpacks.

JavaScript function example:

module.exports = (x) => x**2;

Java function example:

package com.acme;

import java.util.function.Function;

public class Upper implements Function<String, String> {

  public String apply(String in) {
    return in.toUpperCase();
  }
}

Invokers

An invoker works as an interface between the runtime platform and your function. Invokers are written idiomatically for each supported language.

Invokers are responsible for the following:

  • Loading and calling functions
  • Transforming input and output types

When PFS creates a function container, PFS buildpacks combine functions with invokers. For more information, see PFS Buildpacks.

Function and Invoker form Layers in a Function Container