# `Minga.Project.FileFind.Worker`
[🔗](https://github.com/jsmestad/minga/blob/main/lib/minga/project/file_find/worker.ex#L1)

Owns one external project-file discovery process.

The worker monitors its requester and terminates the external process tree when cancelled or when the requester exits. Port output is accumulated asynchronously with byte and file-count bounds so project discovery cannot exhaust the VM.

# `cancel_result`

```elixir
@type cancel_result() :: :ok | {:error, String.t()}
```

Cancellation result.

# `command`

```elixir
@type command() ::
  {executable :: String.t(), args :: [String.t()], directory :: String.t()}
```

An external command with an executable, arguments, and working directory.

# `option`

```elixir
@type option() ::
  {:max_output_bytes, pos_integer()} | {:max_file_count, pos_integer()}
```

Worker options.

# `parser`

```elixir
@type parser() :: (String.t(), non_neg_integer() -&gt; term())
```

Transforms command output and exit status into a discovery result.

# `t`

```elixir
@type t() :: %Minga.Project.FileFind.Worker{
  file_count: non_neg_integer(),
  max_file_count: pos_integer(),
  max_output_bytes: pos_integer(),
  output: [binary()],
  output_bytes: non_neg_integer(),
  owner: pid(),
  owner_ref: reference(),
  parser: parser(),
  port: port() | nil
}
```

Worker state.

# `cancel`

```elixir
@spec cancel(pid()) :: cancel_result()
```

Cancels discovery and waits for its external process tree to terminate.

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `start`

```elixir
@spec start(pid(), command(), parser(), [option()]) :: GenServer.on_start()
```

Starts an unlinked discovery worker monitored by its owner.

---

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