Functions

Available since v1.1.0

A Task represents a planned or scheduled piece of code. The code definition is a Function in Extra Horizon.

Deploying a Function

Developers can leverage the power of the Extra Horizon CLI to efficiently create new Functions and seamlessly update existing ones, this can be achieved by using the exh tasks sync command.

exh tasks sync --name=my-function \
  --code=/my/path/to/my-function \
  --entryPoint=index.handler \
  --runtime="nodejs14.x"

Tutorial

A step-by-step guide on how to deploy a Function is available in the hello world example.

The JavaScript SDK may be used within a Function to easily interface with Extra Horizon services.

List functions

exh tasks list <options>

Delete a function

In order to Delete a Task Function, you will need as a User to have the DELETE_TASK_FUNCTION permission.

exh tasks delete <options>

If a function is removed from the task service its executions (tasks) and the logs aren't removed and can still be retrieved

Function Properties

{
  "name": "my-function",
  "description": "This is an example of a test Lambda function",
  "entryPoint": "index.handler",
  "runtime": "nodejs14.x",
  "timeLimit": 60,
  "memoryLimit": 256,
  "environmentVariables": {
    "CLIENT_ID": {
      "value": "my-token-value" 
    },
    "CLIENT_SECRET": {
      "value": "my-secret-value" 
    }
  },
  "retryPolicy": {
    "enabled": true,
    "errorsToRetry": [
      "CONNECTION_ERROR",
      "DATABASE_ERROR"
    ]
  },
  "executionOptions": {
    "permissionMode": "permissionRequired"
  },
}

name

The name property serves as the unique identifier amongst all Functions.

description

The description property may be supplied to provide a brief explanation regarding a Function's purpose.

entryPoint

The entryPoint property refers to the method in the Function code that is executed.

runtime

The runtime property selects the runtime (or environment) the Function will be running in. The Task Service utilizes AWS Lambda to run Functions. Any runtime supported by AWS Lambda is supported by the Task Service.

See the AWS Lambda documentation for a list of supported runtimes: https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html

timeLimit

The timeLimit represents the maximum allowed execution time limit for this Function in seconds. This value may have a minimum value of 3 seconds and a maximum value of 300 seconds.

memoryLimit

The memoryLimit allocates the desired memory for a Function's execution in MB. This value may have a minimum value of 128 MB and a maximum value of 10240 MB.

environmentVariables

The environmentVariables represent the environment variables in the Function execution runtime.

The following code snippet shows an example how to configure the environment variables:

{
  ...
  "environmentVariables": {
    "CLIENT_ID": {
      "value": "my-token-value" 
    },
    "CLIENT_SECRET": {
      "value": "my-secret-value" 
    }
  }
}

retryPolicy

Available since v1.3.0

The retryPolicy field can be used to determine system behavior after the execution of a Function (Task) fails.

The following code snippet shows an example how to configure the retry policy:

{
  ...
  "retryPolicy": {
    "enabled": true,
    "errorsToRetry": [
      "CONNECTION_ERROR",
      "DATABASE_ERROR"
    ]
  }
}

retryPolicy Properties

enabled

The retry policy is disabled by default, If this field is set to true, the retry policy becomes active. If active the policy will retry a maximum of 3 times, with an increasing timeout of 2, 5 and 10 seconds respectively.

errorsToRetry

It is possible to restrict the retry policy to a specific set of errors using this property.

executionOptions

The executionOptions field may be used to configure how the function can be executed.

The following code snippet shows an example how to configure the execution options:

{
  ...
  "executionOptions": {
    "permissionMode": "permissionRequired"
  },
}

executionOptions Properties

permissionMode

This property determines execution restrictions based on its assigned value. One of the following values may be assigned to the permissionMode property to enforce execution restrictions.

The permissionMode is only considered for direct execution of a Function or API Functions.

For information regarding the application of permissions to users please refer to global roles.

Last updated