Skip to content

Gloop Icon

Invoke

The Invoke Step is used to invoke other Gloop Services, Flux Services, and compatible Java and Groovy Services1 in Gloop. It borrows the Mapper view from the Map Step, meaning you can also set variable values, declare new variables, or unload them in Invoke Steps. This makes Gloop infinitely more powerful, because if there's anything you can't do in Gloop, you can do it in Flux, Java, or Groovy! This also means that you can reuse existing services by wrapping them in Invoke Steps in Gloop Services to make managing your services and APIs easier.

The Mapper view for Invoke Steps has two mappers inside it. One is for mapping input variables (on the left hand side) for the service/code it will invoke, and the other is for mapping output variables from the invoked service (on the right hand side).

Invoke Step *Mapper* view

Mapper in Invoke Steps

When an Invoke Step is selected in the Gloop Service Editor, the Mapper view in Coder will show all of the available Input and Output variables for the service to be invoked, as well as the variables available in the current scope of the service. This is where you map variable values from the current scope of the service to the service to be invoked and add Set Expressions to the inputs of the service to be invoked. After the service has been invoked, Gloop will then map and set all of the variables on the Output side of the Mapper view.

For example, the mapper screenshot below:

Example Invoke Step *Mapper* mapping

... is the same as the following Groovy code:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
// Invoke some code.
GloopModel output =
    TrackerMethods.searchTracker(trackerQuery,
                                 externalIds,
                                 documentTypeId,
                                 'Error',
                                 'CustomerX',
                                 'Togo',
                                 'now',
                                 null,
                                 null,
                                 null,
                                 null,
                                 null,
                                 100,
                                 2)
// Declare the searchResult variable and map (set) it.
GloopModel searchResult = output.searchResult
// Declare the numberOfResults variable and map (set) it.
int numberOfResults = output.searchResult.numFound

Annotating code to make it Gloop-friendly

Gloop has a nifty set of annotations that are used to decorate Groovy and Java code with metadata to make your code look even better in the Gloop UI (and easier to use whilst writing Gloop Services).

Adding Invoke Steps

There are two ways to add an Invoke Step to your Gloop Service:

  • Drag and drop the service you want to invoke from the Coder Navigator view.
  • Use Coder's Auto-Complete feature (activated by pressing . in the Gloop Service Editor), then start typing in the name of the service you want to invoke. Once you find your selection in the list, click on it or use the cursor keys to highlight it and then press .

Below is a GIF showing both ways:

Adding an Invoke Step to a Gloop Service

Declare and map output variables at the same time

If you would like to map the output of an Invoke Step to a new variable, simply drag the variable to the output tree, whilst holding Alt. This will declare the variable and map it for you in one step!

Declaring and mapping in one step


  1. For a Java or Groovy service to be compatible, the method needs to be public static