NAME

Algorithm::Classifier::IsolationForest::App::Command::streamd - Run an Online Isolation Forest scoring daemon on a Unix socket, speaking JSON lines

DESCRIPTION

Wraps the prequential loop of iforest stream in a daemon: it listens on a Unix domain socket, serves many concurrent connections from one shared model, and exchanges one JSON document per line. Because values travel as JSON rather than positionally, raw input headed for mungers may safely contain commas, newlines or any unicode, and object rows run the full munger plan -- expanding and combining mungers included, which positional CSV cannot express.

An optional "tag" on a request is echoed back verbatim. Errors are always per-message: a bad row gets an {"error": ...} reply and the connection lives on.

Models are saved to --model-dir as timestamped files every --save-interval seconds when learning has happened, plus on the save command, on SIGUSR1, and at shutdown. The latest.json symlink is repointed atomically at each save and resumed from at the next startup, so a crash loses at most one interval of learning.

Several named instances can run side by side: --set gives each its own socket, pid file, model subdirectory and resume state.

iforest streamc is the matching client.

Run it as iforest streamd; iforest help streamd lists every option.

METHODS

App::Cmd calls these while dispatching the subcommand. Nothing else should.

opt_spec

Returns this command's option specifications, as the list of arrayrefs Getopt::Long::Descriptive expects.

abstract

Returns the one-line summary iforest commands prints beside the command name.

description

Returns the long help text iforest help streamd prints under the option list.

validate

Checks the parsed options before anything is read or written, so a mistake costs nothing.

Checks that --set is a usable instance name, that --save-interval, --keep, --threshold, --growth and --socket-mode hold sane values, and that a --mungers spec is readable and accompanied by the feature tags (-t) it compiles against.

Takes the parsed options hashref and the arrayref of remaining arguments. Calls usage_error, which prints the usage and exits, on the first problem it finds, and returns 1 when everything checks out.

execute

Prepares the runtime and model directories, daemonizes unless -f was given, and runs the accept/serve loop until it is asked to stop.

Takes the parsed options hashref and the arrayref of remaining arguments, and returns 1.