Skip to content

Home

Introduction

Development

Overview

IDEs

Services

Service manager

API Explorer

Debugging a Flux service

When debugging a Flux service, you gain the ability to inspect and change the flow of the service's execution. Coder supports the adding of breakpoints, stepping through states and transitions, examining the context, performing evaluations, and more. In this section, we will go over these features and learn how they can be used to debug a Flux service.

Starting a debug session

To start a debug session, you need to run your Flux service in debug mode. When a service is running in debug mode, you will be able to perform debug operations on that service. There are two ways to start a service in debug mode:

  • Using the context menu from either the Flux editor or the Coder Navigator view; or

    Starting a debug session

    Starting a debug session

  • The debug button on the service toolbar

    Starting a debug session

    Starting a debug session

If your Flux has input properties declared, Coder will prompt you to supply these properties before starting.

Attaching the debugger

If you have a Flux service that is currently running and you want to perform debug operations on it, you can use the Flux debugger. The Flux debugger has the ability to attach itself to a running Flux service (whether already in a debug session or not) and when it is attached, a new debug session is created and started. To do this:

Attaching the Flux debugger

Attaching the Flux debugger

  1. Access the Integrate service manager.
  2. Right click the Flux service you want to attach to.
  3. Click Attach Debugger.

After the debugger successfully attaches itself, you should see a < Flux Debugger Attached > message in the Console view. You may now perform debug operations on that service.

You will also notice Coder prompting you to switch to the Debug perspective. This perspective contains all elements relevant for debugging services. Click the Yes button to switch immediately; No or Cancel to postpone.

Toggling breakpoints

Breakpoints are used as markers to suspend the execution of a service. In Flux, you can add them to the states either before or during debugging. To do this:

  1. Select one or more states.
  2. Right click then click Toggle Breakpoint.

Adding breakpoints in Flux

Adding breakpoints in Flux

Use the shortcut to quickly toggle breakpoints

You can use the shortcut to toggle a breakpoint when you have a state selected.

Breakpoints view

If you're in the Debug perspective, you'll be able to see all of your breakpoints under the Breakpoints view.

Commands for debugging

The Flux debugger provides different execution operations that you can apply to a service that's being debugged:

  • Resume

    Resumes the debug execution until a breakpoint is hit or the service completes.

  • Pause

    Suspends the debug execution. If a state or transition is currently being executed, execution will be suspended on the next transition or state instead, respectively.

  • Terminate

    Stops the running service.

  • Step Into

    When used on a state, the current state will be invoked and then the execution stops before the transition. When used on a transition, the transition will be invoked and then the execution stops before the next state.

  • Step Over

    When used on a state, the current state and its transition will be invoked and then the execution stops before the next state. When used on a transition, the transition will be invoked then and then the execution stops before the next transition.

Coder also features shortcuts for each of these commands.

The Debug perspective

Flux's Debug perspective is similar to the Gloop's Debug perspective wherein the workspace is re-arranged so that it shows all views relevant when debugging.

The Flux Debug perspective

The Flux Debug perspective

When debugging a Flux service, the user is given the option to use the Flux Debug perspective. The prompt is displayed after inputs have been set.

Triggering the Flux Debug perspective

Triggering the Flux Debug perspective

Debug view

This view shows the debug execution stack of services that are currently and have been debugged.

Debug view

Debug view

Variables view

This view shows the current context of the service being debugged. The context is made available for display when the service's execution is suspended. It consists mainly of Flux service inputs and outputs. If execution halts while on a state, then the state's input and output variables are added; if on a transition, then the transition's input and output variables are added.

Variables view

Variables view

Expressions view

This view allows you to run Groovy statements that use the variables available in the context; all you have to do is define and add the expressions.

In the example below, an expression was added to calculate the total price of all cart items with an additional price of 20 each:

Evaluating expressions via the Expressions view

Evaluating expressions via the Expressions view

Read-only evaluation

The evaluations made while debugging do not alter the values of the context.

Breakpoints view

This view shows all the breakpoints you have added via the Flux service editor. You could enable/disable the breakpoints by toggling the checkbox beside each entry.

Breakpoints view

Breakpoints view

Shortcuts

Command Description Shortcut
Debug Debugs the service previously run
Toggle Breakpoint Adds or removes a breakpoint
Resume Resumes the debug execution
Terminate Stops the debug execution
Step Into Executes the current state or transition and suspends the execution before entering the next state or transition
Step Over Executes the current state and transition and suspends the execution before entering the next state
Command Description Shortcut
Debug Debugs the service previously run
Toggle Breakpoint Adds or removes a breakpoint
Resume Resumes the debug execution
Pause Suspends the debug execution
Terminate Stops the debug execution
Step Into Executes the current state or transition and suspends the execution before entering the next state or transition
Step Over Executes the current state and transition and suspends the execution before entering the next state