Class TerminalNudges
- All Implemented Interfaces:
AutoCloseable,TerminalNudgePublisher
This is a TerminalNudgePublisher: hand it to MemoryTerminalSource.nudges(String, TerminalNudgePublisher) or
TerminalProcess.nudges(String, TerminalNudgePublisher), or call nudge(String, long, boolean) after a
write of your own. Each call is coalesced to at most one frame per terminal per 250 ms, carrying the latest offset,
and is published on term.nudge:<id> as
Wiring. The bus is built from the policy, so it is bound afterwards, once:
TerminalNudges
Access. TerminalAccess.canWatch(TerminalCaller, String) is called for every delivery, which is up to four
times per second per terminal, for each connected session that holds the grant (up to 256 by default). It must be
cheap. Only sessions holding the exact term.nudge:<id> grant receive a nudge; a session granted only
term.nudge:* receives none. A revocation that races a delivery can let that one frame through; the next is
denied.
Delivery runs on one daemon thread named juneau-terminal-nudges. nudge(String, long, boolean) only
records state and schedules, so it never blocks the writer.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionBinds the bus the nudges are published on, and starts the scheduler.voidclose()Stops the scheduler.static TerminalNudgescreate(TerminalAccess access) Creates a publisher.voidRecords that a terminal's bytes now end at an offset; delivery is coalesced and happens on the scheduler thread.static StringThe nudge topic of a terminal.
-
Field Details
-
FAMILY
The topic family; a terminal's topic isterm.nudge:<id>.- See Also:
-
-
Method Details
-
create
Creates a publisher.- Parameters:
access- Who may watch. Must not benull .- Returns:
- A new, unbound publisher.
- Throws:
IllegalArgumentException- Ifaccessisnull .
-
topic
The nudge topic of a terminal.- Parameters:
terminalId- The terminal id.- Returns:
term.nudge:<id>.- Throws:
IllegalArgumentException- If the id is not a valid run id.
-
bind
Binds the bus the nudges are published on, and starts the scheduler. May be called once.- Parameters:
bus- The bus. Its policy must allowterm.nudge:*downstream without retention.- Returns:
- This object.
- Throws:
IllegalArgumentException- Ifbusisnull .IllegalStateException- If a bus is already bound, or the policy does not allowterm.nudge:*downstream unretained.
-
nudge
Records that a terminal's bytes now end at an offset; delivery is coalesced and happens on the scheduler thread.Dropped silently before
bind(ServerBus)and afterclose().- Specified by:
nudgein interfaceTerminalNudgePublisher- Parameters:
terminalId- The terminal id.end- The offset one past the last byte.done-true if no more bytes will be appended.- Throws:
IllegalArgumentException- If the id is not a valid run id.
-
close
Stops the scheduler. Flushes already queued, and later nudges, deliver nothing. Idempotent.- Specified by:
closein interfaceAutoCloseable
-