server

package
v2.0.8+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package server contains a simple STOMP server implementation.

Index

Constants

View Source
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.

View Source
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.

Variables

This section is empty.

Functions

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.

Types

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 *frame.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 *frame.Frame) error

	// Dequeue removes a frame from the head of the queue.
	// Returns nil if no frame is available.
	Dequeue(queue string) (*frame.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

Path Synopsis
Package client implements client connectivity in the STOMP server.
Package client implements client connectivity in the STOMP server.
Package queue provides implementations of server-side queues.
Package queue provides implementations of server-side queues.
Package topic provides implementations of server-side topics.
Package topic provides implementations of server-side topics.

Jump to

Keyboard shortcuts

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