NotificationBusInterface
Carries server-initiated notifications to whichever `subscriptions/listen` streams are open.
A bus and not a registry of listeners, because the two ends are rarely in the
same process: under PHP-FPM the request that changes the tool list and the
request holding a listen stream open are different workers, so the only thing
they can share is storage. The read side is a cursor rather than a
subscription: a stream that opens at cursor c reads forward from c, and
nothing has to know a stream exists before it does.
Implementations are expected to drop old entries — a listen stream that goes away must not make the backlog grow without bound.
Tags
Table of Contents
Methods
- cursor() : int
- The cursor a stream opening now should start from.
- publish() : void
- Publishes a notification to every stream currently reading forward.
- since() : Notification>, int}
- Notifications published after $cursor, and the cursor to read from next.
Methods
cursor()
The cursor a stream opening now should start from.
public
cursor() : int
Deliberately "now" and not "the beginning": a client that subscribes wants what happens next, not a replay of everything the server has done.
Return values
intpublish()
Publishes a notification to every stream currently reading forward.
public
publish(Notification $notification) : void
Parameters
- $notification : Notification
since()
Notifications published after $cursor, and the cursor to read from next.
public
since(int $cursor) : Notification>, int}
Parameters
- $cursor : int