Documentation
¶
Overview ¶
Package rabbitmqtest is a small AMQP 0-9-1 broker for tests.
It does not implement headers exchanges (declare returns 540 NOT_IMPLEMENTED), message TTL, priority ordering, queue-type behaviour, or persistence. Those values are stored and, where a reply echoes them, sent back unchanged.
Index ¶
- type Config
- type ConnInfo
- type Pub
- type Server
- func (s *Server) Addr() string
- func (s *Server) Apply(cfg Config)
- func (s *Server) Block(reason string)
- func (s *Server) CloseChannelOn(method string, code uint16, text string)
- func (s *Server) ConnCount() int
- func (s *Server) Connections() []ConnInfo
- func (s *Server) Delay(d time.Duration)
- func (s *Server) Depth(name string) int
- func (s *Server) DropConnectionOn(method string)
- func (s *Server) Methods() []string
- func (s *Server) NackPublishes(on bool)
- func (s *Server) OpenConns() int
- func (s *Server) PeakUnacked(name string) int
- func (s *Server) Published() []Pub
- func (s *Server) Push(queue, messageID, body string) bool
- func (s *Server) Queues() []string
- func (s *Server) RefuseConnections(on bool)
- func (s *Server) StallOn(method string)
- func (s *Server) URL() string
- func (s *Server) Unacked(name string) int
- func (s *Server) Unblock()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
Config is the login and vhost set. An empty Users map accepts guest/guest. An empty Vhosts list accepts only "/".
type Pub ¶
type Pub struct {
Exchange string
RoutingKey string
Body []byte
MessageID string
ContentType string
Expiration string
DeliveryMode uint8
Priority uint8
Timestamp time.Time
Headers map[string]any
Mandatory bool
}
Pub is one basic.publish the broker accepted into its log, including messages that were then returned as not routed.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is an in-memory AMQP 0-9-1 broker.
func Start ¶
func Start(t testingT) *Server
Start listens on 127.0.0.1:0 and accepts connections until the test ends.
func StartTLS ¶
func StartTLS(t testingT) *Server
StartTLS is Start with a certificate the process generated. Clients that verify certificates fail. Clients that skip verification succeed.
func (*Server) CloseChannelOn ¶
CloseChannelOn answers the named method with channel.close.
func (*Server) Connections ¶
Connections lists connections that finished connection.open.
func (*Server) DropConnectionOn ¶
DropConnectionOn closes the TCP connection when the named method arrives.
func (*Server) NackPublishes ¶
NackPublishes makes publisher confirms nack instead of ack.
func (*Server) PeakUnacked ¶
PeakUnacked is the most unacked messages this queue has had at once.
func (*Server) Push ¶
Push puts a message on a queue and delivers it if a consumer is waiting. Tests use it for a message the caller did not publish.
func (*Server) RefuseConnections ¶
RefuseConnections closes each accepted socket before the handshake.