Documentation ¶
Overview ¶
Package frame provides functionality for manipulating STOMP frames.
Index ¶
- Constants
- Variables
- func ParseHeartBeat(heartBeat string) (time.Duration, time.Duration, error)
- type Frame
- type Header
- func (h *Header) Add(key, value string)
- func (h *Header) AddHeader(header *Header)
- func (h *Header) Clone() *Header
- func (h *Header) Contains(key string) (value string, ok bool)
- func (h *Header) ContentLength() (value int, ok bool, err error)
- func (h *Header) Del(key string)
- func (h *Header) Get(key string) string
- func (h *Header) GetAll(key string) []string
- func (h *Header) GetAt(index int) (key, value string)
- func (h *Header) Len() int
- func (h *Header) Set(key, value string)
- type Reader
- type Writer
Constants ¶
const ( AckAuto = "auto" // Client does not send ACK AckClient = "client" // Client sends ACK/NACK AckClientIndividual = "client-individual" // Client sends ACK/NACK for individual messages )
Valid values for the "ack" header entry.
const ( // Connect commands. CONNECT = "CONNECT" STOMP = "STOMP" CONNECTED = "CONNECTED" // Client commands. SEND = "SEND" SUBSCRIBE = "SUBSCRIBE" UNSUBSCRIBE = "UNSUBSCRIBE" ACK = "ACK" NACK = "NACK" BEGIN = "BEGIN" COMMIT = "COMMIT" ABORT = "ABORT" DISCONNECT = "DISCONNECT" // Server commands. MESSAGE = "MESSAGE" RECEIPT = "RECEIPT" ERROR = "ERROR" )
STOMP frame commands. Used upper case naming convention to avoid clashing with STOMP header names.
const ( ContentLength = "content-length" ContentType = "content-type" Receipt = "receipt" AcceptVersion = "accept-version" Host = "host" Version = "version" Login = "login" Passcode = "passcode" HeartBeat = "heart-beat" Session = "session" Server = "server" Destination = "destination" Id = "id" Ack = "ack" Transaction = "transaction" ReceiptId = "receipt-id" Subscription = "subscription" MessageId = "message-id" Message = "message" )
STOMP header names. Some of the header names have commands with the same name (eg Ack, Message, Receipt). Commands use an upper-case naming convention, header names use pascal-case naming convention.
Variables ¶
var ( ErrInvalidCommand = errors.New("invalid command") ErrInvalidFrameFormat = errors.New("invalid frame format") )
var (
ErrInvalidHeartBeat = errors.New("invalid heart-beat")
)
Functions ¶
func ParseHeartBeat ¶
ParseHeartBeat parses the value of a STOMP heart-beat entry and returns two time durations. Returns an error if the heart-beat value is not in the correct format, or if the time durations are too big to be represented by the time.Duration type.
Types ¶
type Frame ¶
A Frame represents a STOMP frame. A frame consists of a command followed by a collection of header entries, and then an optional body.
type Header ¶
type Header struct {
// contains filtered or unexported fields
}
A Header represents the header part of a STOMP frame. The header in a STOMP frame consists of a list of header entries. Each header entry is a key/value pair of strings.
Normally a STOMP header only has one header entry for a given key, but the STOMP standard does allow for multiple header entries with the same key. In this case, the first header entry contains the value, and any subsequent header entries with the same key are ignored.
Example header containing 6 header entries. Note that the second header entry with the key "comment" would be ignored.
login:scott passcode:tiger host:stompserver accept-version:1.0,1.1,1.2 comment:some comment comment:another comment
func NewHeader ¶
NewHeader creates a new Header and populates it with header entries. This function expects an even number of strings as parameters. The even numbered indices are keys and the odd indices are values. See the example for more information.
func (*Header) Contains ¶
Contains gets the first value associated with the given key, and also returns a bool indicating whether the header entry exists.
If there are no values associated with the key, Get returns "" for the value, and ok is false.
func (*Header) ContentLength ¶
ContentLength returns the value of the "content-length" header entry. If the "content-length" header is missing, then ok is false. If the "content-length" entry is present but is not a valid non-negative integer then err is non-nil.
func (*Header) Get ¶
Get gets the first value associated with the given key. If there are no values associated with the key, Get returns "".
func (*Header) GetAll ¶
GetAll returns all of the values associated with a given key. Normally there is only one header entry per key, but it is permitted to have multiple entries according to the STOMP standard.
func (*Header) GetAt ¶
Returns the header name and value at the specified index in the collection. The index should be in the range 0 <= index < Len(), a panic will occur if it is outside this range.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
The Reader type reads STOMP frames from an underlying io.Reader. The reader is buffered, and the size of the buffer is the maximum size permitted for the STOMP frame command and header section. A STOMP frame is rejected if its command and header section exceed the buffer size.
func NewReaderSize ¶
NewReaderSize creates a Reader with an underlying bufferSize of the specified size.