stomp: github.com/jjeffery/stomp/server Index | Files | Directories

package server

import "github.com/jjeffery/stomp/server"

Package server contains a simple STOMP server implementation.

Index

Package Files

processor.go queue_storage.go server.go

Constants

const (
    // Default address for listening for connections.
    DefaultAddr = ":61613"

    // Default read timeout for heart-beat.
    // Override by setting Server.HeartBeat.
    DefaultHeartBeat = time.Minute
)

Default server parameters.

const QueuePrefix = "/queue"

The STOMP server has the concept of queues and topics. A message sent to a queue destination will be transmitted to the next available client that has subscribed. A message sent to a topic will be transmitted to all subscribers that are currently subscribed to the topic.

Destinations that start with this prefix are considered to be queues. Destinations that do not start with this prefix are considered to be topics.

func ListenAndServe

func ListenAndServe(addr string) error

ListenAndServe listens on the TCP network address addr and then calls Serve.

func Serve

func Serve(l net.Listener) error

Serve accepts incoming TCP connections on the listener l, creating a new STOMP service thread for each connection.

type Authenticator

type Authenticator interface {
    // Authenticate based on the given login and passcode, either of which might be nil.
    // Returns true if authentication is successful, false otherwise.
    Authenticate(login, passcode string) bool
}

Interface for authenticating STOMP clients.

type QueueStorage

type QueueStorage interface {
    // Enqueue adds a MESSAGE frame to the end of the queue.
    Enqueue(queue string, frame *stomp.Frame) error

    // Requeue adds a MESSAGE frame to the head of the queue.
    // This will happen if a client fails to acknowledge receipt.
    Requeue(queue string, frame *stomp.Frame) error

    // Dequeue removes a frame from the head of the queue.
    // Returns nil if no frame is available.
    Dequeue(queue string) (*stomp.Frame, error)

    // Start is called at server startup. Allows the queue storage
    // to perform any initialization.
    Start()

    // Stop is called prior to server shutdown. Allows the queue storage
    // to perform any cleanup, such as flushing to disk.
    Stop()
}

QueueStorage is an interface that abstracts the queue storage mechanism. The intent is that different queue storage implementations can be used, depending on preference. Queue storage mechanisms could include in-memory, and various persistent storage mechanisms (eg file system, DB, etc).

type Server

type Server struct {
    Addr          string        // TCP address to listen on, DefaultAddr if empty
    Authenticator Authenticator // Authenticates login/passcodes. If nil no authentication is performed
    QueueStorage  QueueStorage  // Implementation of queue storage. If nil, in-memory queues are used.
    HeartBeat     time.Duration // Preferred value for heart-beat read/write timeout, if zero, then DefaultHeartBeat.
}

A Server defines parameters for running a STOMP server.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

ListenAndServe listens on the TCP network address s.Addr and then calls Serve to handle requests on the incoming connections. If s.Addr is blank, then DefaultAddr is used.

func (*Server) Serve

func (s *Server) Serve(l net.Listener) error

Serve accepts incoming connections on the Listener l, creating a new service thread for each connection. The service threads read requests and then process each request.

Directories

PathSynopsis
clientPackage client implements client connectivity in the STOMP server.
queuePackage queue provides implementations of server-side queues.
topicPackage topic provides implementations of server-side topics.

Package server imports 9 packages (graph) and is imported by 3 packages. Updated 2014-03-30. Refresh now. Tools for package owners.