Compile and register a strategy
Compiles raw strategy source and registers it, returning its strategyId.
The source is either Java — a class extending a strategy base class — or QTScript
(beta), a compact strategy language whose braced bodies are plain Java. QTScript source
begins with the strategy keyword — whitespace and comments (// or * *) before it
are ignored — and that is how the two are told apart: there is no separate endpoint and
no header to set. Once registered, a strategy is used the same way
whichever language it was written in.
This answers one question: is the source valid. It compiles, registers, and hands
back the id — nothing more. Whether the class can actually run is
POST /strategy/{strategyId}/validate, and everything known about a strategy, validation
included, is read from GET /strategy/{strategyId}. One place to ask, so there is no second
answer to keep in step.
For Java, the strategyId is derived from what the code means, not from how it is
written. Adding a comment, inserting a blank line, re-indenting, reordering imports, or
moving a method around all return the same id — you have not created a second strategy.
Renaming a variable, changing an identifier's case, reordering fields, or reordering
statements inside a method return a different one.
For QTScript, the id is derived from the text, because indentation is part of its
grammar. Only differences that cannot change the strategy are ignored: a byte-order mark, the
style of line endings, whitespace at the end of a line, and blank lines before the first and
after the last line. Anything else — a comment, the indentation, a blank line in between —
returns a different id.
Two rules follow, and they are worth designing around:
re-submitting a Java strategy you have only reformatted is free, and gives you back the id
you already had, along with any validation already recorded against it;
the id says nothing about behaviour. Two sources that compute the same thing by
different means are two strategies, because deciding otherwise would mean deciding program
equivalence.
The response also lists declaredProperties — the sweep/execute param keys this strategy
is known to accept, so a caller can catch a typo'd key before submitting a sweep instead of
only learning it from a rejected one. See DeclaredProperty: best-effort, not exhaustive.
Compile and register a strategy Compiles raw strategy source and registers it, returning its
strategyId.The source is either Java — a class extending a strategy base class — or QTScript (beta), a compact strategy language whose braced bodies are plain Java. QTScript source begins with the
strategykeyword — whitespace and comments (//or* *) before it are ignored — and that is how the two are told apart: there is no separate endpoint and no header to set. Once registered, a strategy is used the same way whichever language it was written in.This answers one question: is the source valid. It compiles, registers, and hands back the id — nothing more. Whether the class can actually run is
POST /strategy/{strategyId}/validate, and everything known about a strategy, validation included, is read fromGET /strategy/{strategyId}. One place to ask, so there is no second answer to keep in step.For Java, the
strategyIdis derived from what the code means, not from how it is written. Adding a comment, inserting a blank line, re-indenting, reordering imports, or moving a method around all return the same id — you have not created a second strategy. Renaming a variable, changing an identifier's case, reordering fields, or reordering statements inside a method return a different one.For QTScript, the id is derived from the text, because indentation is part of its grammar. Only differences that cannot change the strategy are ignored: a byte-order mark, the style of line endings, whitespace at the end of a line, and blank lines before the first and after the last line. Anything else — a comment, the indentation, a blank line in between — returns a different id.
Two rules follow, and they are worth designing around:
The response also lists
declaredProperties— the sweep/execute param keys this strategy is known to accept, so a caller can catch a typo'd key before submitting a sweep instead of only learning it from a rejected one. SeeDeclaredProperty: best-effort, not exhaustive.