client

package
v2.0.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2016 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package client implements client connectivity in the STOMP server.

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

Index

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
}

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

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

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

Write a frame to the connection without requiring any acknowledgement.

func (*Conn) SendError

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

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.

func (RequestOp) String

func (r RequestOp) String() string

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL