server

package
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2017 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

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

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

	// DefaultHeartBeatInterval is the interval at which server sends heartbeat to a client
	DefaultHeartBeatInterval = 30 * time.Second
	// DefaultClientHBTimeout is how long server waits for a heartbeat response
	DefaultClientHBTimeout = 10 * time.Second
	// DefaultMaxFailedHeartBeats is the number of failed heartbeats before server closes
	// the client connection (total= (heartbeat interval + heartbeat timeout) * (fail count + 1)
	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")
	ErrInvalidStart       = errors.New("stan: invalid start position")
	ErrInvalidSub         = errors.New("stan: invalid subscription")
	ErrInvalidClient      = errors.New("stan: clientID already registered")
	ErrMissingClient      = errors.New("stan: clientID missing")
	ErrInvalidAckWait     = errors.New("stan: invalid ack wait time, should be >= 1s")
	ErrInvalidMaxInflight = errors.New("stan: invalid MaxInflight, should be >= 1")
	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")
	ErrInvalidDurName     = errors.New("stan: durable name of a durable queue subscriber can't contain the character ':'")
	ErrUnknownClient      = errors.New("stan: unknown 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 ProcessConfigFile added in v0.3.0

func ProcessConfigFile(configFile string, opts *Options) error

ProcessConfigFile parses the configuration file `configFile` and updates the given Streaming options `opts`.

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
	stores.StoreLimits               // Store limits (MaxChannels, etc..)
	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.
	ClientHBInterval   time.Duration // Interval at which server sends heartbeat to a client.
	ClientHBTimeout    time.Duration // How long server waits for a heartbeat response.
	ClientHBFailCount  int           // Number of failed heartbeats before server closes client connection.
}

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