mocks

package
v0.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeFrame

func EncodeFrame(t FrameType, remoteChannel uint16, f frames.FrameBody) ([]byte, error)

EncodeFrame encodes the specified frame to be sent over the wire.

func PerformBegin

func PerformBegin(remoteChannel uint16) ([]byte, error)

PerformBegin appends a PerformBegin frame with the specified remote channel ID. This frame is needed when making a call to Client.NewSession().

func PerformClose

func PerformClose(e *encoding.Error) ([]byte, error)

PerformClose encodes a PerformClose frame with an optional error.

func PerformDetach

func PerformDetach(remoteChannel uint16, linkHandle uint32, e *encoding.Error) ([]byte, error)

PerformDetach encodes a PerformDetach frame with an optional error.

func PerformDisposition

func PerformDisposition(role encoding.Role, remoteChannel uint16, deliveryID uint32, state encoding.DeliveryState) ([]byte, error)

PerformDisposition appends a PerformDisposition frame with the specified values. The deliveryID MUST match the deliveryID value specified in PerformTransfer.

func PerformEnd

func PerformEnd(remoteChannel uint16, e *encoding.Error) ([]byte, error)

PerformEnd encodes a PerformEnd frame with an optional error.

func PerformOpen

func PerformOpen(containerID string) ([]byte, error)

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

func PerformTransfer(remoteChannel uint16, linkHandle, deliveryID uint32, payload []byte) ([]byte, error)

PerformTransfer appends a PerformTransfer frame with the specified values. The linkHandle MUST match the linkHandle value specified in ReceiverAttach.

func ProtoHeader

func ProtoHeader(id ProtoID) ([]byte, error)

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(remoteChannel uint16, linkName string, linkHandle uint32, mode encoding.ReceiverSettleMode) ([]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(remoteChannel 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

type AMQPProto struct {
	frames.FrameBody
}

AMQPProto is the frame type passed to FrameCallback() for the initial protocal handshake.

type FrameType

type FrameType uint8

FrameType indicates the type of frame (copied from sasl.go)

const (
	FrameAMQP FrameType = 0x0
	FrameSASL FrameType = 0x1
)

type KeepAlive

type KeepAlive struct {
	frames.FrameBody
}

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
	// contains filtered or unexported fields
}

NetConn is a mock network connection that satisfies the net.Conn interface.

func NewNetConn

func NewNetConn(resp func(frames.FrameBody) ([]byte, error)) *NetConn

NewNetConn creates a new instance of NetConn. Responder is invoked by Write when a frame is received. Return a nil slice/nil error to swallow the frame. Return a non-nil error to simulate a write error.

func (*NetConn) Close

func (n *NetConn) Close() error

Close is called by conn.close when conn.mux unwinds.

func (*NetConn) LocalAddr

func (n *NetConn) LocalAddr() net.Addr

func (*NetConn) Read

func (n *NetConn) Read(b []byte) (int, error)

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 (n *NetConn) RemoteAddr() net.Addr

func (*NetConn) SendFrame

func (n *NetConn) SendFrame(f []byte)

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) SetDeadline

func (n *NetConn) SetDeadline(t time.Time) error

func (*NetConn) SetReadDeadline

func (n *NetConn) SetReadDeadline(t time.Time) error

func (*NetConn) SetWriteDeadline

func (n *NetConn) SetWriteDeadline(t time.Time) error

func (*NetConn) Write

func (n *NetConn) Write(b []byte) (int, error)

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.

  1. an encoded frame and nil error
  2. a non-nil error to similate a write failure
  3. a nil slice and nil error indicating the frame should be ignored

type ProtoID

type ProtoID uint8

ProtoID indicates the type of protocol (copied from conn.go)

const (
	ProtoAMQP ProtoID = 0x0
	ProtoTLS  ProtoID = 0x2
	ProtoSASL ProtoID = 0x3
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL