Documentation
¶
Overview ¶
Package mux implements the ISO-8583 switch: it multiplexes request/response exchanges over a single full-duplex link.Link, correlating each response to its in-flight request by a caller-supplied key (typically STAN + terminal). A background reader dispatches frames to waiting callers; unmatched frames go to an optional unsolicited handler. (Named "mux" rather than "switch" because switch is a Go keyword and cannot be an import identifier.)
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrTimeout = errors.New("mux: request timed out") ErrClosed = errors.New("mux: closed") ErrDuplicateKey = errors.New("mux: a request with this key is already in flight") )
Mux errors.
Functions ¶
This section is empty.
Types ¶
type Keyer ¶
Keyer extracts a correlation key from a message frame. The key for a request and its response must match.
type Mux ¶
type Mux struct {
// contains filtered or unexported fields
}
Mux correlates requests and responses over a link.
func (*Mux) Done ¶ added in v0.2.0
func (m *Mux) Done() <-chan struct{}
Done returns a channel closed when the mux stops — because Close was called or the underlying link's read loop failed. A supervisor (e.g. a reconnecting connector) selects on it to learn the link died without issuing a request.
type Option ¶
type Option func(*config)
Option configures a Mux.
func WithTimeout ¶
WithTimeout sets the default per-request timeout (0 = none; rely on context).
func WithUnsolicitedHandler ¶
WithUnsolicitedHandler sets a handler for frames that match no in-flight request (server-initiated requests, late responses). It runs on the reader goroutine, so it must not block.