Documentation
¶
Index ¶
- Variables
- type NATS
- func (n *NATS) Publish(subject string, data []byte) error
- func (n *NATS) PublishWithReply(subject string, data []byte, timeout time.Duration) ([]byte, error)
- func (n *NATS) QueueSubscribeSync(subject, queue string) *nats.Subscription
- func (n *NATS) Shutdown()
- func (n *NATS) SubscribeSync(subject string) *nats.Subscription
- func (n *NATS) WaitForMessage(sub *nats.Subscription, timeout time.Duration) *nats.Msg
- func (n *NATS) WaitForSubscribers(numSubscribers int, timeout time.Duration) bool
Constants ¶
This section is empty.
Variables ¶
var ( // ErrServerStartTimeout indicates the NATS server failed to start within the timeout period. ErrServerStartTimeout = eris.New("NATS server failed to start within timeout") // ErrPublishTimeout indicates a publish operation timed out. ErrPublishTimeout = eris.New("publish operation timed out") // ErrSubscriberTimeout indicates waiting for subscribers timed out. ErrSubscriberTimeout = eris.New("timeout waiting for subscribers") )
Functions ¶
This section is empty.
Types ¶
type NATS ¶
type NATS struct {
Server *server.Server
Client *nats.Conn
// contains filtered or unexported fields
}
NATS represents a test NATS server with its client.
func NewNATS ¶
NewNATS creates a new NATS test server with a connected client. It automatically registers cleanup with t.Cleanup().
func (*NATS) Publish ¶
Publish publishes a message to a subject. Returns an error if the publish operation fails.
func (*NATS) PublishWithReply ¶
PublishWithReply publishes a message to a subject and waits for a reply. Returns the reply data and any error that occurred.
func (*NATS) QueueSubscribeSync ¶
func (n *NATS) QueueSubscribeSync(subject, queue string) *nats.Subscription
QueueSubscribeSync creates a synchronous queue subscription and returns it. The subscription is automatically cleaned up when the test ends.
func (*NATS) Shutdown ¶
func (n *NATS) Shutdown()
Shutdown gracefully shuts down the NATS test server and client.
func (*NATS) SubscribeSync ¶
func (n *NATS) SubscribeSync(subject string) *nats.Subscription
SubscribeSync creates a synchronous subscription and returns it. The subscription is automatically cleaned up when the test ends.
func (*NATS) WaitForMessage ¶
WaitForMessage waits for a message on the given subscription. Returns the received message or fails the test if timeout is reached.