Git Call
  • 21 Aug 2023
  • 6 Minutes to read
  • Contributors
  • Dark
    Light
  • PDF

Git Call

  • Dark
    Light
  • PDF

Article Summary

With the Git Call node, you can easily fetch and run code from any Git repository, be it GitHub or any other platform (see Picture 1).

Git Call.png

Picture 1. Git Call node task flow

All you need to do is specify the repository you want, write a program that uses it (or include it in the repo), and give the right build instructions.

Git experience recommended

Having some prior experience with Git and the command line is strongly advised before starting to work with the Git Call node.

Even if you're not a Git pro, the Git Call node is designed to be user-friendly and easy to work with. So, you can quickly and effectively access and execute code from any Git repository without much hassle.

The intricacies of the node's internal processes may appear intimidating to those unfamiliar with Docker containerization, but you don't need to understand them to work with the Git Call node. All you need to know is that it works as a miniature computer that effectively executes your code.

How the node works:

Upon clicking the Build button, the Git Call node promptly retrieves the code you specified from the Git repository. Corezoid then takes over to generate a Docker image that encapsulates your codebase, along with all the essential libraries, dependencies, and runtime configurations necessary for running your code seamlessly.

Cold Start

To execute your code, Corezoid must first launch a Docker container from the Docker image it created. This operation can take a few moments, typically ranging from 10 to 15 seconds, depending on the complexity of your codebase and the associated runtime configurations.

Once the Docker container is up and running, it will remain active for as long as the Git Call node keeps receiving tasks. However, if there is no task activity for a while, the container may shut down to conserve resources. If this happens, the node will relaunch the container the next time it receives tasks, which may result in a slight delay in task processing.

If tasks are received during the container relaunch process, they will be stored and processed once the container is up and running again, ensuring that there are no disruptions to the processing flow.

Limitations
  • The available space for code and other resources within this node is limited to 200 MB.

  • Output generated by the node cannot exceed 2 MB in size.

  • A task will not be processed for longer than 30 seconds and will time out if this time is exceeded.

Node Settings

Basic settings

Language: allows you to specify one of the supported languages.

Available languages and their package managers:

LanguagePackage ManagerOS
JavaScript(node) v18.16yarn, npmalpine v3.17
GoLang v1.20go modalpine v3.17
Python v3.11.2pipalpine v3.17
PHP v8.1.16composer v2.5.4alpine v3.17
Java v19gradlealpine v3.15
clojure v1.11.1lein v2.10.0alpine v3.17
lisp v2.0.5roswell v20.05.14.106Ubuntu v18.04.4
prologswipl v9.1.8debian:bullseye-slim

Code Editor - allows you to write and include additional code, which will be executed when a task enters the node.

When you write code in the Code Editor of the Git Call node, it will be added to the retrieved folder as a file named "usercode" with a corresponding extension. This allows you to easily incorporate your custom code with the existing codebase from the Git repository and execute it seamlessly as a part of the overall workflow, i.e. :

  • js: usercode.js
  • go: usercode.go
  • python: usercode.py
  • php: usercode.php

Alternatively, you can include the "usercode" file in your Git repository, which allows you to manage and version control your custom code alongside the main codebase.

To correctly integrate and execute your custom code within the Git Call node, it must be written within a wrapper. You can find detailed examples of the appropriate wrapper syntax for each available programming language on our GitHub page.

Overwriting usercode

In case a file with the name "usercode" is already included in the Git repository, but you also write code in the Code Editor, the original file will be overwritten.

Get SSH Key - If you press this button, the Git Call node will generate an SSH key that can be added to your private Git repository. This key allows for automatic authentication of the node.

Repo URL - The URL of the git repository you would like to retrieve.

If you choose to authenticate your request to access the repository with a login and password, you can do so by adding them to the URL using the following format:

https://username:password@github.com/account/repository

Replace and with your GitHub username and password, respectively. Note that including your login credentials in the URL is not recommended for security reasons. Instead, we suggest using an SSH key to authenticate your requests.

Tag Branch Commit - allows you to select a specific branch from your repository. In most cases, it should be "main".

Handler (Java) - allows you to specify the name of the class that implements UsercodeHandler;

Build command - optional. Allows you to write commands to build your code and to install any missing libraries using a package manager. It uses sh (Bourne Shell) and provides a non-interactive environment. After you press Build, a terminal window will open and you will be able to monitor the execution of your commands. However, unlike a typical terminal, you cannot interact with it, and you need to specify all of your commands together. It is important to note that there is no access to the root repository.

Making Changes

Git Call works differently than other nodes in that every time you make a change, you'll need to rebuild it by pressing the 'build' button before you can deploy it.

Other

Alert if the number of tasks in the node queue reaches the following number - If this option is selected, a new condition will be created within the node. It will allow you to monitor whether the number of tasks in the node exceeds the specified threshold.

Maximum interval, for which the task stays in the node before being forwarded - the amount of time a task is allowed to be in this node. Can be specified in seconds, minutes, hours, or days. It can also be specified as a unixtime function. This value must be at least 30 seconds.

Examples

Accessing a Python library using Git Call

In this example, we'll use Git Call to install a library and write code that uses it (see Picture 2).

image.png

Picture 2. Using the Git Call node to install a library and use it in our code

First, choose Python as the programming language.

To install the library, enter this command in the Build command field:

pip install pyjwt

Leave the "Repo URL" and "Tag Branch Commit" fields empty.

Now, add code in the editor that uses the library:

import jwt

def handle(data):
    data["encoded_jwt"] = jwt.encode(data["my_payload"], data["secret"], algorithm="HS256")
    return data

When writing your code, pay attention to these two key points: First, place your code inside the handle function, which takes the data parameter containing the task parameters. Second, since Python represents JSON objects as dictionaries, use dictionary syntax when accessing and manipulating the task parameters within the data variable.

Error handling & troubleshooting

When an error occurs in the node, a task goes to the auxiliary Condition output node (Picture 3):

image.png

Picture 3. Git Call node's auxiliary output node

This auxiliary Condition node is used for storing error parameters. With that, the following fields are added to the initial task depending on the error and node type:

Error parameter nameParameter description
__conveyor_node_type_return_type_error__Error type: hardware (system error), software (error in a node logic/settings)
__conveyor_node_type_return_type_tag__Error tag
__conveyor_node_type_return_type_description__Error description in human-readable language. Can be static or dynamic
ProblemCauseSolution
The build failsTo use the repository, root access is required.Corezoid does not allow access to the root directory. If your code requires root access, you will need to modify it to work within the allowed directory structure. Alternatively, you can contact us to discuss custom solutions.
The repository requires C/C++By default, Git Call does not support C/C++. If you require access to this feature, please contact our support team.
No internet accessGit Call requires internet access to retrieve code from a repository. It will not be able to function in a closed offline environment.

What's Next