fake

package
v0.0.0-...-898dac5 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2023 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 frames.Type, channel uint16, f frames.FrameBody) ([]byte, error)

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

func PerformBegin

func PerformBegin(channel, 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(channel uint16, linkHandle uint32, e *encoding.Error) ([]byte, error)

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

func PerformEnd(channel 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(channel 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(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

type AMQPProto struct {
	frames.FrameBody
}

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

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

	// 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 mock network connection that satisfies the net.Conn interface.

func NewNetConn

func NewNetConn(resp func(remoteChannel uint16, fr 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.

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