Documentation
¶
Overview ¶
Package mock provides an in-process, CGo-free implementation of the dds interfaces. All participants within the same process share a global in-memory broker: a Publisher.Write on topic T is delivered synchronously to every Subscriber.C() for topic T.
The mock is the default implementation used by unit tests. Switch to the rtps or cyclone package when a real DDS domain (multi-process, multi-host) is required.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New creates a mock DDS Participant for the given domain. Domain is accepted for API compatibility but has no effect — all mock participants share the same global broker regardless of domain (unless IsolatedBroker is used).
func NewLoaningPublisher ¶ added in v0.16.0
func NewLoaningPublisher(p dds.Participant, topic string, qos dds.QoS, bufSize int) (dds.LoaningPublisher, error)
NewLoaningPublisher creates a LoaningPublisher for topic using the given QoS. bufSize is the maximum sample size the pool will pre-allocate; pass 0 for the pool default (4096 bytes).
Types ¶
type Option ¶ added in v0.3.0
type Option func(*participant)
Option configures a mock participant.
func IsolatedBroker ¶ added in v0.9.0
func IsolatedBroker() Option
IsolatedBroker creates the participant with its own independent broker that is not shared with any other participant. Use this when testing components that bridge between separate DDS domains (e.g. the WAN bridge), where publishing on one participant must not echo to subscribers on another.
func WithContext ¶ added in v0.10.0
WithContext returns an Option that closes the participant when ctx is done. This is the idiomatic Go shutdown pattern: pass a context with a cancel function or deadline to tie the participant's lifetime to an outer scope.
func WithDeadlineCallback ¶ added in v0.3.0
WithDeadlineCallback registers fn to be called when a publisher has not written within its QoS.Deadline period.
func WithLivelinessCallback ¶ added in v0.4.0
func WithLivelinessCallback(fn func(dds.GUID, dds.LivelinessEvent)) Option
WithLivelinessCallback registers fn to be called when a participant is discovered or lost. In the mock, participants fire LivelinessGained on New and LivelinessLost on Close.
func WithLogger ¶ added in v0.4.0
WithLogger sets the structured logger used by this participant. Log output is zero-cost when l is nil.