Documentation ¶
Index ¶
- Variables
- func ParseInt(d []byte) (n int)
- func ParseInt64(d []byte) (n int64)
- func Pipe() (Peer, Peer)
- func Rand() []byte
- type Client
- func (c *Client) Ack(id []byte, opts ...MessageOption) error
- func (c *Client) Connect(opts ...MessageOption) error
- func (c *Client) Disconnect() error
- func (c *Client) Done() <-chan error
- func (c *Client) Nack(id []byte, opts ...MessageOption) error
- func (c *Client) NewContext(ctx context.Context, client *Client) context.Context
- func (c *Client) Send(dest string, data []byte, opts ...MessageOption) error
- func (c *Client) SendJSON(dest string, v interface{}, opts ...MessageOption) error
- func (c *Client) Subscribe(dest string, handler Handler, opts ...MessageOption) (id []byte, err error)
- func (c *Client) Unsubscribe(id []byte, opts ...MessageOption) error
- type Handler
- type HandlerFunc
- type Header
- func (h *Header) Add(name, data []byte)
- func (h *Header) Field(name []byte) []byte
- func (h *Header) Get(name []byte) (b []byte)
- func (h *Header) GetBool(name string) bool
- func (h *Header) GetInt(name string) int
- func (h *Header) GetInt64(name string) int64
- func (h *Header) GetString(name string) string
- func (h *Header) Index(i int) (k, v []byte)
- func (h *Header) Len() int
- type Message
- func (m *Message) Apply(opts ...MessageOption)
- func (m *Message) Bytes() []byte
- func (m *Message) Context() context.Context
- func (m *Message) Copy() *Message
- func (m *Message) Parse(b []byte) error
- func (m *Message) Release()
- func (m *Message) Reset()
- func (m *Message) String() string
- func (m *Message) Unmarshal(v interface{}) error
- func (m *Message) WithContext(ctx context.Context) *Message
- type MessageOption
- func WithAck(ack string) MessageOption
- func WithCredentials(username, password string) MessageOption
- func WithExpires(exp int64) MessageOption
- func WithHeader(key, value string) MessageOption
- func WithHeaders(headers map[string]string) MessageOption
- func WithPersistence() MessageOption
- func WithPrefetch(prefetch int) MessageOption
- func WithReceipt() MessageOption
- func WithRetain(retain string) MessageOption
- func WithSelector(selector string) MessageOption
- type Peer
Constants ¶
This section is empty.
Variables ¶
var ( MethodStomp = []byte("STOMP") MethodConnect = []byte("CONNECT") MethodConnected = []byte("CONNECTED") MethodSend = []byte("SEND") MethodSubscribe = []byte("SUBSCRIBE") MethodUnsubscribe = []byte("UNSUBSCRIBE") MethodAck = []byte("ACK") MethodNack = []byte("NACK") MethodDisconnect = []byte("DISCONNECT") MethodMessage = []byte("MESSAGE") MethodRecipet = []byte("RECEIPT") MethodError = []byte("ERROR") MethodPing = []byte("PING") )
STOMP protocol methods.
var ( HeaderAccept = []byte("accept-version") HeaderAck = []byte("ack") HeaderExpires = []byte("expires") HeaderDest = []byte("destination") HeaderHost = []byte("host") HeaderLogin = []byte("login") HeaderPass = []byte("passcode") HeaderID = []byte("id") HeaderMessageID = []byte("message-id") HeaderPersist = []byte("persist") HeaderPrefetch = []byte("prefetch-count") HeaderReceipt = []byte("receipt") HeaderReceiptID = []byte("receipt-id") HeaderRetain = []byte("retain") HeaderSelector = []byte("selector") HeaderServer = []byte("server") HeaderSession = []byte("session") HeaderSubscription = []byte("subscription") HeaderVersion = []byte("version") )
STOMP protocol headers.
var ( AckAuto = []byte("auto") AckClient = []byte("client") PersistTrue = []byte("true") RetainTrue = []byte("true") RetainLast = []byte("last") RetainAll = []byte("all") RetainRemove = []byte("remove") )
Common STOMP header values.
var STOMP = []byte("1.2")
STOMP protocol version.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client defines a client connection to a STOMP server.
func FromContext ¶
FromContext retrieves the client from context
func MustFromContext ¶
MustFromContext retrieves the client from context. Panics if not found
func (*Client) Ack ¶
func (c *Client) Ack(id []byte, opts ...MessageOption) error
Ack acknowledges the messages with the given id.
func (*Client) Connect ¶
func (c *Client) Connect(opts ...MessageOption) error
Connect opens the connection and establishes the session.
func (*Client) Disconnect ¶
Disconnect terminates the session and closes the connection.
func (*Client) Nack ¶
func (c *Client) Nack(id []byte, opts ...MessageOption) error
Nack negative-acknowledges the messages with the given id.
func (*Client) NewContext ¶
NewContext adds the client to the context.
func (*Client) Send ¶
func (c *Client) Send(dest string, data []byte, opts ...MessageOption) error
Send sends the data to the given destination.
func (*Client) SendJSON ¶
func (c *Client) SendJSON(dest string, v interface{}, opts ...MessageOption) error
SendJSON sends the JSON encoding of v to the given destination.
func (*Client) Subscribe ¶
func (c *Client) Subscribe(dest string, handler Handler, opts ...MessageOption) (id []byte, err error)
Subscribe subscribes to the given destination.
func (*Client) Unsubscribe ¶
func (c *Client) Unsubscribe(id []byte, opts ...MessageOption) error
Unsubscribe unsubscribes to the destination.
type HandlerFunc ¶
type HandlerFunc func(*Message)
The HandlerFunc type is an adapter to allow the use of an ordinary function as a STOMP message handler.
type Header ¶
type Header struct {
// contains filtered or unexported fields
}
Header represents the header section of the STOMP message.
func (*Header) Field ¶
Field returns the named header value in string format. This is used to provide compatibility with the SQL expression evaluation package.
type Message ¶
type Message struct { ID []byte // id header Proto []byte // stomp version Method []byte // stomp method User []byte // username header Pass []byte // password header Dest []byte // destination header Subs []byte // subscription id Ack []byte // ack id Msg []byte // message-id header Persist []byte // persist header Retain []byte // retain header Prefetch []byte // prefetch count Expires []byte // expires header Receipt []byte // receipt header Selector []byte // selector header Body []byte Header *Header // custom headers // contains filtered or unexported fields }
Message represents a parsed STOMP message.
func NewMessage ¶
func NewMessage() *Message
NewMessage returns an empty message from the message pool.
func (*Message) Apply ¶
func (m *Message) Apply(opts ...MessageOption)
Apply applies the options to the message.
func (*Message) Release ¶
func (m *Message) Release()
Release releases the message back to the message pool.
func (*Message) Reset ¶
func (m *Message) Reset()
Reset resets the meesage fields to their zero values.
type MessageOption ¶
type MessageOption func(*Message)
MessageOption configures message options.
func WithAck ¶
func WithAck(ack string) MessageOption
WithAck returns a MessageOption configured with an ack policy.
func WithCredentials ¶
func WithCredentials(username, password string) MessageOption
WithCredentials returns a MessageOption which sets credentials.
func WithExpires ¶
func WithExpires(exp int64) MessageOption
WithExpires returns a MessageOption configured with an expiration.
func WithHeader ¶
func WithHeader(key, value string) MessageOption
WithHeader returns a MessageOption which sets a header.
func WithHeaders ¶
func WithHeaders(headers map[string]string) MessageOption
WithHeaders returns a MessageOption which sets headers.
func WithPersistence ¶
func WithPersistence() MessageOption
WithPersistence returns a MessageOption configured to persist.
func WithPrefetch ¶
func WithPrefetch(prefetch int) MessageOption
WithPrefetch returns a MessageOption configured with a prefetch count.
func WithReceipt ¶
func WithReceipt() MessageOption
WithReceipt returns a MessageOption configured with a receipt request.
func WithRetain ¶
func WithRetain(retain string) MessageOption
WithRetain returns a MessageOption configured to retain the message.
func WithSelector ¶
func WithSelector(selector string) MessageOption
WithSelector returns a MessageOption configured to filter messages using a sql-like evaluation string.