class Obsctl::CLI::Watcher

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

Constant Summary

DEFAULT_TOPICS = TOPICS
SUBSCRIBE_ID = "watch-subscribe"
TOPICS = ["state", "events", "logs"]

Constructors

Class Method Summary

Instance Method Summary

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))) #

[View source]

Class Method Detail

def self.subscribe(socket_path : String, topics : Array(String)) : IPC::ClientSession #

Opens a subscription session for the requested topics.


[View source]
def self.validate_topics!(topics : Array(String)) : Array(String) #

Validates topic names against the set the daemon publishes.


[View source]

Instance Method Detail

def run : Int32 #

Streams until the daemon closes the connection or the limit is reached.


[View source]