stomp: Index | Files

package client

import ""

Package client implements client connectivity in the STOMP server.

The key abstractions include a connection, a subscription and a client request.


Package Files

client.go config.go conn.go errors.go frame.go request.go subscription.go subscription_list.go tx_store.go util.go

type Config Uses

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

Contains information the client package needs from the rest of the STOMP server code.

type Conn Uses

type Conn struct {
    // contains filtered or unexported fields

Represents a connection with the STOMP client.

func NewConn Uses

func NewConn(config Config, rw net.Conn, ch chan Request) *Conn

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.

func (*Conn) Send Uses

func (c *Conn) Send(f *frame.Frame)

Write a frame to the connection without requiring any acknowledgement.

func (*Conn) SendError Uses

func (c *Conn) SendError(err error)

Send and ERROR message to the client. The client connection will disconnect as soon as the ERROR message has been transmitted. The message header will be based on the contents of the err parameter.

type Request Uses

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 Uses

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.

func (RequestOp) String Uses

func (r RequestOp) String() string

type Subscription Uses

type Subscription struct {
    // contains filtered or unexported fields

func (*Subscription) Ack Uses

func (s *Subscription) Ack() string

func (*Subscription) Destination Uses

func (s *Subscription) Destination() string

func (*Subscription) Id Uses

func (s *Subscription) Id() string

func (*Subscription) IsAckedBy Uses

func (s *Subscription) IsAckedBy(msgId uint64) bool

func (*Subscription) IsNackedBy Uses

func (s *Subscription) IsNackedBy(msgId uint64) bool

func (*Subscription) SendQueueFrame Uses

func (s *Subscription) SendQueueFrame(f *frame.Frame)

func (*Subscription) SendTopicFrame Uses

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 Uses

type SubscriptionList struct {
    // contains filtered or unexported fields

Maintains a list of subscriptions. Not thread-safe.

func NewSubscriptionList Uses

func NewSubscriptionList() *SubscriptionList

func (*SubscriptionList) Ack Uses

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 Uses

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 Uses

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 Uses

func (sl *SubscriptionList) ForEach(callback func(s *Subscription, isLast bool))

Invoke a callback function for every subscription in the list.

func (*SubscriptionList) Get Uses

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 Uses

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 Uses

func (sl *SubscriptionList) Remove(s *Subscription)

Removes the subscription from the list.

Package client imports 12 packages (graph) and is imported by 14 packages. Updated 2016-07-16. Refresh now. Tools for package owners.