# `Juggernaut.View.Stream`
[🔗](https://github.com/holsee/juggernaut/blob/v0.4.0/lib/juggernaut/view/stream.ex#L1)

The NDJSON event stream (`--stream`, see the [agent output guide](agent-output.md)),
format 1: one compact JSON object per line, each with `v`, `event`, `run_id` and `t_ms`
(milliseconds since the run started) first.

The runner describes what happens as `t:event/0` values; `lines/4` turns one into its
lines. The same events drive the live terminal view (`Juggernaut.View.Live`), so both
show the same run. A `mutant` event whose result is listed as a survivor is followed by
a `survivor` line carrying the full agent survivor object; `run_finished` is followed by
a `report` line holding the agent document when the `report` option is set
(`--stream --format agent`).

A `mutant` line's `test_lane` is the test lane of a kill (`unit`, or `integration`
when only an integration test killed it), `null` otherwise; `run_finished` counts
those in `counts.integration_only`.

# `event`

```elixir
@type event() ::
  {:run_started, Juggernaut.Run.t()}
  | {:phase_started, Juggernaut.Phase.name()}
  | {:phase_finished, Juggernaut.Phase.t()}
  | {:plan,
     %{
       mutants: non_neg_integer(),
       by_file: %{required(String.t()) =&gt; non_neg_integer()},
       ignored: non_neg_integer()
     }}
  | {:reuse, %{reused: non_neg_integer(), recorded_ms: non_neg_integer()}}
  | {:worker,
     %{
       worker: non_neg_integer() | :boot,
       state: :up | :recycled | :down,
       reason: String.t() | nil,
       duration_ms: non_neg_integer() | nil
     }}
  | {:mutant, Juggernaut.Mutant.t(), Juggernaut.Result.t()}
  | {:boot_lane,
     %{
       mutants: non_neg_integer(),
       concurrency: pos_integer(),
       reason: String.t()
     }}
  | {:warning,
     %{
       code: atom(),
       message: String.t(),
       file: String.t() | nil,
       line: pos_integer() | nil
     }}
  | {:run_finished, Juggernaut.Run.t()}
```

Something that happened in a run, as the views see it.

# `lines`

```elixir
@spec lines(
  event(),
  String.t(),
  non_neg_integer(),
  keyword() | Juggernaut.View.options()
) :: iodata()
```

The NDJSON lines (each ending in a newline) of one event.

# `objects`

```elixir
@spec objects(
  event(),
  String.t(),
  non_neg_integer(),
  keyword() | Juggernaut.View.options()
) :: [
  Jason.OrderedObject.t()
]
```

The JSON objects of one event, in line order.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
