package fake
import "github.com/Azure/go-amqp/internal/fake"
Index ¶
- Variables
- func EncodeFrame(t frames.Type, channel uint16, f frames.FrameBody) ([]byte, error)
- func PerformBegin(channel, remoteChannel uint16) ([]byte, error)
- func PerformClose(e *encoding.Error) ([]byte, error)
- func PerformDetach(channel uint16, linkHandle uint32, e *encoding.Error) ([]byte, error)
- func PerformDisposition(role encoding.Role, channel uint16, firstID uint32, lastID *uint32, state encoding.DeliveryState) ([]byte, error)
- func PerformEnd(channel uint16, e *encoding.Error) ([]byte, error)
- func PerformOpen(containerID string) ([]byte, error)
- func PerformTransfer(channel uint16, linkHandle, deliveryID uint32, payload []byte) ([]byte, error)
- func ProtoHeader(id ProtoID) ([]byte, error)
- func ReceiverAttach(channel uint16, linkName string, linkHandle uint32, mode encoding.ReceiverSettleMode, filter encoding.Filter) ([]byte, error)
- func SenderAttach(channel uint16, linkName string, linkHandle uint32, mode encoding.SenderSettleMode) ([]byte, error)
- type AMQPProto
- type KeepAlive
- type NetConn
- func NewNetConn(resp func(remoteChannel uint16, fr frames.FrameBody) (Response, error), opts NetConnOptions) *NetConn
- func (n *NetConn) Close() error
- func (n *NetConn) LocalAddr() net.Addr
- func (n *NetConn) Read(b []byte) (int, error)
- func (n *NetConn) RemoteAddr() net.Addr
- func (n *NetConn) SendFrame(f []byte)
- func (n *NetConn) SendKeepAlive()
- func (n *NetConn) SendMultiFrameTransfer(channel uint16, linkHandle, deliveryID uint32, payload []byte, edit func(int, *frames.PerformTransfer)) error
- func (n *NetConn) SetDeadline(t time.Time) error
- func (n *NetConn) SetReadDeadline(t time.Time) error
- func (n *NetConn) SetWriteDeadline(t time.Time) error
- func (n *NetConn) Write(b []byte) (int, error)
- type NetConnOptions
- type ProtoID
- type Response
Variables ¶
ErrAlreadyClosed is returned by Close() if NetConn is already closed.
Functions ¶
func EncodeFrame ¶
EncodeFrame encodes the specified frame to be sent over the wire.
func PerformBegin ¶
PerformBegin appends a PerformBegin frame with the specified remote channel ID. This frame is needed when making a call to Client.NewSession().
func PerformClose ¶
PerformClose encodes a PerformClose frame with an optional error.
func PerformDetach ¶
PerformDetach encodes a PerformDetach frame with an optional error.
func PerformDisposition ¶
func PerformDisposition(role encoding.Role, channel uint16, firstID uint32, lastID *uint32, state encoding.DeliveryState) ([]byte, error)
PerformDisposition appends a PerformDisposition frame with the specified values. The firstID MUST match the deliveryID value specified in PerformTransfer.
func PerformEnd ¶
PerformEnd encodes a PerformEnd frame with an optional error.
func PerformOpen ¶
PerformOpen appends a PerformOpen frame with the specified container ID. This frame, and ProtoHeader, are needed when calling amqp.New() to create a client.
func PerformTransfer ¶
PerformTransfer appends a PerformTransfer frame with the specified values. The linkHandle MUST match the linkHandle value specified in ReceiverAttach.
func ProtoHeader ¶
ProtoHeader adds the initial handshake frame to the list of responses. This frame, and PerformOpen, are needed when calling amqp.New() to create a client.
func ReceiverAttach ¶
func ReceiverAttach(channel uint16, linkName string, linkHandle uint32, mode encoding.ReceiverSettleMode, filter encoding.Filter) ([]byte, error)
ReceiverAttach appends a PerformAttach frame with the specified values. This frame is needed when making a call to Session.NewReceiver().
func SenderAttach ¶
func SenderAttach(channel uint16, linkName string, linkHandle uint32, mode encoding.SenderSettleMode) ([]byte, error)
SenderAttach encodes a PerformAttach frame with the specified values. This frame is needed when making a call to Session.NewSender().
Types ¶
type AMQPProto ¶
AMQPProto is the frame type passed to FrameCallback() for the initial protocal handshake.
type KeepAlive ¶
KeepAlive is the frame type passed to FrameCallback() for keep-alive frames.
type NetConn ¶
type NetConn struct { // OnClose is called from Close() before it returns. // The value returned from OnClose is returned from Close(). OnClose func() error // ReadErr is used to simulate a connReader error. // The error written to this channel is returned // from the call to NetConn.Read. ReadErr chan error // WriteErr is used to simulate a connWriter error. // The error sent here is returned from the call to NetConn.Write. // Has a buffer of one so setting a pending error won't block. WriteErr chan error // contains filtered or unexported fields }
NetConn is a fake network connection that satisfies the net.Conn interface.
func NewNetConn ¶
func NewNetConn(resp func(remoteChannel uint16, fr frames.FrameBody) (Response, error), opts NetConnOptions) *NetConn
NewNetConn creates a new instance of NetConn. Responder is invoked by Write when a frame is received. Return a zero-value Response/nil error to swallow the frame. Return a non-nil error to simulate a write error. NOTE: resp is called on a separate goroutine so it MUST NOT access any *testing.T etc
func (*NetConn) Close ¶
Close is called by conn.close.
func (*NetConn) LocalAddr ¶
func (*NetConn) Read ¶
Read is invoked by conn.connReader to recieve frame data. It blocks until Write or Close are called, or the read deadline expires which will return an error.
func (*NetConn) RemoteAddr ¶
func (*NetConn) SendFrame ¶
SendFrame sends the encoded frame to the client. Use this to send a frame at an arbitrary time.
func (*NetConn) SendKeepAlive ¶
func (n *NetConn) SendKeepAlive()
SendKeepAlive sends a keep-alive frame to the client.
func (*NetConn) SendMultiFrameTransfer ¶
func (n *NetConn) SendMultiFrameTransfer(channel uint16, linkHandle, deliveryID uint32, payload []byte, edit func(int, *frames.PerformTransfer)) error
SendMultiFrameTransfer splits payload into 32-byte chunks, encodes, and sends to the client. Payload must be big enough for at least two chunks.
func (*NetConn) SetDeadline ¶
func (*NetConn) SetReadDeadline ¶
func (*NetConn) SetWriteDeadline ¶
func (*NetConn) Write ¶
Write is invoked by conn.connWriter when we're being sent frame data. Every call to Write will invoke the responder callback that must reply with one of three possibilities.
- an encoded frame and nil error
- a non-nil error to similate a write failure
- a nil slice and nil error indicating the frame should be ignored
type NetConnOptions ¶
type NetConnOptions struct { // ChunkSize is the size of chunks to split responses into. // A zero or negative value means no chunking. // The default value is zero. ChunkSize int }
NetConnOptions contains options when creating a NetConn. Pass the zero-value to accept the default values.
type ProtoID ¶
type ProtoID uint8
ProtoID indicates the type of protocol (copied from conn.go)
type Response ¶
type Response struct { // Payload is the marshalled frame to send to Conn.connReader Payload []byte // WriteDelay is the duration to wait before writing Payload. // Use this to introduce a delay when waiting for a response. WriteDelay time.Duration // ChunkSize is the size of chunks to split Payload into. // A zero or negative value means no chunking. // This value supercedes the NetConnOptions.ChunkSize. ChunkSize int }
Response is the response returned from a responder function.
Source Files ¶
- Version
- v1.4.0 (latest)
- Published
- Feb 19, 2025
- Platform
- linux/amd64
- Imports
- 7 packages
- Last checked
- 5 days ago –
Tools for package owners.