Documentation ¶
Index ¶
- Constants
- func ReleaseVersion() string
- type AckMode
- type Broker
- type BrokerOpts
- type ClientHandler
- func (c *ClientHandler) BeginTransaction() (*Transaction, error)
- func (c *ClientHandler) Connect(useStompCmd bool) error
- func (c *ClientHandler) Disconnect() error
- func (c *ClientHandler) Send(dest string, body []byte, contentType string, customHeaders map[string]string) error
- func (c *ClientHandler) SetMessageHandler(handlerFunc MessageHandlerFunc)
- func (c *ClientHandler) Subscribe(dest string, mode AckMode) (*Subscription, error)
- type ClientOpts
- type Command
- type Frame
- type FrameSource
- type Header
- type LoginFunc
- type MessageHandlerFunc
- type Session
- type Subscription
- type Transaction
- type Transport
- type UserMessage
Constants ¶
const (
DefaultPort = "61613"
)
Variables ¶
This section is empty.
Functions ¶
func ReleaseVersion ¶ added in v0.2.16
func ReleaseVersion() string
ReleaseVersion returns the version of the go-proto-stomp module
Types ¶
type Broker ¶ added in v0.2.15
type Broker interface { // ListenAndServe is a blocking method that keeps accepting the client connections and handles the STOMP messages. ListenAndServe() // Shutdown should be called to bring down the underlying server gracefully. Shutdown() }
Broker lists the methods supported by the STOMP brokers
func StartBroker ¶ added in v0.2.15
func StartBroker(opts *BrokerOpts) (Broker, error)
StartBroker is the entry point for the STOMP broker.
type BrokerOpts ¶ added in v0.2.16
type BrokerOpts struct { // Transport refers to the underlying protocol for STOMP. // Choices: TransportTCP, TransportWebsocket. Default: TransportTCP Transport Transport // Host is the name of the host or IP to bind the server to. Default: localhost Host string // Port is the port number for the server to listen on. Default: 61613 (DefaultPort) Port string // LoginFunc is a user defined function for authenticating the user. Default: nil // It is of the form `func(login, passcode string) error` LoginFunc LoginFunc // HeartbeatSendIntervalMsec is the interval in milliseconds by which the broker can send heartbeats. // The broker will negotiate using this value with the client. Default: 0 (no heartbeats) // It will not send the heartbeats by an interval any smaller than this value. HeartbeatSendIntervalMsec int // HeartbeatReceiveIntervalMsec is the interval in milliseconds by which the broker can receive heartbeats. // The broker will negotiate using this value with the client. Default: 0 (no heartbeats) // This is to tell the client that the broker cannot receive heartbeats by any shorter interval than this value. HeartbeatReceiveIntervalMsec int }
BrokerOpts is passed as an argument to StartBroker
type ClientHandler ¶
type ClientHandler struct { SessionID string // Session ID for the connection with the STOMP Broker // contains filtered or unexported fields }
ClientHandler is the control struct for Client's connection with the STOMP Broker
func NewClientHandler ¶
func NewClientHandler(transport Transport, host, port string, opts *ClientOpts) *ClientHandler
NewClientHandler creates the Client for STOMP
func (*ClientHandler) BeginTransaction ¶
func (c *ClientHandler) BeginTransaction() (*Transaction, error)
func (*ClientHandler) Connect ¶
func (c *ClientHandler) Connect(useStompCmd bool) error
Connect connects with the broker and starts listening to the messages from broker
func (*ClientHandler) Disconnect ¶
func (c *ClientHandler) Disconnect() error
func (*ClientHandler) SetMessageHandler ¶
func (c *ClientHandler) SetMessageHandler(handlerFunc MessageHandlerFunc)
SetMessageHandler accepts the user-defined function to handle the messages
func (*ClientHandler) Subscribe ¶
func (c *ClientHandler) Subscribe(dest string, mode AckMode) (*Subscription, error)
type ClientOpts ¶
type ClientOpts struct { VirtualHost string // Virtual host Login string // AuthN Username Passcode string // AuthN Password HeartbeatSendInterval int // Sending interval of heartbeats in milliseconds HeartbeatReceiveInterval int // Receiving interval of heartbeats in milliseconds MessageHandler MessageHandlerFunc // User-defined callback function to handle MESSAGE }
ClientOpts provides the options as argument to NewClientHandler
type Command ¶
type Command string
Command represents the STOMP message-type
const ( CmdConnected Command = "CONNECTED" CmdMessage Command = "MESSAGE" CmdReceipt Command = "RECEIPT" CmdError Command = "ERROR" )
Server Frame Commands
const ( CmdConnect Command = "CONNECT" CmdStomp Command = "STOMP" CmdSend Command = "SEND" CmdSubscribe Command = "SUBSCRIBE" CmdUnsubscribe Command = "UNSUBSCRIBE" CmdAck Command = "ACK" CmdNack Command = "NACK" CmdBegin Command = "BEGIN" CmdCommit Command = "COMMIT" CmdAbort Command = "ABORT" CmdDisconnect Command = "DISCONNECT" )
Client Frame Commands
type Frame ¶
type Frame struct {
// contains filtered or unexported fields
}
Frame represents the stomp protocol frame
func NewFrameFromBytes ¶
NewFrameFromBytes creates a new Frame that is populated with deserialized raw input
func (*Frame) Deserialize ¶
Deserialize takes the wire-format and unmarshalls it into Frame struct. It also internally validates the wire-format while parsing to some extent.
func (*Frame) Validate ¶
func (f *Frame) Validate(s FrameSource) error
Validate checks both client and server STOMP frames. It also checks if the mandatory headers are present for a given message.
type FrameSource ¶
type FrameSource int
FrameSource is the source of frame: either Broker or Client
const ( ServerFrame FrameSource = 0 ClientFrame FrameSource = 1 )
Modes: server/client
type Header ¶
type Header string
Header represents the header-keys in the STOMP Frame
const ( HdrKeyAcceptVersion Header = "accept-version" HdrKeyAck Header = "ack" HdrKeyContentLength Header = "content-length" HdrKeyContentType Header = "content-type" HdrKeyDestination Header = "destination" HdrKeyHeartBeat Header = "heart-beat" HdrKeyHost Header = "host" HdrKeyID Header = "id" HdrKeyLogin Header = "login" HdrKeyMessage Header = "message" HdrKeyMessageID Header = "message-id" HdrKeyPassCode Header = "passcode" HdrKeyReceipt Header = "receipt" HdrKeyReceiptID Header = "receipt-id" HdrKeyServer Header = "server" HdrKeySession Header = "session" HdrKeySubscription Header = "subscription" HdrKeyTransaction Header = "transaction" HdrKeyVersion Header = "version" )
Frame headers
type MessageHandlerFunc ¶
type MessageHandlerFunc func(message *UserMessage)
MessageHandlerFunc is the function-type for user-defined function to handle the messages
type Session ¶ added in v0.2.16
type Session struct {
// contains filtered or unexported fields
}
Session handles the STOMP client session on connection
type Subscription ¶
type Subscription struct { SubsID string Destination string // contains filtered or unexported fields }
Subscription represents the state of subscription
func (*Subscription) Unsubscribe ¶
func (s *Subscription) Unsubscribe() error
type Transaction ¶
type Transaction struct { TxID string // contains filtered or unexported fields }
Transaction represents the state of transaction
func (*Transaction) AbortTransaction ¶
func (t *Transaction) AbortTransaction() error
func (*Transaction) CommitTransaction ¶
func (t *Transaction) CommitTransaction() error
type Transport ¶ added in v0.2.15
type Transport string
Transport represents the underlying transporting protocol for STOMP
type UserMessage ¶
type UserMessage struct { Headers map[string]string // STOMP and custom headers received in MESSAGE Body []byte // MESSAGE payload }
UserMessage represents the messages and the user-headers to be received by the user