The Command API provides a type-safe, fluent interface for
building and executing Concourse operations. Commands can be
constructed programmatically, parsed from CCL strings, executed
individually, or submitted as a batch.
Await commands take the longest time to wait as their first
argument. The rest of the command is built the same way as the
read it waits for. Like all awaits, they can’t run inside a
transaction, including one started by an earlier stage in the
same batch.
// JavaCommandcmd=Command.parse("select name from 1");// Parse multiple semicolon-separated commandsList<Command>cmds=Command.parseAll("add name as Jeff in 1; set age as 30 in 1");
Both families execute commands sequentially in a single
server round trip. If any command fails, execution stops and
the exception is propagated immediately.
// Java// Single commandObjectresult=concourse.exec(Command.to().get("name").from(1));// Multiple commands as varargs — returns last resultObjectlast=concourse.exec(Command.to().add("name").as("Jeff").in(1),Command.to().add("age").as(30).in(1),Command.to().select("name",1));// From a pre-built listList<Command>cmds=...;Objectlast=concourse.exec(cmds);// Directly from CCL textObjectlast=concourse.exec("add name as Jeff in 1; select name from 1");
// Java// Single command — returns a one-element listList<Object>r=concourse.submit(Command.to().add("name").as("Jeff").in(1));// Multiple commands as varargsList<Object>results=concourse.submit(Command.to().add("name").as("Jeff").in(1),Command.to().add("age").as(30).in(1),Command.to().select(1));// From a pre-built listList<Command>cmds=...;List<Object>results=concourse.submit(cmds);// Directly from CCL text (semicolon- or newline-separated)List<Object>results=concourse.submit("add name as Jeff in 1; add age as 30 in 1");// From a CommandGroup built via prepare()List<Object>results=concourse.submit(group);
In CCL text form, commands are separated by a semicolon (;)
or a newline. Whitespace between commands is ignored.
prepare() returns a CommandGroup — a void-returning
mirror of the entire Concourse API. Call methods on the group
to accumulate operations, then pass the group to submit() to
execute them all in a single round trip.
CommandGroup supports every read, write, aggregation,
atomic, await, and system operation that Concourse does:
select, get, find, browse, navigate, audit,
chronicle, trace, consolidate, calculate,
verifyAndSwap, verifyOrSet, findOrAdd, findOrInsert,
findAndSet, selectAndSet, getAndSet, awaitFind,
awaitSelect, awaitGet, stage, commit,
abort, ping, holds, inventory, and more. Each group
method signature matches the corresponding method on
Concourse but returns void — results surface when the
group is submitted.
This returns an unmodifiable snapshot of the commands the group
has collected. It is useful for logging, assertions in tests,
or rendering a preview of what submit(group) will execute.