Documentation ¶
Overview ¶
Package client implements client connectivity in the STOMP server.
The key abstractions include a connection, a subscription and a client request.
Index ¶
- type Config
- type Conn
- type Request
- type RequestOp
- type Subscription
- func (s *Subscription) Ack() string
- func (s *Subscription) Destination() string
- func (s *Subscription) Id() string
- func (s *Subscription) IsAckedBy(msgId uint64) bool
- func (s *Subscription) IsNackedBy(msgId uint64) bool
- func (s *Subscription) SendQueueFrame(f *frame.Frame)
- func (s *Subscription) SendTopicFrame(f *frame.Frame)
- type SubscriptionList
- func (sl *SubscriptionList) Ack(msgId uint64, callback func(s *Subscription))
- func (sl *SubscriptionList) Add(sub *Subscription)
- func (sl *SubscriptionList) FindByIdAndRemove(id string) *Subscription
- func (sl *SubscriptionList) ForEach(callback func(s *Subscription, isLast bool))
- func (sl *SubscriptionList) Get() *Subscription
- func (sl *SubscriptionList) Nack(msgId uint64, callback func(s *Subscription))
- func (sl *SubscriptionList) Remove(s *Subscription)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config interface { // Method to authenticate a login and associated passcode. // Returns true if login/passcode is valid, false otherwise. Authenticate(login, passcode string) bool // Default duration for read/write heart-beat values. If this // returns zero, no heart-beat will take place. If this value is // larger than the maximu permitted value (which is more than // 11 days, but less than 12 days), then it is truncated to the // maximum permitted values. HeartBeat() time.Duration // Logger provides the logger for a client Logger() stomp.Logger }
Contains information the client package needs from the rest of the STOMP server code.
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Represents a connection with the STOMP client.
func NewConn ¶
Creates a new client connection. The config parameter contains process-wide configuration parameters relevant to a client connection. The rw parameter is a network connection object for communicating with the client. All client requests are sent via the ch channel to the upper layer.
type Request ¶
type Request struct { Op RequestOp // opcode for request Sub *Subscription // SubscribeOp, UnsubscribeOp Frame *frame.Frame // EnqueueOp, RequeueOp Conn *Conn // ConnectedOp, DisconnectedOp }
Client requests received to be processed by main processing loop
type RequestOp ¶
type RequestOp int
Opcode used in client requests.
const ( SubscribeOp RequestOp = iota // subscription ready UnsubscribeOp // subscription not ready EnqueueOp // send a message to a queue RequeueOp // re-queue a message, not successfully sent ConnectedOp // connection established DisconnectedOp // connection disconnected )
Valid value for client request opcodes.
type Subscription ¶
type Subscription struct {
// contains filtered or unexported fields
}
func (*Subscription) Ack ¶
func (s *Subscription) Ack() string
func (*Subscription) Destination ¶
func (s *Subscription) Destination() string
func (*Subscription) Id ¶
func (s *Subscription) Id() string
func (*Subscription) IsAckedBy ¶
func (s *Subscription) IsAckedBy(msgId uint64) bool
func (*Subscription) IsNackedBy ¶
func (s *Subscription) IsNackedBy(msgId uint64) bool
func (*Subscription) SendQueueFrame ¶
func (s *Subscription) SendQueueFrame(f *frame.Frame)
func (*Subscription) SendTopicFrame ¶
func (s *Subscription) SendTopicFrame(f *frame.Frame)
Send a message frame to the client, as part of this subscription. Called within the queue when a message frame is available.
type SubscriptionList ¶
type SubscriptionList struct {
// contains filtered or unexported fields
}
Maintains a list of subscriptions. Not thread-safe.
func NewSubscriptionList ¶
func NewSubscriptionList() *SubscriptionList
func (*SubscriptionList) Ack ¶
func (sl *SubscriptionList) Ack(msgId uint64, callback func(s *Subscription))
Finds all subscriptions in the subscription list that are acked by the specified message-id (or ack) header. The subscription is removed from the list and the callback function called for that subscription.
func (*SubscriptionList) Add ¶
func (sl *SubscriptionList) Add(sub *Subscription)
Add a subscription to the back of the list. Will panic if the subscription destination does not match the subscription list destination. Will also panic if the subscription has already been added to a subscription list.
func (*SubscriptionList) FindByIdAndRemove ¶
func (sl *SubscriptionList) FindByIdAndRemove(id string) *Subscription
Search for a subscription with the specified id and remove it. Returns a pointer to the subscription if found, nil otherwise.
func (*SubscriptionList) ForEach ¶
func (sl *SubscriptionList) ForEach(callback func(s *Subscription, isLast bool))
Invoke a callback function for every subscription in the list.
func (*SubscriptionList) Get ¶
func (sl *SubscriptionList) Get() *Subscription
Gets the first subscription in the list, or nil if there are no subscriptions available. The subscription is removed from the list.
func (*SubscriptionList) Nack ¶
func (sl *SubscriptionList) Nack(msgId uint64, callback func(s *Subscription))
Finds all subscriptions in the subscription list that are *nacked* by the specified message-id (or ack) header. The subscription is removed from the list and the callback function called for that subscription. Current understanding that all NACKs are individual, but not sure
func (*SubscriptionList) Remove ¶
func (sl *SubscriptionList) Remove(s *Subscription)
Removes the subscription from the list.