LogShipper class
Batches a node's log lines and ships them to the Hub.
A node agent already knows how to push a LogBatch; nothing ever called it, so a node's own log stayed on the node — where you can only read it by logging into the machine, which is the thing a fleet tool exists to avoid.
Batched rather than sent line by line: a log line is small and a control-frame round trip is not, so a chatty agent would spend more effort announcing what it did than doing it. Lines are flushed when maxLines accumulate, or after interval, whichever comes first — so a burst is coalesced and a trickle still arrives promptly.
Best-effort by design: if the link is down the lines are dropped rather than queued forever. A node's log tail is for looking at what a machine is doing now; a backlog replayed on reconnect would be a different, less useful thing, and an unbounded queue is how an agent runs a machine out of memory.
Constructors
-
LogShipper({required void send(List<
String> lines), int maxLines = 50, Duration interval = const Duration(seconds: 2)}) -
Creates a shipper that hands batches to
send.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- interval → Duration
-
How long to wait before flushing whatever has accumulated.
final
- maxLines → int
-
How many lines to accumulate before flushing early.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
send
→ void Function(List<
String> lines) -
Sends a batch. Wired to
NodeAgent.sendLogs.final
Methods
-
add(
String line) → void -
Queues
linefor shipping. -
close(
) → void - Flushes and stops.
-
flush(
) → void - Ships whatever has accumulated.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited