Minga.Project.FileFind.Worker (Minga v0.1.0)

Copy Markdown View Source

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.

Summary

Types

Cancellation result.

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

Worker options.

Transforms command output and exit status into a discovery result.

t()

Worker state.

Functions

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

Returns a specification to start this module under a supervisor.

Starts an unlinked discovery worker monitored by its owner.

Types

cancel_result()

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

Cancellation result.

command()

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

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

option()

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

Worker options.

parser()

@type parser() :: (String.t(), non_neg_integer() -> term())

Transforms command output and exit status into a discovery result.

t()

@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.

Functions

cancel(pid)

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

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

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start(owner, command, parser, opts \\ [])

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

Starts an unlinked discovery worker monitored by its owner.