Documentation
¶
Overview ¶
Package memory provides an in-process signaling hub for tests and same-process examples. It routes envelopes between peers registered on the same Hub without sockets, and it can inject faults deterministically so that duplicate, dropped, reordered, and disconnected signaling can be tested without timing luck.
Index ¶
Constants ¶
const DefaultQueueSize = 64
DefaultQueueSize is the per-peer inbound queue depth.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Fault ¶
Fault transforms one outbound signal into the signals actually delivered. Returning an empty slice drops the signal; returning several copies duplicates it. Implementations must be safe for concurrent use.
func DropFirst ¶
func DropFirst(kind pipe.SignalKind, n int) Fault
DropFirst drops the first n signals of the given kind and delivers the rest.
func DropKind ¶
func DropKind(kinds ...pipe.SignalKind) Fault
DropKind drops every signal of the given kinds.
func DuplicateAll ¶
func DuplicateAll() Fault
DuplicateAll delivers every signal twice, which exercises deduplication.
func SwapAdjacent ¶
func SwapAdjacent(kind pipe.SignalKind) Fault
SwapAdjacent holds back every other signal of the given kind and releases it after the next one, which reorders delivery deterministically. An odd final signal stays held, so this fault also drops at most one signal per kind.
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
Hub is an in-process signaling relay. It implements pipe.Signaler and may be shared by any number of endpoints with distinct peer IDs.
func (*Hub) Disconnect ¶
Disconnect closes the signaling connection of one peer as if its transport had failed. It reports whether the peer was registered.
func (*Hub) Open ¶
Open registers local and returns its signaling connection. Registering a peer ID that is already live fails with pipe.ErrDuplicatePeer.
func (*Hub) Registered ¶
Registered returns the peer IDs with a live connection.