server

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2016 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// VERSION is the current version for the NATS Streaming server.
	VERSION = "0.2.2"

	DefaultClusterID      = "test-cluster"
	DefaultDiscoverPrefix = "_STAN.discover"
	DefaultPubPrefix      = "_STAN.pub"
	DefaultSubPrefix      = "_STAN.sub"
	DefaultUnSubPrefix    = "_STAN.unsub"
	DefaultClosePrefix    = "_STAN.close"
	DefaultStoreType      = stores.TypeMemory

	// DefaultChannelLimit defines how many channels (literal subjects) we allow
	DefaultChannelLimit = 100
	// DefaultSubStoreLimit defines how many subscriptions per channel we allow
	DefaultSubStoreLimit = 1000
	// DefaultMsgStoreLimit defines how many messages per channel we allow
	DefaultMsgStoreLimit = 1000000
	// DefaultMsgSizeStoreLimit defines how many bytes per channel we allow
	DefaultMsgSizeStoreLimit = DefaultMsgStoreLimit * 1024

	// Heartbeat intervals.
	DefaultHeartBeatInterval   = 30 * time.Second
	DefaultClientHBTimeout     = 10 * time.Second
	DefaultMaxFailedHeartBeats = int((5 * time.Minute) / DefaultHeartBeatInterval)

	// DefaultIOBatchSize is the maximum number of messages to accumulate before flushing a store.
	DefaultIOBatchSize = 1024

	// DefaultIOSleepTime is the duration (in micro-seconds) the server waits for more messages
	// before starting processing. Set to 0 (or negative) to disable the wait.
	DefaultIOSleepTime = int64(0)
)

Server defaults.

Variables

View Source
var (
	ErrInvalidSubject  = errors.New("stan: invalid subject")
	ErrInvalidSequence = errors.New("stan: invalid start sequence")
	ErrInvalidTime     = errors.New("stan: invalid start time")
	ErrInvalidSub      = errors.New("stan: invalid subscription")
	ErrInvalidClient   = errors.New("stan: clientID already registered")
	ErrInvalidAckWait  = errors.New("stan: invalid ack wait time, should be >= 1s")
	ErrInvalidConnReq  = errors.New("stan: invalid connection request")
	ErrInvalidPubReq   = errors.New("stan: invalid publish request")
	ErrInvalidSubReq   = errors.New("stan: invalid subscription request")
	ErrInvalidUnsubReq = errors.New("stan: invalid unsubscribe request")
	ErrInvalidCloseReq = errors.New("stan: invalid close request")
	ErrDupDurable      = errors.New("stan: duplicate durable registration")
	ErrDurableQueue    = errors.New("stan: queue subscribers can't be durable")
	ErrUnknownClient   = errors.New("stan: unkwown clientID")
)

Errors.

View Source
var DefaultNatsServerOptions = server.Options{
	Host:   "localhost",
	Port:   4222,
	NoLog:  true,
	NoSigs: true,
}

DefaultNatsServerOptions are default options for the NATS server

Functions

func ConfigureLogger

func ConfigureLogger(stanOpts *Options, natsOpts *natsd.Options)

ConfigureLogger configures logging for STAN and the embedded NATS server based on options passed.

func Debugf

func Debugf(format string, v ...interface{})

Debugf logs a debug statement

func Errorf

func Errorf(format string, v ...interface{})

Errorf logs an error

func Fatalf

func Fatalf(format string, v ...interface{})

Fatalf logs a fatal error

func Noticef

func Noticef(format string, v ...interface{})

Noticef logs a notice statement

func RemoveLogger

func RemoveLogger()

RemoveLogger clears the logger instance and debug/trace flags. Used for testing.

func Tracef

func Tracef(format string, v ...interface{})

Tracef logs a trace statement

Types

type Options

type Options struct {
	ID               string
	DiscoverPrefix   string
	StoreType        string
	FilestoreDir     string
	FileStoreOpts    stores.FileStoreOptions
	MaxChannels      int
	MaxMsgs          int    // Maximum number of messages per channel
	MaxBytes         uint64 // Maximum number of bytes used by messages per channel
	MaxSubscriptions int    // Maximum number of subscriptions per channel
	Trace            bool   // Verbose trace
	Debug            bool   // Debug trace
	Secure           bool   // Create a TLS enabled connection w/o server verification
	ClientCert       string // Client Certificate for TLS
	ClientKey        string // Client Key for TLS
	ClientCA         string // Client CAs for TLS
	IOBatchSize      int    // Number of messages we collect from clients before processing them.
	IOSleepTime      int64  // Duration (in micro-seconds) the server waits for more message to fill up a batch.
	NATSServerURL    string // URL for external NATS Server to connect to. If empty, NATS Server is embedded.
}

Options for STAN Server

func GetDefaultOptions

func GetDefaultOptions() (o *Options)

GetDefaultOptions returns default options for the STAN server

type StanServer

type StanServer struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

StanServer structure represents the STAN server

func RunServer

func RunServer(ID string) *StanServer

RunServer will startup an embedded STAN server and a nats-server to support it.

func RunServerWithOpts

func RunServerWithOpts(stanOpts *Options, natsOpts *server.Options) *StanServer

RunServerWithOpts will startup an embedded STAN server and a nats-server to support it.

func (*StanServer) ClusterID

func (s *StanServer) ClusterID() string

ClusterID returns the STAN Server's ID.

func (*StanServer) Shutdown

func (s *StanServer) Shutdown()

Shutdown will close our NATS connection and shutdown any embedded NATS server.

Jump to

Keyboard shortcuts

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