class
Obsctl::CLI::Watcher
- Obsctl::CLI::Watcher
- Reference
- Object
Overview
Streams daemon events to stdout as newline-delimited JSON.
watch is the scripting counterpart to the TUI: it subscribes to the same
daemon topics and writes one self-describing JSON object per line, so a
consumer can pipe it into jq or read it line-by-line without framing
logic. Each line is flushed immediately; a buffered stream would make the
command useless for reacting to events as they happen.
Defined in:
obsctl/cli/watcher.crConstant Summary
-
DEFAULT_TOPICS =
TOPICS -
SUBSCRIBE_ID =
"watch-subscribe" -
TOPICS =
["state", "events", "logs"]
Constructors
Class Method Summary
-
.subscribe(socket_path : String, topics : Array(String)) : IPC::ClientSession
Opens a subscription session for the requested topics.
-
.validate_topics!(topics : Array(String)) : Array(String)
Validates topic names against the set the daemon publishes.
Instance Method Summary
-
#run : Int32
Streams until the daemon closes the connection or the limit is reached.
Constructor Detail
def self.new(socket_path : String, topics : Array(String) = DEFAULT_TOPICS, stdout : IO = STDOUT, limit : Int32 | Nil = nil, session_factory : SessionFactory = ->Watcher.subscribe(String, Array(String)))
#
Class Method Detail
def self.subscribe(socket_path : String, topics : Array(String)) : IPC::ClientSession
#
Opens a subscription session for the requested topics.
def self.validate_topics!(topics : Array(String)) : Array(String)
#
Validates topic names against the set the daemon publishes.