frames

package
v0.0.0-...-17e524c Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Pseudo-frames, tracking "special" types
	BodyTypeEmptyFrame = "Empty" // a frame without a body. This is commonly used for AMQP keep-alives.
	BodyTypeRawFrame   = "Raw"   // a frame that was fabricated. This is primarily useful when attempting to go outside of the AMQP, with full control over the encoded frame.

	// AMQP frame types
	BodyTypeAttach      = "Attach"
	BodyTypeBegin       = "Begin"
	BodyTypeClose       = "Close"
	BodyTypeDetach      = "Detach"
	BodyTypeDisposition = "Disposition"
	BodyTypeEnd         = "End"
	BodyTypeFlow        = "Flow"
	BodyTypeOpen        = "Open"
	BodyTypeTransfer    = "Transfer"

	// SASL frames
	BodyTypeSASLChallenge  = "SASLChallenge"
	BodyTypeSASLInit       = "SASLInit"
	BodyTypeSASLMechanisms = "SASLMechanisms"
	BodyTypeSASLOutcome    = "SASLOutcome"
	BodyTypeSASLResponse   = "SASLResponse"
)
View Source
const HeaderSize = 8

Variables

This section is empty.

Functions

This section is empty.

Types

type Body

type Body interface {
	Type() BodyType
	GetHandle() *uint32
	// contains filtered or unexported methods
}

frameBody adds some type safety to frame encoding

type BodyType

type BodyType string

type Buffer

type Buffer struct {
	// contains filtered or unexported fields
}

func (*Buffer) Add

func (fb *Buffer) Add(buff []byte)

Add adds connection data. Use [Extract] to extract frames from the added data. NOTE: this call cannot be used concurrently.

func (*Buffer) Extract

func (fb *Buffer) Extract() (PreambleOrFrame, error)

Extract will return any parsed items (AMQP preamble, frame headers or frames) It returns (nil, nil) if there are no longer any items to parse with the buffered data it has remaining.

func (*Buffer) ExtractFrame

func (fb *Buffer) ExtractFrame() (*Frame, error)

ExtractFrame extracts an AMQPFrame, if available. NOTE: this function should only be used when you're certain the underlying stream will not contain an AMQP preamble. It's only safe to use when SASL negotiation has completed. It returns (nil, nil) if there are no longer any items to parse with the buffered data it has remaining.

type ConnReadWriter

type ConnReadWriter struct {
	// contains filtered or unexported fields
}

ConnReadWriter makes it simple to write or read from a stream with frames or AMQP preambles.

func NewConnReadWriter

func NewConnReadWriter(conn io.ReadWriter, options ...ConnReadWriterOption) *ConnReadWriter

func (*ConnReadWriter) Iter

func (*ConnReadWriter) Write

func (fc *ConnReadWriter) Write(data interface{ MarshalAMQP() ([]byte, error) }) error

TODO: remove

func (*ConnReadWriter) WriteBytes

func (fc *ConnReadWriter) WriteBytes(data []byte) error

type ConnReadWriterOption

type ConnReadWriterOption func(fi *ConnReadWriter) error

type EmptyFrame

type EmptyFrame struct{}

func (*EmptyFrame) GetHandle

func (e *EmptyFrame) GetHandle() *uint32

func (*EmptyFrame) Marshal

func (e *EmptyFrame) Marshal(wr *buffer.Buffer) error

func (*EmptyFrame) Type

func (e *EmptyFrame) Type() BodyType

type Frame

type Frame struct {
	// Header is an AMQP frame header. This will be followed with a [ParsedItem] with a [Body].
	Header Header

	// Body is the AMQP frame body.
	Body Body
	// contains filtered or unexported fields
}

func NewRawFrame

func NewRawFrame(rawFrame []byte) *Frame

func (Frame) MarshalAMQP

func (a Frame) MarshalAMQP() ([]byte, error)

MarshalAMQP marshals this frame into the proper format to send on an AMQP connection.

func (*Frame) MarshalJSON

func (fr *Frame) MarshalJSON() ([]byte, error)

func (Frame) MustMarshalAMQP

func (a Frame) MustMarshalAMQP() []byte

MustMarshalAMQP marshals this frame into the proper format to send on an AMQP connection and panic()'s if an error occurs.

func (*Frame) Raw

func (a *Frame) Raw() []byte

so we can conform to the AMQPItem interface.

func (*Frame) UnmarshalJSON

func (fr *Frame) UnmarshalJSON(data []byte) error
type Header struct {
	// size: an unsigned 32-bit integer that MUST contain the total frame size of the frame header,
	// extended header, and frame body. The frame is malformed if the size is less than the size of
	// the frame header (8 bytes).
	Size uint32
	// doff: gives the position of the body within the frame. The value of the data offset is an
	// unsigned, 8-bit integer specifying a count of 4-byte words. Due to the mandatory 8-byte
	// frame header, the frame is malformed if the value is less than 2.
	DataOffset uint8
	FrameType  uint8
	Channel    uint16

	Raw []byte
}

Header in a structure appropriate for use with binary.Read()

func ParseHeader

func ParseHeader(r *buffer.Buffer) (Header, error)

ParseHeader reads the header from r and returns the result.

No validation is done.

type PerformAttach

type PerformAttach struct {
	// the name of the link
	//
	// This name uniquely identifies the link from the container of the source
	// to the container of the target node, e.g., if the container of the source
	// node is A, and the container of the target node is B, the link MAY be
	// globally identified by the (ordered) tuple (A,B,<name>).
	Name string // required

	// the handle for the link while attached
	//
	// The numeric handle assigned by the the peer as a shorthand to refer to the
	// link in all performatives that reference the link until the it is detached.
	//
	// The handle MUST NOT be used for other open links. An attempt to attach using
	// a handle which is already associated with a link MUST be responded to with
	// an immediate close carrying a handle-in-use session-error.
	//
	// To make it easier to monitor AMQP link attach frames, it is RECOMMENDED that
	// implementations always assign the lowest available handle to this field.
	//
	// The two endpoints MAY potentially use different handles to refer to the same link.
	// Link handles MAY be reused once a link is closed for both send and receive.
	Handle uint32 // required

	// role of the link endpoint
	//
	// The role being played by the peer, i.e., whether the peer is the sender or the
	// receiver of messages on the link.
	Role encoding.Role

	// settlement policy for the sender
	//
	// The delivery settlement policy for the sender. When set at the receiver this
	// indicates the desired value for the settlement mode at the sender. When set
	// at the sender this indicates the actual settlement mode in use. The sender
	// SHOULD respect the receiver's desired settlement mode if the receiver initiates
	// the attach exchange and the sender supports the desired mode.
	//
	// 0: unsettled - The sender will send all deliveries initially unsettled to the receiver.
	// 1: settled - The sender will send all deliveries settled to the receiver.
	// 2: mixed - The sender MAY send a mixture of settled and unsettled deliveries to the receiver.
	SenderSettleMode *encoding.SenderSettleMode

	// the settlement policy of the receiver
	//
	// The delivery settlement policy for the receiver. When set at the sender this
	// indicates the desired value for the settlement mode at the receiver.
	// When set at the receiver this indicates the actual settlement mode in use.
	// The receiver SHOULD respect the sender's desired settlement mode if the sender
	// initiates the attach exchange and the receiver supports the desired mode.
	//
	// 0: first - The receiver will spontaneously settle all incoming transfers.
	// 1: second - The receiver will only settle after sending the disposition to
	//             the sender and receiving a disposition indicating settlement of
	//             the delivery from the sender.
	ReceiverSettleMode *encoding.ReceiverSettleMode

	// the source for messages
	//
	// If no source is specified on an outgoing link, then there is no source currently
	// attached to the link. A link with no source will never produce outgoing messages.
	Source *Source

	// the target for messages
	//
	// If no target is specified on an incoming link, then there is no target currently
	// attached to the link. A link with no target will never permit incoming messages.
	Target *Target

	// unsettled delivery state
	//
	// This is used to indicate any unsettled delivery states when a suspended link is
	// resumed. The map is keyed by delivery-tag with values indicating the delivery state.
	// The local and remote delivery states for a given delivery-tag MUST be compared to
	// resolve any in-doubt deliveries. If necessary, deliveries MAY be resent, or resumed
	// based on the outcome of this comparison. See subsection 2.6.13.
	//
	// If the local unsettled map is too large to be encoded within a frame of the agreed
	// maximum frame size then the session MAY be ended with the frame-size-too-small error.
	// The endpoint SHOULD make use of the ability to send an incomplete unsettled map
	// (see below) to avoid sending an error.
	//
	// The unsettled map MUST NOT contain null valued keys.
	//
	// When reattaching (as opposed to resuming), the unsettled map MUST be null.
	Unsettled encoding.Unsettled

	// If set to true this field indicates that the unsettled map provided is not complete.
	// When the map is incomplete the recipient of the map cannot take the absence of a
	// delivery tag from the map as evidence of settlement. On receipt of an incomplete
	// unsettled map a sending endpoint MUST NOT send any new deliveries (i.e. deliveries
	// where resume is not set to true) to its partner (and a receiving endpoint which sent
	// an incomplete unsettled map MUST detach with an error on receiving a transfer which
	// does not have the resume flag set to true).
	//
	// Note that if this flag is set to true then the endpoints MUST detach and reattach at
	// least once in order to send new deliveries. This flag can be useful when there are
	// too many entries in the unsettled map to fit within a single frame. An endpoint can
	// attach, resume, settle, and detach until enough unsettled state has been cleared for
	// an attach where this flag is set to false.
	IncompleteUnsettled bool // default: false

	// the sender's initial value for delivery-count
	//
	// This MUST NOT be null if role is sender, and it is ignored if the role is receiver.
	InitialDeliveryCount uint32 // sequence number

	// the maximum message size supported by the link endpoint
	//
	// This field indicates the maximum message size supported by the link endpoint.
	// Any attempt to deliver a message larger than this results in a message-size-exceeded
	// link-error. If this field is zero or unset, there is no maximum size imposed by the
	// link endpoint.
	MaxMessageSize uint64

	// the extension capabilities the sender supports
	// http://www.amqpfaultinjector.org/specification/1.0/link-capabilities
	OfferedCapabilities encoding.MultiSymbol

	// the extension capabilities the sender can use if the receiver supports them
	//
	// The sender MUST NOT attempt to use any capability other than those it
	// has declared in desired-capabilities field.
	DesiredCapabilities encoding.MultiSymbol

	// link properties
	// http://www.amqpfaultinjector.org/specification/1.0/link-properties
	Properties map[encoding.Symbol]any
}

<type name="attach" class="composite" source="list" provides="frame">

<descriptor name="amqp:attach:list" code="0x00000000:0x00000012"/>
<field name="name" type="string" mandatory="true"/>
<field name="handle" type="handle" mandatory="true"/>
<field name="role" type="role" mandatory="true"/>
<field name="snd-settle-mode" type="sender-settle-mode" default="mixed"/>
<field name="rcv-settle-mode" type="receiver-settle-mode" default="first"/>
<field name="source" type="*" requires="source"/>
<field name="target" type="*" requires="target"/>
<field name="unsettled" type="map"/>
<field name="incomplete-unsettled" type="boolean" default="false"/>
<field name="initial-delivery-count" type="sequence-no"/>
<field name="max-message-size" type="ulong"/>
<field name="offered-capabilities" type="symbol" multiple="true"/>
<field name="desired-capabilities" type="symbol" multiple="true"/>
<field name="properties" type="fields"/>

</type>

func (*PerformAttach) Address

func (a *PerformAttach) Address(out bool) (address string)

Entity returns the underlying target or source for this ATTACH frame.

func (*PerformAttach) GetHandle

func (a *PerformAttach) GetHandle() *uint32

func (*PerformAttach) Marshal

func (a *PerformAttach) Marshal(wr *buffer.Buffer) error

func (PerformAttach) String

func (a PerformAttach) String() string

func (*PerformAttach) Type

func (a *PerformAttach) Type() BodyType

func (*PerformAttach) Unmarshal

func (a *PerformAttach) Unmarshal(r *buffer.Buffer) error

type PerformBegin

type PerformBegin struct {
	// the remote channel for this session
	// If a session is locally initiated, the remote-channel MUST NOT be set.
	// When an endpoint responds to a remotely initiated session, the remote-channel
	// MUST be set to the channel on which the remote session sent the begin.
	RemoteChannel *uint16

	// the transfer-id of the first transfer id the sender will send
	NextOutgoingID uint32 // required, sequence number http://www.ietf.org/rfc/rfc1982.txt

	// the initial incoming-window of the sender
	IncomingWindow uint32 // required

	// the initial outgoing-window of the sender
	OutgoingWindow uint32 // required

	// the maximum handle value that can be used on the session
	// The handle-max value is the highest handle value that can be
	// used on the session. A peer MUST NOT attempt to attach a link
	// using a handle value outside the range that its partner can handle.
	// A peer that receives a handle outside the supported range MUST
	// close the connection with the framing-error error-code.
	HandleMax uint32 // default 4294967295

	// the extension capabilities the sender supports
	// http://www.amqpfaultinjector.org/specification/1.0/session-capabilities
	OfferedCapabilities encoding.MultiSymbol

	// the extension capabilities the sender can use if the receiver supports them
	// The sender MUST NOT attempt to use any capability other than those it
	// has declared in desired-capabilities field.
	DesiredCapabilities encoding.MultiSymbol

	// session properties
	// http://www.amqpfaultinjector.org/specification/1.0/session-properties
	Properties map[encoding.Symbol]any
}

<type name="begin" class="composite" source="list" provides="frame">

<descriptor name="amqp:begin:list" code="0x00000000:0x00000011"/>
<field name="remote-channel" type="ushort"/>
<field name="next-outgoing-id" type="transfer-number" mandatory="true"/>
<field name="incoming-window" type="uint" mandatory="true"/>
<field name="outgoing-window" type="uint" mandatory="true"/>
<field name="handle-max" type="handle" default="4294967295"/>
<field name="offered-capabilities" type="symbol" multiple="true"/>
<field name="desired-capabilities" type="symbol" multiple="true"/>
<field name="properties" type="fields"/>

</type>

func (*PerformBegin) GetHandle

func (b *PerformBegin) GetHandle() *uint32

func (*PerformBegin) Marshal

func (b *PerformBegin) Marshal(wr *buffer.Buffer) error

func (*PerformBegin) String

func (b *PerformBegin) String() string

func (*PerformBegin) Type

func (b *PerformBegin) Type() BodyType

func (*PerformBegin) Unmarshal

func (b *PerformBegin) Unmarshal(r *buffer.Buffer) error

type PerformClose

type PerformClose struct {
	// error causing the close
	//
	// If set, this field indicates that the session is being closed due to an error
	// condition. The value of the field SHOULD contain details on the cause of the error.
	Error *encoding.Error
}

<type name="close" class="composite" source="list" provides="frame">

<descriptor name="amqp:close:list" code="0x00000000:0x00000018"/>
<field name="error" type="error"/>

</type>

func (*PerformClose) GetHandle

func (c *PerformClose) GetHandle() *uint32

func (*PerformClose) Marshal

func (c *PerformClose) Marshal(wr *buffer.Buffer) error

func (*PerformClose) String

func (c *PerformClose) String() string

func (*PerformClose) Type

func (c *PerformClose) Type() BodyType

func (*PerformClose) Unmarshal

func (c *PerformClose) Unmarshal(r *buffer.Buffer) error

type PerformDetach

type PerformDetach struct {
	// the local handle of the link to be detached
	Handle uint32 // required

	// if true then the sender has closed the link
	Closed bool `json:",omitempty"`

	// error causing the detach
	//
	// If set, this field indicates that the link is being detached due to an error
	// condition. The value of the field SHOULD contain details on the cause of the error.
	Error *encoding.Error `json:",omitempty"`
}

<type name="detach" class="composite" source="list" provides="frame">

<descriptor name="amqp:detach:list" code="0x00000000:0x00000016"/>
<field name="handle" type="handle" mandatory="true"/>
<field name="closed" type="boolean" default="false"/>
<field name="error" type="error"/>

</type>

func (*PerformDetach) GetHandle

func (d *PerformDetach) GetHandle() *uint32

func (*PerformDetach) Marshal

func (d *PerformDetach) Marshal(wr *buffer.Buffer) error

func (PerformDetach) String

func (d PerformDetach) String() string

func (*PerformDetach) Type

func (d *PerformDetach) Type() BodyType

func (*PerformDetach) Unmarshal

func (d *PerformDetach) Unmarshal(r *buffer.Buffer) error

type PerformDisposition

type PerformDisposition struct {
	// directionality of disposition
	//
	// The role identifies whether the disposition frame contains information about
	// sending link endpoints or receiving link endpoints.
	Role encoding.Role

	// lower bound of deliveries
	//
	// Identifies the lower bound of delivery-ids for the deliveries in this set.
	First uint32 // required, sequence number

	// upper bound of deliveries
	//
	// Identifies the upper bound of delivery-ids for the deliveries in this set.
	// If not set, this is taken to be the same as first.
	Last *uint32 // sequence number

	// indicates deliveries are settled
	//
	// If true, indicates that the referenced deliveries are considered settled by
	// the issuing endpoint.
	Settled bool

	// indicates state of deliveries
	//
	// Communicates the state of all the deliveries referenced by this disposition.
	State encoding.DeliveryState

	// batchable hint
	//
	// If true, then the issuer is hinting that there is no need for the peer to
	// urgently communicate the impact of the updated delivery states. This hint
	// MAY be used to artificially increase the amount of batching an implementation
	// uses when communicating delivery states, and thereby save bandwidth.
	Batchable bool
}

<type name="disposition" class="composite" source="list" provides="frame">

<descriptor name="amqp:disposition:list" code="0x00000000:0x00000015"/>
<field name="role" type="role" mandatory="true"/>
<field name="first" type="delivery-number" mandatory="true"/>
<field name="last" type="delivery-number"/>
<field name="settled" type="boolean" default="false"/>
<field name="state" type="*" requires="delivery-state"/>
<field name="batchable" type="boolean" default="false"/>

</type>

func (*PerformDisposition) GetHandle

func (d *PerformDisposition) GetHandle() *uint32

func (*PerformDisposition) Marshal

func (d *PerformDisposition) Marshal(wr *buffer.Buffer) error

func (PerformDisposition) String

func (d PerformDisposition) String() string

func (*PerformDisposition) Type

func (d *PerformDisposition) Type() BodyType

func (*PerformDisposition) Unmarshal

func (d *PerformDisposition) Unmarshal(r *buffer.Buffer) error

type PerformEnd

type PerformEnd struct {
	// error causing the end
	//
	// If set, this field indicates that the session is being ended due to an error
	// condition. The value of the field SHOULD contain details on the cause of the error.
	Error *encoding.Error
}

<type name="end" class="composite" source="list" provides="frame">

<descriptor name="amqp:end:list" code="0x00000000:0x00000017"/>
<field name="error" type="error"/>

</type>

func (*PerformEnd) GetHandle

func (e *PerformEnd) GetHandle() *uint32

func (*PerformEnd) Marshal

func (e *PerformEnd) Marshal(wr *buffer.Buffer) error

func (PerformEnd) String

func (d PerformEnd) String() string

func (*PerformEnd) Type

func (e *PerformEnd) Type() BodyType

func (*PerformEnd) Unmarshal

func (e *PerformEnd) Unmarshal(r *buffer.Buffer) error

type PerformFlow

type PerformFlow struct {
	// Identifies the expected transfer-id of the next incoming transfer frame.
	// This value MUST be set if the peer has received the begin frame for the
	// session, and MUST NOT be set if it has not. See subsection 2.5.6 for more details.
	NextIncomingID *uint32 // sequence number

	// Defines the maximum number of incoming transfer frames that the endpoint
	// can currently receive. See subsection 2.5.6 for more details.
	IncomingWindow uint32 // required

	// The transfer-id that will be assigned to the next outgoing transfer frame.
	// See subsection 2.5.6 for more details.
	NextOutgoingID uint32 // sequence number

	// Defines the maximum number of outgoing transfer frames that the endpoint
	// could potentially currently send, if it was not constrained by restrictions
	// imposed by its peer's incoming-window. See subsection 2.5.6 for more details.
	OutgoingWindow uint32

	// If set, indicates that the flow frame carries flow state information for the local
	// link endpoint associated with the given handle. If not set, the flow frame is
	// carrying only information pertaining to the session endpoint.
	//
	// If set to a handle that is not currently associated with an attached link,
	// the recipient MUST respond by ending the session with an unattached-handle
	// session error.
	Handle *uint32

	// The delivery-count is initialized by the sender when a link endpoint is created,
	// and is incremented whenever a message is sent. Only the sender MAY independently
	// modify this field. The receiver's value is calculated based on the last known
	// value from the sender and any subsequent messages received on the link. Note that,
	// despite its name, the delivery-count is not a count but a sequence number
	// initialized at an arbitrary point by the sender.
	//
	// When the handle field is not set, this field MUST NOT be set.
	//
	// When the handle identifies that the flow state is being sent from the sender link
	// endpoint to receiver link endpoint this field MUST be set to the current
	// delivery-count of the link endpoint.
	//
	// When the flow state is being sent from the receiver endpoint to the sender endpoint
	// this field MUST be set to the last known value of the corresponding sending endpoint.
	// In the event that the receiving link endpoint has not yet seen the initial attach
	// frame from the sender this field MUST NOT be set.
	DeliveryCount *uint32 // sequence number

	// the current maximum number of messages that can be received
	//
	// The current maximum number of messages that can be handled at the receiver endpoint
	// of the link. Only the receiver endpoint can independently set this value. The sender
	// endpoint sets this to the last known value seen from the receiver.
	// See subsection 2.6.7 for more details.
	//
	// When the handle field is not set, this field MUST NOT be set.
	LinkCredit *uint32

	// the number of available messages
	//
	// The number of messages awaiting credit at the link sender endpoint. Only the sender
	// can independently set this value. The receiver sets this to the last known value seen
	// from the sender. See subsection 2.6.7 for more details.
	//
	// When the handle field is not set, this field MUST NOT be set.
	Available *uint32

	// indicates drain mode
	//
	// When flow state is sent from the sender to the receiver, this field contains the
	// actual drain mode of the sender. When flow state is sent from the receiver to the
	// sender, this field contains the desired drain mode of the receiver.
	// See subsection 2.6.7 for more details.
	//
	// When the handle field is not set, this field MUST NOT be set.
	Drain bool

	// request state from partner
	//
	// If set to true then the receiver SHOULD send its state at the earliest convenient
	// opportunity.
	//
	// If set to true, and the handle field is not set, then the sender only requires
	// session endpoint state to be echoed, however, the receiver MAY fulfil this requirement
	// by sending a flow performative carrying link-specific state (since any such flow also
	// carries session state).
	//
	// If a sender makes multiple requests for the same state before the receiver can reply,
	// the receiver MAY send only one flow in return.
	//
	// Note that if a peer responds to echo requests with flows which themselves have the
	// echo field set to true, an infinite loop could result if its partner adopts the same
	// policy (therefore such a policy SHOULD be avoided).
	Echo bool

	// link state properties
	// http://www.amqpfaultinjector.org/specification/1.0/link-state-properties
	Properties map[encoding.Symbol]any
}

<type name="flow" class="composite" source="list" provides="frame">

<descriptor name="amqp:flow:list" code="0x00000000:0x00000013"/>
<field name="next-incoming-id" type="transfer-number"/>
<field name="incoming-window" type="uint" mandatory="true"/>
<field name="next-outgoing-id" type="transfer-number" mandatory="true"/>
<field name="outgoing-window" type="uint" mandatory="true"/>
<field name="handle" type="handle"/>
<field name="delivery-count" type="sequence-no"/>
<field name="link-credit" type="uint"/>
<field name="available" type="uint"/>
<field name="drain" type="boolean" default="false"/>
<field name="echo" type="boolean" default="false"/>
<field name="properties" type="fields"/>

</type>

func (*PerformFlow) GetHandle

func (f *PerformFlow) GetHandle() *uint32

func (*PerformFlow) Marshal

func (f *PerformFlow) Marshal(wr *buffer.Buffer) error

func (*PerformFlow) String

func (f *PerformFlow) String() string

func (*PerformFlow) Type

func (f *PerformFlow) Type() BodyType

func (*PerformFlow) Unmarshal

func (f *PerformFlow) Unmarshal(r *buffer.Buffer) error

type PerformOpen

type PerformOpen struct {
	ContainerID         string // required
	Hostname            string
	MaxFrameSize        uint32        // default: 4294967295
	ChannelMax          uint16        // default: 65535
	IdleTimeout         time.Duration // from milliseconds
	OutgoingLocales     encoding.MultiSymbol
	IncomingLocales     encoding.MultiSymbol
	OfferedCapabilities encoding.MultiSymbol
	DesiredCapabilities encoding.MultiSymbol
	Properties          map[encoding.Symbol]any
}

func (*PerformOpen) GetHandle

func (o *PerformOpen) GetHandle() *uint32

func (*PerformOpen) Marshal

func (o *PerformOpen) Marshal(wr *buffer.Buffer) error

func (*PerformOpen) String

func (o *PerformOpen) String() string

func (*PerformOpen) Type

func (o *PerformOpen) Type() BodyType

func (*PerformOpen) Unmarshal

func (o *PerformOpen) Unmarshal(r *buffer.Buffer) error

type PerformTransfer

type PerformTransfer struct {
	// Specifies the link on which the message is transferred.
	Handle uint32 // required

	// The delivery-id MUST be supplied on the first transfer of a multi-transfer
	// delivery. On continuation transfers the delivery-id MAY be omitted. It is
	// an error if the delivery-id on a continuation transfer differs from the
	// delivery-id on the first transfer of a delivery.
	DeliveryID *uint32 // sequence number

	// Uniquely identifies the delivery attempt for a given message on this link.
	// This field MUST be specified for the first transfer of a multi-transfer
	// message and can only be omitted for continuation transfers. It is an error
	// if the delivery-tag on a continuation transfer differs from the delivery-tag
	// on the first transfer of a delivery.
	DeliveryTag []byte // up to 32 bytes

	// This field MUST be specified for the first transfer of a multi-transfer message
	// and can only be omitted for continuation transfers. It is an error if the
	// message-format on a continuation transfer differs from the message-format on
	// the first transfer of a delivery.
	//
	// The upper three octets of a message format code identify a particular message
	// format. The lowest octet indicates the version of said message format. Any given
	// version of a format is forwards compatible with all higher versions.
	MessageFormat *uint32

	// If not set on the first (or only) transfer for a (multi-transfer) delivery,
	// then the settled flag MUST be interpreted as being false. For subsequent
	// transfers in a multi-transfer delivery if the settled flag is left unset then
	// it MUST be interpreted as true if and only if the value of the settled flag on
	// any of the preceding transfers was true; if no preceding transfer was sent with
	// settled being true then the value when unset MUST be taken as false.
	//
	// If the negotiated value for snd-settle-mode at attachment is settled, then this
	// field MUST be true on at least one transfer frame for a delivery (i.e., the
	// delivery MUST be settled at the sender at the point the delivery has been
	// completely transferred).
	//
	// If the negotiated value for snd-settle-mode at attachment is unsettled, then this
	// field MUST be false (or unset) on every transfer frame for a delivery (unless the
	// delivery is aborted).
	Settled bool

	// indicates that the message has more content
	//
	// Note that if both the more and aborted fields are set to true, the aborted flag
	// takes precedence. That is, a receiver SHOULD ignore the value of the more field
	// if the transfer is marked as aborted. A sender SHOULD NOT set the more flag to
	// true if it also sets the aborted flag to true.
	More bool

	// If first, this indicates that the receiver MUST settle the delivery once it has
	// arrived without waiting for the sender to settle first.
	//
	// If second, this indicates that the receiver MUST NOT settle until sending its
	// disposition to the sender and receiving a settled disposition from the sender.
	//
	// If not set, this value is defaulted to the value negotiated on link attach.
	//
	// If the negotiated link value is first, then it is illegal to set this field
	// to second.
	//
	// If the message is being sent settled by the sender, the value of this field
	// is ignored.
	//
	// The (implicit or explicit) value of this field does not form part of the
	// transfer state, and is not retained if a link is suspended and subsequently resumed.
	//
	// 0: first - The receiver will spontaneously settle all incoming transfers.
	// 1: second - The receiver will only settle after sending the disposition to
	//             the sender and receiving a disposition indicating settlement of
	//             the delivery from the sender.
	ReceiverSettleMode *encoding.ReceiverSettleMode

	// the state of the delivery at the sender
	//
	// When set this informs the receiver of the state of the delivery at the sender.
	// This is particularly useful when transfers of unsettled deliveries are resumed
	// after resuming a link. Setting the state on the transfer can be thought of as
	// being equivalent to sending a disposition immediately before the transfer
	// performative, i.e., it is the state of the delivery (not the transfer) that
	// existed at the point the frame was sent.
	//
	// Note that if the transfer performative (or an earlier disposition performative
	// referring to the delivery) indicates that the delivery has attained a terminal
	// state, then no future transfer or disposition sent by the sender can alter that
	// terminal state.
	State encoding.DeliveryState

	// indicates a resumed delivery
	//
	// If true, the resume flag indicates that the transfer is being used to reassociate
	// an unsettled delivery from a dissociated link endpoint. See subsection 2.6.13
	// for more details.
	//
	// The receiver MUST ignore resumed deliveries that are not in its local unsettled map.
	// The sender MUST NOT send resumed transfers for deliveries not in its local
	// unsettled map.
	//
	// If a resumed delivery spans more than one transfer performative, then the resume
	// flag MUST be set to true on the first transfer of the resumed delivery. For
	// subsequent transfers for the same delivery the resume flag MAY be set to true,
	// or MAY be omitted.
	//
	// In the case where the exchange of unsettled maps makes clear that all message
	// data has been successfully transferred to the receiver, and that only the final
	// state (and potentially settlement) at the sender needs to be conveyed, then a
	// resumed delivery MAY carry no payload and instead act solely as a vehicle for
	// carrying the terminal state of the delivery at the sender.
	Resume bool

	// indicates that the message is aborted
	//
	// Aborted messages SHOULD be discarded by the recipient (any payload within the
	// frame carrying the performative MUST be ignored). An aborted message is
	// implicitly settled.
	Aborted bool

	// batchable hint
	//
	// If true, then the issuer is hinting that there is no need for the peer to urgently
	// communicate updated delivery state. This hint MAY be used to artificially increase
	// the amount of batching an implementation uses when communicating delivery states,
	// and thereby save bandwidth.
	//
	// If the message being delivered is too large to fit within a single frame, then the
	// setting of batchable to true on any of the transfer performatives for the delivery
	// is equivalent to setting batchable to true for all the transfer performatives for
	// the delivery.
	//
	// The batchable value does not form part of the transfer state, and is not retained
	// if a link is suspended and subsequently resumed.
	Batchable bool

	Payload []byte

	// optional channel to indicate to sender that transfer has completed
	//
	// Settled=true: closed when the transferred on network.
	// Settled=false: closed when the receiver has confirmed settlement.
	Done chan encoding.DeliveryState `json:"-"`
}

<type name="transfer" class="composite" source="list" provides="frame">

<descriptor name="amqp:transfer:list" code="0x00000000:0x00000014"/>
<field name="handle" type="handle" mandatory="true"/>
<field name="delivery-id" type="delivery-number"/>
<field name="delivery-tag" type="delivery-tag"/>
<field name="message-format" type="message-format"/>
<field name="settled" type="boolean"/>
<field name="more" type="boolean" default="false"/>
<field name="rcv-settle-mode" type="receiver-settle-mode"/>
<field name="state" type="*" requires="delivery-state"/>
<field name="resume" type="boolean" default="false"/>
<field name="aborted" type="boolean" default="false"/>
<field name="batchable" type="boolean" default="false"/>

</type>

func (*PerformTransfer) GetHandle

func (t *PerformTransfer) GetHandle() *uint32

func (*PerformTransfer) Marshal

func (t *PerformTransfer) Marshal(wr *buffer.Buffer) error

func (PerformTransfer) String

func (t PerformTransfer) String() string

func (*PerformTransfer) Type

func (t *PerformTransfer) Type() BodyType

func (*PerformTransfer) Unmarshal

func (t *PerformTransfer) Unmarshal(r *buffer.Buffer) error

type Preamble

type Preamble = Raw

type PreambleOrFrame

type PreambleOrFrame interface {

	// Raw is the original raw bytes, and isn't required to change if the underlying
	// parsed entities change.
	Raw() []byte

	MustMarshalAMQP() []byte
	MarshalAMQP() ([]byte, error)
	// contains filtered or unexported methods
}

PreambleOrFrame represents parseable items when extracting data from an AMQP stream. Includes *Frame and Preamble.

type Raw

type Raw []byte

func (Raw) MarshalAMQP

func (a Raw) MarshalAMQP() ([]byte, error)

func (Raw) MustMarshalAMQP

func (a Raw) MustMarshalAMQP() []byte

func (Raw) Raw

func (a Raw) Raw() []byte

type RawFrame

type RawFrame struct{}

func (*RawFrame) GetHandle

func (r *RawFrame) GetHandle() *uint32

func (*RawFrame) Marshal

func (r *RawFrame) Marshal(wr *buffer.Buffer) error

func (*RawFrame) Type

func (r *RawFrame) Type() BodyType

type SASLChallenge

type SASLChallenge struct {
	Challenge []byte
}

func (*SASLChallenge) GetHandle

func (sc *SASLChallenge) GetHandle() *uint32

func (*SASLChallenge) Marshal

func (sc *SASLChallenge) Marshal(wr *buffer.Buffer) error

func (*SASLChallenge) String

func (sc *SASLChallenge) String() string

func (*SASLChallenge) Type

func (sc *SASLChallenge) Type() BodyType

func (*SASLChallenge) Unmarshal

func (sc *SASLChallenge) Unmarshal(r *buffer.Buffer) error

type SASLInit

type SASLInit struct {
	Mechanism       encoding.Symbol
	InitialResponse []byte
	Hostname        string
}

func (*SASLInit) GetHandle

func (si *SASLInit) GetHandle() *uint32

func (*SASLInit) Marshal

func (si *SASLInit) Marshal(wr *buffer.Buffer) error

func (*SASLInit) String

func (si *SASLInit) String() string

func (*SASLInit) Type

func (si *SASLInit) Type() BodyType

func (*SASLInit) Unmarshal

func (si *SASLInit) Unmarshal(r *buffer.Buffer) error

type SASLMechanisms

type SASLMechanisms struct {
	Mechanisms encoding.MultiSymbol
}

func (*SASLMechanisms) GetHandle

func (sm *SASLMechanisms) GetHandle() *uint32

func (*SASLMechanisms) Marshal

func (sm *SASLMechanisms) Marshal(wr *buffer.Buffer) error

func (*SASLMechanisms) String

func (sm *SASLMechanisms) String() string

func (*SASLMechanisms) Type

func (sm *SASLMechanisms) Type() BodyType

func (*SASLMechanisms) Unmarshal

func (sm *SASLMechanisms) Unmarshal(r *buffer.Buffer) error

type SASLOutcome

type SASLOutcome struct {
	Code           encoding.SASLCode
	AdditionalData []byte
}

func (*SASLOutcome) GetHandle

func (so *SASLOutcome) GetHandle() *uint32

func (*SASLOutcome) Marshal

func (so *SASLOutcome) Marshal(wr *buffer.Buffer) error

func (*SASLOutcome) String

func (so *SASLOutcome) String() string

func (*SASLOutcome) Type

func (so *SASLOutcome) Type() BodyType

func (*SASLOutcome) Unmarshal

func (so *SASLOutcome) Unmarshal(r *buffer.Buffer) error

type SASLResponse

type SASLResponse struct {
	Response []byte
}

func (*SASLResponse) GetHandle

func (sr *SASLResponse) GetHandle() *uint32

func (*SASLResponse) Marshal

func (sr *SASLResponse) Marshal(wr *buffer.Buffer) error

func (*SASLResponse) String

func (sr *SASLResponse) String() string

func (*SASLResponse) Type

func (sr *SASLResponse) Type() BodyType

func (*SASLResponse) Unmarshal

func (sr *SASLResponse) Unmarshal(r *buffer.Buffer) error

type Source

type Source struct {
	// the address of the source
	//
	// The address of the source MUST NOT be set when sent on a attach frame sent by
	// the receiving link endpoint where the dynamic flag is set to true (that is where
	// the receiver is requesting the sender to create an addressable node).
	//
	// The address of the source MUST be set when sent on a attach frame sent by the
	// sending link endpoint where the dynamic flag is set to true (that is where the
	// sender has created an addressable node at the request of the receiver and is now
	// communicating the address of that created node). The generated name of the address
	// SHOULD include the link name and the container-id of the remote container to allow
	// for ease of identification.
	Address string

	// indicates the durability of the terminus
	//
	// Indicates what state of the terminus will be retained durably: the state of durable
	// messages, only existence and configuration of the terminus, or no state at all.
	//
	// 0: none
	// 1: configuration
	// 2: unsettled-state
	Durable encoding.Durability

	// the expiry policy of the source
	//
	// link-detach: The expiry timer starts when terminus is detached.
	// session-end: The expiry timer starts when the most recently associated session is
	//              ended.
	// connection-close: The expiry timer starts when most recently associated connection
	//                   is closed.
	// never: The terminus never expires.
	ExpiryPolicy encoding.ExpiryPolicy

	// duration that an expiring source will be retained
	//
	// The source starts expiring as indicated by the expiry-policy.
	Timeout uint32 // seconds

	// request dynamic creation of a remote node
	//
	// When set to true by the receiving link endpoint, this field constitutes a request
	// for the sending peer to dynamically create a node at the source. In this case the
	// address field MUST NOT be set.
	//
	// When set to true by the sending link endpoint this field indicates creation of a
	// dynamically created node. In this case the address field will contain the address
	// of the created node. The generated address SHOULD include the link name and other
	// available information on the initiator of the request (such as the remote
	// container-id) in some recognizable form for ease of traceability.
	Dynamic bool

	// properties of the dynamically created node
	//
	// If the dynamic field is not set to true this field MUST be left unset.
	//
	// When set by the receiving link endpoint, this field contains the desired
	// properties of the node the receiver wishes to be created. When set by the
	// sending link endpoint this field contains the actual properties of the
	// dynamically created node. See subsection 3.5.9 for standard node properties.
	// http://www.amqpfaultinjector.org/specification/1.0/node-properties
	//
	// lifetime-policy: The lifetime of a dynamically generated node.
	//					Definitionally, the lifetime will never be less than the lifetime
	//					of the link which caused its creation, however it is possible to
	//					extend the lifetime of dynamically created node using a lifetime
	//					policy. The value of this entry MUST be of a type which provides
	//					the lifetime-policy archetype. The following standard
	//					lifetime-policies are defined below: delete-on-close,
	//					delete-on-no-links, delete-on-no-messages or
	//					delete-on-no-links-or-messages.
	// supported-dist-modes: The distribution modes that the node supports.
	//					The value of this entry MUST be one or more symbols which are valid
	//					distribution-modes. That is, the value MUST be of the same type as
	//					would be valid in a field defined with the following attributes:
	//						type="symbol" multiple="true" requires="distribution-mode"
	DynamicNodeProperties map[encoding.Symbol]any // TODO: implement custom type with validation

	// the distribution mode of the link
	//
	// This field MUST be set by the sending end of the link if the endpoint supports more
	// than one distribution-mode. This field MAY be set by the receiving end of the link
	// to indicate a preference when a node supports multiple distribution modes.
	DistributionMode encoding.Symbol

	// a set of predicates to filter the messages admitted onto the link
	//
	// The receiving endpoint sets its desired filter, the sending endpoint sets the filter
	// actually in place (including any filters defaulted at the node). The receiving
	// endpoint MUST check that the filter in place meets its needs and take responsibility
	// for detaching if it does not.
	Filter encoding.Filter

	// default outcome for unsettled transfers
	//
	// Indicates the outcome to be used for transfers that have not reached a terminal
	// state at the receiver when the transfer is settled, including when the source
	// is destroyed. The value MUST be a valid outcome (e.g., released or rejected).
	DefaultOutcome any

	// descriptors for the outcomes that can be chosen on this link
	//
	// The values in this field are the symbolic descriptors of the outcomes that can
	// be chosen on this link. This field MAY be empty, indicating that the default-outcome
	// will be assumed for all message transfers (if the default-outcome is not set, and no
	// outcomes are provided, then the accepted outcome MUST be supported by the source).
	//
	// When present, the values MUST be a symbolic descriptor of a valid outcome,
	// e.g., "amqp:accepted:list".
	Outcomes encoding.MultiSymbol

	// the extension capabilities the sender supports/desires
	//
	// http://www.amqpfaultinjector.org/specification/1.0/source-capabilities
	Capabilities encoding.MultiSymbol
}

<type name="source" class="composite" source="list" provides="source">

<descriptor name="amqp:source:list" code="0x00000000:0x00000028"/>
<field name="address" type="*" requires="address"/>
<field name="durable" type="terminus-durability" default="none"/>
<field name="expiry-policy" type="terminus-expiry-policy" default="session-end"/>
<field name="timeout" type="seconds" default="0"/>
<field name="dynamic" type="boolean" default="false"/>
<field name="dynamic-node-properties" type="node-properties"/>
<field name="distribution-mode" type="symbol" requires="distribution-mode"/>
<field name="filter" type="filter-set"/>
<field name="default-outcome" type="*" requires="outcome"/>
<field name="outcomes" type="symbol" multiple="true"/>
<field name="capabilities" type="symbol" multiple="true"/>

</type>

func (*Source) Marshal

func (s *Source) Marshal(wr *buffer.Buffer) error

func (Source) String

func (s Source) String() string

func (*Source) Unmarshal

func (s *Source) Unmarshal(r *buffer.Buffer) error

type Target

type Target struct {
	// the address of the target
	//
	// The address of the target MUST NOT be set when sent on a attach frame sent by
	// the sending link endpoint where the dynamic flag is set to true (that is where
	// the sender is requesting the receiver to create an addressable node).
	//
	// The address of the source MUST be set when sent on a attach frame sent by the
	// receiving link endpoint where the dynamic flag is set to true (that is where
	// the receiver has created an addressable node at the request of the sender and
	// is now communicating the address of that created node). The generated name of
	// the address SHOULD include the link name and the container-id of the remote
	// container to allow for ease of identification.
	Address string

	// indicates the durability of the terminus
	//
	// Indicates what state of the terminus will be retained durably: the state of durable
	// messages, only existence and configuration of the terminus, or no state at all.
	//
	// 0: none
	// 1: configuration
	// 2: unsettled-state
	Durable encoding.Durability

	// the expiry policy of the target
	//
	// link-detach: The expiry timer starts when terminus is detached.
	// session-end: The expiry timer starts when the most recently associated session is
	//              ended.
	// connection-close: The expiry timer starts when most recently associated connection
	//                   is closed.
	// never: The terminus never expires.
	ExpiryPolicy encoding.ExpiryPolicy

	// duration that an expiring target will be retained
	//
	// The target starts expiring as indicated by the expiry-policy.
	Timeout uint32 // seconds

	// request dynamic creation of a remote node
	//
	// When set to true by the sending link endpoint, this field constitutes a request
	// for the receiving peer to dynamically create a node at the target. In this case
	// the address field MUST NOT be set.
	//
	// When set to true by the receiving link endpoint this field indicates creation of
	// a dynamically created node. In this case the address field will contain the
	// address of the created node. The generated address SHOULD include the link name
	// and other available information on the initiator of the request (such as the
	// remote container-id) in some recognizable form for ease of traceability.
	Dynamic bool

	// properties of the dynamically created node
	//
	// If the dynamic field is not set to true this field MUST be left unset.
	//
	// When set by the sending link endpoint, this field contains the desired
	// properties of the node the sender wishes to be created. When set by the
	// receiving link endpoint this field contains the actual properties of the
	// dynamically created node. See subsection 3.5.9 for standard node properties.
	// http://www.amqpfaultinjector.org/specification/1.0/node-properties
	//
	// lifetime-policy: The lifetime of a dynamically generated node.
	//					Definitionally, the lifetime will never be less than the lifetime
	//					of the link which caused its creation, however it is possible to
	//					extend the lifetime of dynamically created node using a lifetime
	//					policy. The value of this entry MUST be of a type which provides
	//					the lifetime-policy archetype. The following standard
	//					lifetime-policies are defined below: delete-on-close,
	//					delete-on-no-links, delete-on-no-messages or
	//					delete-on-no-links-or-messages.
	// supported-dist-modes: The distribution modes that the node supports.
	//					The value of this entry MUST be one or more symbols which are valid
	//					distribution-modes. That is, the value MUST be of the same type as
	//					would be valid in a field defined with the following attributes:
	//						type="symbol" multiple="true" requires="distribution-mode"
	DynamicNodeProperties map[encoding.Symbol]any // TODO: implement custom type with validation

	// the extension capabilities the sender supports/desires
	//
	// http://www.amqpfaultinjector.org/specification/1.0/target-capabilities
	Capabilities encoding.MultiSymbol
}

<type name="target" class="composite" source="list" provides="target">

<descriptor name="amqp:target:list" code="0x00000000:0x00000029"/>
<field name="address" type="*" requires="address"/>
<field name="durable" type="terminus-durability" default="none"/>
<field name="expiry-policy" type="terminus-expiry-policy" default="session-end"/>
<field name="timeout" type="seconds" default="0"/>
<field name="dynamic" type="boolean" default="false"/>
<field name="dynamic-node-properties" type="node-properties"/>
<field name="capabilities" type="symbol" multiple="true"/>

</type>

func (*Target) Marshal

func (t *Target) Marshal(wr *buffer.Buffer) error

func (Target) String

func (t Target) String() string

func (*Target) Unmarshal

func (t *Target) Unmarshal(r *buffer.Buffer) error

type Type

type Type uint8

Type contains the values for a frame's type.

const (
	TypeAMQP Type = 0x0
	TypeSASL Type = 0x1
)

func (Type) String

func (t Type) String() string

String implements the fmt.Stringer interface for type Type.

Jump to

Keyboard shortcuts

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