Minga.Buffer.Messages (Minga v0.1.0)

Copy Markdown View Source

Owner of the BEAM-wide singleton *Messages* buffer.

One process, one buffer pid, regardless of how many editors are running. This matches emacs --daemon semantics: a single message log that outlives any individual frame (editor) and is available even in headless mode where no editor exists.

Responsibilities

  • Starts and supervises a single Minga.Buffer process under Minga.Buffer.Supervisor with buffer_name: "*Messages*".
  • Subscribes to the :log_message Events topic and appends every broadcast entry to that buffer with a timestamp prefix.
  • Drains any entries the Minga.LoggerHandler ETS pre-subscribe buffer captured before this process was up.
  • Trims the buffer to @max_lines lines so it stays bounded.

Boot order

Minga.LoggerHandler.install_messages_handler/0 runs at application start, before this process is supervised. Logs emitted during early boot land in the LoggerHandler ETS pre-subscribe buffer; this process drains that buffer in init/1, so no entries are lost.

Summary

Functions

Returns a specification to start this module under a supervisor.

Returns the pid of the singleton *Messages* buffer, or nil if the owner has never started successfully.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

pid()

@spec pid() :: pid() | nil

Returns the pid of the singleton *Messages* buffer, or nil if the owner has never started successfully.

Reads from :persistent_term so it never blocks on the owner's mailbox, even during heavy log bursts.