Class ScenarioReader
This is what makes the studio worth using: what it exports, this reads, and the command line runs it. Without this the studio would be a drawing tool whose output somebody has to translate by hand — and a translation is a place for the two to diverge.
Both formats, because both exist for good reasons. The studio writes JSON because that is what its API speaks; a person editing a scenario in a repository writes YAML because comments matter more than machine-readability there.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA scenario file that cannot be read, with what is wrong with it. -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringdescribe(ScenarioFile file) static booleanisScenario(Path path) Whether a file is a scenario rather than a single-path workload.static ScenarioFileA scenario somebody handed over, rather than one read from disk.static ScenarioFilestatic String
-
Method Details
-
read
- Parameters:
path- a scenario file,.jsonor.yaml- Returns:
- what it describes
- Throws:
ScenarioReader.ScenarioFormatException- if it cannot be read
-
parse
A scenario somebody handed over, rather than one read from disk.Used when the studio opens a file: the bytes arrive over HTTP and the format is decided by the name when there is one and by the first character when there is not.
${VAR}is left alone here. Resolving it would read the studio's own environment on behalf of whoever uploaded the file, and hand back the result — a broker URL containing${AWS_SECRET_ACCESS_KEY}would come back with the value in it. The placeholder stays a placeholder, and is resolved by the command line at the point where the person running it owns the environment.- Parameters:
text- the file's contentsfileName- what it was called, or null- Returns:
- what it describes
- Throws:
ScenarioReader.ScenarioFormatException- if it cannot be read
-
isScenario
Whether a file is a scenario rather than a single-path workload.Decided by what is in it rather than by a flag somebody has to remember: a scenario describes exchanges, queues and producers, and a workload describes a topology with publishers and consumers. Two shapes, one
-f.- Parameters:
path- the file- Returns:
- whether it looks like a scenario
-
describe
- Returns:
- what to say about a scenario before running it
-
redact
- Parameters:
url- a broker URL @return the same URL with the password taken out
-