Skip to content

RexConnect Conditional Execution

Zach Kinstner edited this page Sep 3, 2013 · 5 revisions

Written for version 0.5.0.

Overview

There are various scenarios where it is beneficial to conditionally execute a RexConnect command. RexConnect provides this functionality via the RequestCmd.e property. This property represents a list of command IDs, whose responses must be "successful" in order for the current command to execute.

Rules

  • If a command does not specify any target command IDs, then it will execute.
  • A conditional command may specify one or more target command IDs.
  • The target commands must be positioned before the conditional command.
  • The conditional command is not executed if any of these are true (for any target command):
  • The response is "false" or "0".
  • The response has an error.
  • The response is empty.
  • The target command did not occur.

Benefits

The key benefit of conditional command execution: a single RexConnect can dynamically decide which individual commands to execute based on actual command results. Without this feature, a RexConnect user may need to make several round-trips to the server and/or wrap several of their command queries in if-then clauses (which still isn't as good -- such "wrapped" queries still must be executed).

The origin of this feature comes from a Fabric "batch" scenario, where several vertices/edges are added in the same RexConnect request, but can fail individually. Notes and ideas leading up to conditional execution are available in this Fabric issue.