MCPcopy
hub / github.com/mudler/LocalAI / FakeBus

Struct FakeBus

core/services/testutil/fakebus.go:23–34  ·  view source on GitHub ↗

FakeBus is an in-memory messaging.MessagingClient that delivers each published message synchronously to every registered subscriber whose subject filter matches, including NATS-style wildcard subjects (`*` matches exactly one token). Synchronous delivery keeps specs deterministic: the moment Publis

Source from the content-addressed store, hash-verified

21// delivery semantics. It deliberately depends only on the standard library and
22// the messaging package — no test framework — so it is importable anywhere.
23type FakeBus struct {
24 mu sync.Mutex
25 subs []fakeBusSub
26 // publishCounts records how many messages were published per subject, so a
27 // spec can assert the echo-loop guard (an applied delta must not re-publish).
28 publishCounts map[string]int
29
30 // reconnectCbs back the optional OnReconnect/TriggerReconnect pair, letting a
31 // spec exercise the component's reconnect re-hydrate path without a real
32 // NATS server.
33 reconnectCbs []func()
34}
35
36type fakeBusSub struct {
37 subject string

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected