gnatsd: Index | Files | Directories

package server

import ""


Package Files

accounts.go auth.go ciphersuites.go client.go const.go errors.go events.go gateway.go jwt.go leafnode.go log.go monitor.go monitor_sort_opts.go nkey.go opts.go parser.go reload.go ring.go route.go server.go service.go signal.go sublist.go util.go


const (
    // CLIENT is an end user.
    CLIENT = iota
    // ROUTER is another router in the cluster.
    // GATEWAY is a link between 2 clusters.
    // SYSTEM is an internal system client.
    // LEAF is for leaf node connections.

Type of client connection.

const (
    // ClientProtoZero is the original Client protocol from 2009.
    ClientProtoZero = iota
    // ClientProtoInfo signals a client can receive more then the original INFO block.
    // This can be used to update clients on other cluster members, etc.
const (
    ClientClosed = ClosedState(iota + 1)
const (
    CommandStop   = Command("stop")
    CommandQuit   = Command("quit")
    CommandReopen = Command("reopen")
    CommandReload = Command("reload")

Valid Command values.

const (
    // VERSION is the current version for the server.
    VERSION = "2.0.0-RC6"

    // PROTO is the currently supported protocol.
    // 0 was the original
    // 1 maintains proto 0, adds echo abilities for CONNECT from the client. Clients
    // should not send echo unless proto in INFO is >= 1.
    PROTO = 1

    // DEFAULT_PORT is the default port for client connections.
    DEFAULT_PORT = 4222

    // RANDOM_PORT is the value for port that, when supplied, will cause the
    // server to listen on a randomly-chosen available port. The resolved port
    // is available via the Addr() method.
    RANDOM_PORT = -1

    // DEFAULT_HOST defaults to all interfaces.

    // MAX_CONTROL_LINE_SIZE is the maximum allowed protocol control line size.
    // 4k should be plenty since payloads sans connect/info string are separate.

    // MAX_PAYLOAD_SIZE is the maximum allowed payload size. Should be using
    // something different if > 1MB payloads are needed.
    MAX_PAYLOAD_SIZE = (1024 * 1024)

    // MAX_PENDING_SIZE is the maximum outbound pending bytes per client.
    MAX_PENDING_SIZE = (64 * 1024 * 1024)

    // DEFAULT_MAX_CONNECTIONS is the default maximum connections allowed.

    // TLS_TIMEOUT is the TLS wait time.
    TLS_TIMEOUT = 500 * time.Millisecond

    // AUTH_TIMEOUT is the authorization wait time.

    // DEFAULT_PING_INTERVAL is how often pings are sent to clients and routes.
    DEFAULT_PING_INTERVAL = 2 * time.Minute

    // DEFAULT_PING_MAX_OUT is maximum allowed pings outstanding before disconnect.

    // CR_LF string
    CR_LF = "\r\n"

    // LEN_CR_LF hold onto the computed size.
    LEN_CR_LF = len(CR_LF)

    // DEFAULT_FLUSH_DEADLINE is the write/flush deadlines.
    DEFAULT_FLUSH_DEADLINE = 2 * time.Second

    // DEFAULT_HTTP_PORT is the default monitoring port.

    // ACCEPT_MIN_SLEEP is the minimum acceptable sleep times on temporary errors.
    ACCEPT_MIN_SLEEP = 10 * time.Millisecond

    // ACCEPT_MAX_SLEEP is the maximum acceptable sleep times on temporary errors
    ACCEPT_MAX_SLEEP = 1 * time.Second

    // DEFAULT_ROUTE_CONNECT Route solicitation intervals.
    DEFAULT_ROUTE_CONNECT = 1 * time.Second

    // DEFAULT_ROUTE_RECONNECT Route reconnect intervals.
    DEFAULT_ROUTE_RECONNECT = 1 * time.Second

    // DEFAULT_ROUTE_DIAL Route dial timeout.
    DEFAULT_ROUTE_DIAL = 1 * time.Second

    // DEFAULT_LEAF_NODE_RECONNECT LeafNode reconnect interval.

    // PROTO_SNIPPET_SIZE is the default size of proto to print on parse errors.

    // MAX_MSG_ARGS Maximum possible number of arguments from MSG proto.
    MAX_MSG_ARGS = 4

    // MAX_PUB_ARGS Maximum possible number of arguments from PUB proto.
    MAX_PUB_ARGS = 3

    // DEFAULT_MAX_CLOSED_CLIENTS is the maximum number of closed connections we hold onto.

    // DEFAULT_MAX_ACCOUNT_AE_RESPONSE_MAPS is for auto-expire response maps for imports.

    // DEFAULT_TTL_AE_RESPONSE_MAP is the default time to expire auto-response map entries.
    DEFAULT_TTL_AE_RESPONSE_MAP = 10 * time.Minute

    // DEFAULT_LAME_DUCK_DURATION is the time in which the server spreads
    // the closing of clients when signaled to go in lame duck mode.
    DEFAULT_LAME_DUCK_DURATION = 2 * time.Minute

    // DEFAULT_LEAFNODE_INFO_WAIT Route dial timeout.
    DEFAULT_LEAFNODE_INFO_WAIT = 1 * time.Second
const (
    ConnOpen = ConnState(iota)
const (
    OP_START parserState = iota

Parser constants

const (
    // RouteProtoZero is the original Route protocol from 2009.
    RouteProtoZero = iota
    // RouteProtoInfo signals a route can receive more then the original INFO block.
    // This can be used to update remote cluster permissions, etc...
    // RouteProtoV2 is the new route/cluster protocol that provides account support.
const (
    ConProto  = "CONNECT %s" + _CRLF_
    InfoProto = "INFO %s" + _CRLF_

Route protocol constants

const (
    RootPath    = "/"
    VarzPath    = "/varz"
    ConnzPath   = "/connz"
    RoutezPath  = "/routez"
    SubszPath   = "/subsz"
    StackszPath = "/stacksz"

HTTP endpoints

const DefaultConnListSize = 1024

DefaultConnListSize is the default size of the connection list.

const DefaultSubListSize = 1024

DefaultSubListSize is the default size of the subscriptions list.


var (
    // ErrConnectionClosed represents an error condition on a closed connection.
    ErrConnectionClosed = errors.New("connection closed")

    // ErrAuthentication represents an error condition on failed authentication.
    ErrAuthentication = errors.New("authentication error")

    // ErrAuthTimeout represents an error condition on failed authorization due to timeout.
    ErrAuthTimeout = errors.New("authentication timeout")

    // ErrAuthExpired represents an expired authorization due to timeout.
    ErrAuthExpired = errors.New("authentication expired")

    // ErrMaxPayload represents an error condition when the payload is too big.
    ErrMaxPayload = errors.New("maximum payload exceeded")

    // ErrMaxControlLine represents an error condition when the control line is too big.
    ErrMaxControlLine = errors.New("maximum control line exceeded")

    // ErrReservedPublishSubject represents an error condition when sending to a reserved subject, e.g. _SYS.>
    ErrReservedPublishSubject = errors.New("reserved internal subject")

    // ErrBadClientProtocol signals a client requested an invalud client protocol.
    ErrBadClientProtocol = errors.New("invalid client protocol")

    // ErrTooManyConnections signals a client that the maximum number of connections supported by the
    // server has been reached.
    ErrTooManyConnections = errors.New("maximum connections exceeded")

    // ErrTooManyAccountConnections signals that an acount has reached its maximum number of active
    // connections.
    ErrTooManyAccountConnections = errors.New("maximum account active connections exceeded")

    // ErrTooManySubs signals a client that the maximum number of subscriptions per connection
    // has been reached.
    ErrTooManySubs = errors.New("maximum subscriptions exceeded")

    // ErrClientConnectedToRoutePort represents an error condition when a client
    // attempted to connect to the route listen port.
    ErrClientConnectedToRoutePort = errors.New("attempted to connect to route port")

    // ErrClientConnectedToLeafNodePort represents an error condition when a client
    // attempted to connect to the leaf node listen port.
    ErrClientConnectedToLeafNodePort = errors.New("attempted to connect to leaf node port")

    // ErrAccountExists is returned when an account is attempted to be registered
    // but already exists.
    ErrAccountExists = errors.New("account exists")

    // ErrBadAccount represents a malformed or incorrect account.
    ErrBadAccount = errors.New("bad account")

    // ErrReservedAccount represents a reserved account that can not be created.
    ErrReservedAccount = errors.New("reserved account")

    // ErrMissingAccount is returned when an account does not exist.
    ErrMissingAccount = errors.New("account missing")

    // ErrAccountValidation is returned when an account has failed validation.
    ErrAccountValidation = errors.New("account validation failed")

    // ErrAccountExpired is returned when an account has expired.
    ErrAccountExpired = errors.New("account expired")

    // ErrNoAccountResolver is returned when we attempt an update but do not have an account resolver.
    ErrNoAccountResolver = errors.New("account resolver missing")

    // ErrAccountResolverUpdateTooSoon is returned when we attempt an update too soon to last request.
    ErrAccountResolverUpdateTooSoon = errors.New("account resolver update too soon")

    // ErrAccountResolverSameClaims is returned when same claims have been fetched.
    ErrAccountResolverSameClaims = errors.New("account resolver no new claims")

    // ErrStreamImportAuthorization is returned when a stream import is not authorized.
    ErrStreamImportAuthorization = errors.New("stream import not authorized")

    // ErrServiceImportAuthorization is returned when a service import is not authorized.
    ErrServiceImportAuthorization = errors.New("service import not authorized")

    // ErrClientOrRouteConnectedToGatewayPort represents an error condition when
    // a client or route attempted to connect to the Gateway port.
    ErrClientOrRouteConnectedToGatewayPort = errors.New("attempted to connect to gateway port")

    // ErrWrongGateway represents an error condition when a server receives a connect
    // request from a remote Gateway with a destination name that does not match the server's
    // Gateway's name.
    ErrWrongGateway = errors.New("wrong gateway")

    // ErrNoSysAccount is returned when an attempt to publish or subscribe is made
    // when there is no internal system account defined.
    ErrNoSysAccount = errors.New("system account not setup")
var (
    ErrInvalidSubject = errors.New("sublist: invalid subject")
    ErrNotFound       = errors.New("sublist: no matches found")

Sublist related errors

var IsPublicExport = []*Account(nil)

IsPublicExport is a placeholder to denote a public export.

func GenTLSConfig Uses

func GenTLSConfig(tc *TLSConfigOpts) (*tls.Config, error)

GenTLSConfig loads TLS related configuration parameters.

func IsValidLiteralSubject Uses

func IsValidLiteralSubject(subject string) bool

IsValidLiteralSubject returns true if a subject is valid and literal (no wildcards), false otherwise

func IsValidSubject Uses

func IsValidSubject(subject string) bool

IsValidSubject returns true if a subject is valid, false otherwise

func PrintAndDie Uses

func PrintAndDie(msg string)

PrintAndDie is exported for access in other packages.

func PrintServerAndExit Uses

func PrintServerAndExit()

PrintServerAndExit will print our version and exit.

func PrintTLSHelpAndDie Uses

func PrintTLSHelpAndDie()

PrintTLSHelpAndDie prints TLS usage and exits.

func ProcessCommandLineArgs Uses

func ProcessCommandLineArgs(cmd *flag.FlagSet) (showVersion bool, showHelp bool, err error)

ProcessCommandLineArgs takes the command line arguments validating and setting flags for handling in case any sub command was present.

func ProcessSignal Uses

func ProcessSignal(command Command, pidStr string) error

ProcessSignal sends the given signal command to the given process. If pidStr is empty, this will send the signal to the single running instance of gnatsd. If multiple instances are running, it returns an error. This returns an error if the given process is not running or the command is invalid.

func RemoveSelfReference Uses

func RemoveSelfReference(clusterPort int, routes []*url.URL) ([]*url.URL, error)

RemoveSelfReference removes this server from an array of routes

func ResetGatewaysSolicitDelay Uses

func ResetGatewaysSolicitDelay()

ResetGatewaysSolicitDelay resets the initial delay before gateways connections are initiated to its default values. Used by tests.

func ResponseHandler Uses

func ResponseHandler(w http.ResponseWriter, r *http.Request, data []byte)

ResponseHandler handles responses for monitoring routes

func RoutesFromStr Uses

func RoutesFromStr(routesStr string) []*url.URL

RoutesFromStr parses route URLs from a string

func Run Uses

func Run(server *Server) error

Run starts the NATS server. This wrapper function allows Windows to add a hook for running NATS as a service.

func SetGatewaysSolicitDelay Uses

func SetGatewaysSolicitDelay(delay time.Duration)

SetGatewaysSolicitDelay sets the initial delay before gateways connections are initiated. Used by tests.

func SetProcessName Uses

func SetProcessName(name string)

SetProcessName allows to change the expected name of the process.

type Account Uses

type Account struct {
    Name   string
    Nkey   string
    Issuer string
    // contains filtered or unexported fields

Account are subject namespace definitions. By default no messages are shared between accounts. You can share via Exports and Imports of Streams and Services.

func NewAccount Uses

func NewAccount(name string) *Account

func (*Account) AddServiceExport Uses

func (a *Account) AddServiceExport(subject string, accounts []*Account) error

AddServiceExport will configure the account with the defined export.

func (*Account) AddServiceImport Uses

func (a *Account) AddServiceImport(destination *Account, from, to string) error

AddServiceImport will add a route to an account to send published messages / requests to the destination account. From is the local subject to map, To is the subject that will appear on the destination account. Destination will need to have an import rule to allow access via addService.

func (*Account) AddServiceImportWithClaim Uses

func (a *Account) AddServiceImportWithClaim(destination *Account, from, to string, imClaim *jwt.Import) error

func (*Account) AddStreamExport Uses

func (a *Account) AddStreamExport(subject string, accounts []*Account) error

AddStreamExport will add an export to the account. If accounts is nil it will signify a public export, meaning anyone can impoort.

func (*Account) AddStreamImport Uses

func (a *Account) AddStreamImport(account *Account, from, prefix string) error

AddStreamImport will add in the stream import from a specific account.

func (*Account) AddStreamImportWithClaim Uses

func (a *Account) AddStreamImportWithClaim(account *Account, from, prefix string, imClaim *jwt.Import) error

AddStreamImportWithClaim will add in the stream import from a specific account with optional token.

func (*Account) AutoExpireTTL Uses

func (a *Account) AutoExpireTTL() time.Duration

AutoExpireTTL returns the ttl for response maps.

func (*Account) IsExpired Uses

func (a *Account) IsExpired() bool

IsExpired returns expiration status.

func (*Account) MaxActiveConnections Uses

func (a *Account) MaxActiveConnections() int

MaxActiveConnections return the set limit for the account system wide for total number of active connections.

func (*Account) MaxAutoExpireResponseMaps Uses

func (a *Account) MaxAutoExpireResponseMaps() int

MaxAutoExpireResponseMaps return the maximum number of auto expire response maps we will allow.

func (*Account) MaxTotalConnectionsReached Uses

func (a *Account) MaxTotalConnectionsReached() bool

MaxClientsReached returns if we have reached our limit for number of connections.

func (*Account) NumConnections Uses

func (a *Account) NumConnections() int

NumClients returns active number of clients for this account for all known servers.

func (*Account) NumLocalConnections Uses

func (a *Account) NumLocalConnections() int

NumLocalClients returns active number of clients for this account on this server.

func (*Account) RoutedSubs Uses

func (a *Account) RoutedSubs() int

RoutedSubs returns how many subjects we would send across a route when first connected or expressing interest. Local client subs.

func (*Account) SetAutoExpireTTL Uses

func (a *Account) SetAutoExpireTTL(ttl time.Duration)

SetAutoExpireTTL sets the ttl for response maps.

func (*Account) SetMaxAutoExpireResponseMaps Uses

func (a *Account) SetMaxAutoExpireResponseMaps(max int)

SetMaxAutoExpireResponseMaps sets the max outstanding auto expire response maps.

func (*Account) TotalSubs Uses

func (a *Account) TotalSubs() int

TotalSubs returns total number of Subscriptions for this account.

type AccountNumConns Uses

type AccountNumConns struct {
    Server     ServerInfo `json:"server"`
    Account    string     `json:"acc"`
    Conns      int        `json:"conns"`
    TotalConns int        `json:"total_conns"`

AccountNumConns is an event that will be sent from a server that is tracking a given account when the number of connections changes. It will also HB updates in the absence of any changes.

type AccountResolver Uses

type AccountResolver interface {
    Fetch(name string) (string, error)
    Store(name, jwt string) error

AccountResolver interface. This is to fetch Account JWTs by public nkeys

type Authentication Uses

type Authentication interface {
    // Check if a client is authorized to connect
    Check(c ClientAuthentication) bool

Authentication is an interface for implementing authentication

type ClientAuthentication Uses

type ClientAuthentication interface {
    // Get options associated with a client
    GetOpts() *clientOpts
    // If TLS is enabled, TLS ConnectionState, nil otherwise
    GetTLSConnectionState() *tls.ConnectionState
    // Optionally map a user after auth.
    // RemoteAddress expose the connection information of the client
    RemoteAddress() net.Addr

ClientAuthentication is an interface for client authentication

type ClientInfo Uses

type ClientInfo struct {
    Start   time.Time  `json:"start,omitempty"`
    Host    string     `json:"host,omitempty"`
    ID      uint64     `json:"id"`
    Account string     `json:"acc"`
    User    string     `json:"user,omitempty"`
    Name    string     `json:"name,omitempty"`
    Lang    string     `json:"lang,omitempty"`
    Version string     `json:"ver,omitempty"`
    RTT     string     `json:"rtt,omitempty"`
    Stop    *time.Time `json:"stop,omitempty"`

ClientInfo is detailed information about the client forming a connection.

type ClosedState Uses

type ClosedState int

ClosedState is the reason client was closed. This will be passed into calls to clearConnection, but will only be stored in ConnInfo for monitoring.

func (ClosedState) String Uses

func (reason ClosedState) String() string

type ClusterOpts Uses

type ClusterOpts struct {
    Host           string            `json:"addr,omitempty"`
    Port           int               `json:"cluster_port,omitempty"`
    Username       string            `json:"-"`
    Password       string            `json:"-"`
    AuthTimeout    float64           `json:"auth_timeout,omitempty"`
    Permissions    *RoutePermissions `json:"-"`
    TLSTimeout     float64           `json:"-"`
    TLSConfig      *tls.Config       `json:"-"`
    TLSMap         bool              `json:"-"`
    ListenStr      string            `json:"-"`
    Advertise      string            `json:"-"`
    NoAdvertise    bool              `json:"-"`
    ConnectRetries int               `json:"-"`

ClusterOpts are options for clusters.

type Command Uses

type Command string

Command is a signal used to control a running gnatsd process.

type ConnInfo Uses

type ConnInfo struct {
    Cid            uint64     `json:"cid"`
    IP             string     `json:"ip"`
    Port           int        `json:"port"`
    Start          time.Time  `json:"start"`
    LastActivity   time.Time  `json:"last_activity"`
    Stop           *time.Time `json:"stop,omitempty"`
    Reason         string     `json:"reason,omitempty"`
    RTT            string     `json:"rtt,omitempty"`
    Uptime         string     `json:"uptime"`
    Idle           string     `json:"idle"`
    Pending        int        `json:"pending_bytes"`
    InMsgs         int64      `json:"in_msgs"`
    OutMsgs        int64      `json:"out_msgs"`
    InBytes        int64      `json:"in_bytes"`
    OutBytes       int64      `json:"out_bytes"`
    NumSubs        uint32     `json:"subscriptions"`
    Name           string     `json:"name,omitempty"`
    Lang           string     `json:"lang,omitempty"`
    Version        string     `json:"version,omitempty"`
    TLSVersion     string     `json:"tls_version,omitempty"`
    TLSCipher      string     `json:"tls_cipher_suite,omitempty"`
    AuthorizedUser string     `json:"authorized_user,omitempty"`
    Subs           []string   `json:"subscriptions_list,omitempty"`

ConnInfo has detailed information on a per connection basis.

type ConnInfos Uses

type ConnInfos []*ConnInfo

Represents a connection info list. We use pointers since it will be sorted.

func (ConnInfos) Len Uses

func (cl ConnInfos) Len() int

For sorting

func (ConnInfos) Swap Uses

func (cl ConnInfos) Swap(i, j int)

type ConnState Uses

type ConnState int

ConnState is for filtering states of connections. We will only have two, open and closed.

type ConnectEventMsg Uses

type ConnectEventMsg struct {
    Server ServerInfo `json:"server"`
    Client ClientInfo `json:"client"`

ConnectEventMsg is sent when a new connection is made that is part of an account.

type Connz Uses

type Connz struct {
    ID       string      `json:"server_id"`
    Now      time.Time   `json:"now"`
    NumConns int         `json:"num_connections"`
    Total    int         `json:"total"`
    Offset   int         `json:"offset"`
    Limit    int         `json:"limit"`
    Conns    []*ConnInfo `json:"connections"`

Connz represents detailed information on current client connections.

type ConnzOptions Uses

type ConnzOptions struct {
    // Sort indicates how the results will be sorted. Check SortOpt for possible values.
    // Only the sort by connection ID (ByCid) is ascending, all others are descending.
    Sort SortOpt `json:"sort"`

    // Username indicates if user names should be included in the results.
    Username bool `json:"auth"`

    // Subscriptions indicates if subscriptions should be included in the results.
    Subscriptions bool `json:"subscriptions"`

    // Offset is used for pagination. Connz() only returns connections starting at this
    // offset from the global results.
    Offset int `json:"offset"`

    // Limit is the maximum number of connections that should be returned by Connz().
    Limit int `json:"limit"`

    // Filter for this explicit client connection.
    CID uint64 `json:"cid"`

    // Filter by connection state.
    State ConnState `json:"state"`

ConnzOptions are the options passed to Connz()

type DataStats Uses

type DataStats struct {
    Msgs  int64 `json:"msgs"`
    Bytes int64 `json:"bytes"`

DataStats reports how may msg and bytes. Applicable for both sent and received.

type DisconnectEventMsg Uses

type DisconnectEventMsg struct {
    Server   ServerInfo `json:"server"`
    Client   ClientInfo `json:"client"`
    Sent     DataStats  `json:"sent"`
    Received DataStats  `json:"received"`
    Reason   string     `json:"reason"`

DisconnectEventMsg is sent when a new connection previously defined from a ConnectEventMsg is closed.

type GatewayOpts Uses

type GatewayOpts struct {
    Name           string               `json:"name"`
    Host           string               `json:"addr,omitempty"`
    Port           int                  `json:"port,omitempty"`
    Username       string               `json:"-"`
    Password       string               `json:"-"`
    AuthTimeout    float64              `json:"auth_timeout,omitempty"`
    TLSConfig      *tls.Config          `json:"-"`
    TLSTimeout     float64              `json:"tls_timeout,omitempty"`
    TLSMap         bool                 `json:"-"`
    Advertise      string               `json:"advertise,omitempty"`
    ConnectRetries int                  `json:"connect_retries,omitempty"`
    Gateways       []*RemoteGatewayOpts `json:"gateways,omitempty"`
    RejectUnknown  bool                 `json:"reject_unknown,omitempty"`
    // contains filtered or unexported fields

GatewayOpts are options for gateways.

type GatewayStat Uses

type GatewayStat struct {
    ID         uint64    `json:"gwid"`
    Name       string    `json:"name"`
    Sent       DataStats `json:"sent"`
    Received   DataStats `json:"received"`
    NumInbound int       `json:"inbound_connections"`

type Info Uses

type Info struct {
    ID                string   `json:"server_id"`
    Version           string   `json:"version"`
    Proto             int      `json:"proto"`
    GitCommit         string   `json:"git_commit,omitempty"`
    GoVersion         string   `json:"go"`
    Host              string   `json:"host"`
    Port              int      `json:"port"`
    AuthRequired      bool     `json:"auth_required,omitempty"`
    TLSRequired       bool     `json:"tls_required,omitempty"`
    TLSVerify         bool     `json:"tls_verify,omitempty"`
    MaxPayload        int32    `json:"max_payload"`
    IP                string   `json:"ip,omitempty"`
    CID               uint64   `json:"client_id,omitempty"`
    Nonce             string   `json:"nonce,omitempty"`
    Cluster           string   `json:"cluster,omitempty"`
    ClientConnectURLs []string `json:"connect_urls,omitempty"` // Contains URLs a client can connect to.

    // Route Specific
    Import *SubjectPermission `json:"import,omitempty"`
    Export *SubjectPermission `json:"export,omitempty"`

    // Gateways Specific
    Gateway           string   `json:"gateway,omitempty"`             // Name of the origin Gateway (sent by gateway's INFO)
    GatewayURLs       []string `json:"gateway_urls,omitempty"`        // Gateway URLs in the originating cluster (sent by gateway's INFO)
    GatewayURL        string   `json:"gateway_url,omitempty"`         // Gateway URL on that server (sent by route's INFO)
    GatewayCmd        byte     `json:"gateway_cmd,omitempty"`         // Command code for the receiving server to know what to do
    GatewayCmdPayload []byte   `json:"gateway_cmd_payload,omitempty"` // Command payload when needed

    // LeafNode Specific
    LeafNodeURLs []string `json:"leafnode_urls,omitempty"` // LeafNode URLs that the server can reconnect to.

Info is the information sent to clients, routes, gateways, and leaf nodes, to help them understand information about this server.

type LeafNodeOpts Uses

type LeafNodeOpts struct {
    Host              string            `json:"addr,omitempty"`
    Port              int               `json:"port,omitempty"`
    Username          string            `json:"-"`
    Password          string            `json:"-"`
    AuthTimeout       float64           `json:"auth_timeout,omitempty"`
    TLSConfig         *tls.Config       `json:"-"`
    TLSTimeout        float64           `json:"tls_timeout,omitempty"`
    TLSMap            bool              `json:"-"`
    Remotes           []*RemoteLeafOpts `json:"remotes,omitempty"`
    Advertise         string            `json:"-"`
    NoAdvertise       bool              `json:"-"`
    ReconnectInterval time.Duration     `json:"-"`
    // contains filtered or unexported fields

LeafNodeOpts are options for a given server to accept leaf node connections and/or connect to a remote cluster.

type Logger Uses

type Logger interface {

    // Log a notice statement
    Noticef(format string, v ...interface{})

    // Log a warning statement
    Warnf(format string, v ...interface{})

    // Log a fatal error
    Fatalf(format string, v ...interface{})

    // Log an error
    Errorf(format string, v ...interface{})

    // Log a debug statement
    Debugf(format string, v ...interface{})

    // Log a trace statement
    Tracef(format string, v ...interface{})

Logger interface of the NATS Server

type MemAccResolver Uses

type MemAccResolver struct {
    // contains filtered or unexported fields

Mostly for testing.

func (*MemAccResolver) Fetch Uses

func (m *MemAccResolver) Fetch(name string) (string, error)

Fetch will fetch the account jwt claims from the internal sync.Map.

func (*MemAccResolver) Store Uses

func (m *MemAccResolver) Store(name, jwt string) error

Store will store the account jwt claims in the internal sync.Map.

type NkeyUser Uses

type NkeyUser struct {
    Nkey        string       `json:"user"`
    Permissions *Permissions `json:"permissions,omitempty"`
    Account     *Account     `json:"account,omitempty"`
    SigningKey  string       `json:"signing_key,omitempty"`

NkeyUser is for multiple nkey based users

type Options Uses

type Options struct {
    ConfigFile       string        `json:"-"`
    Host             string        `json:"addr"`
    Port             int           `json:"port"`
    ClientAdvertise  string        `json:"-"`
    Trace            bool          `json:"-"`
    Debug            bool          `json:"-"`
    NoLog            bool          `json:"-"`
    NoSigs           bool          `json:"-"`
    Logtime          bool          `json:"-"`
    MaxConn          int           `json:"max_connections"`
    MaxSubs          int           `json:"max_subscriptions,omitempty"`
    Nkeys            []*NkeyUser   `json:"-"`
    Users            []*User       `json:"-"`
    Accounts         []*Account    `json:"-"`
    SystemAccount    string        `json:"-"`
    AllowNewAccounts bool          `json:"-"`
    Username         string        `json:"-"`
    Password         string        `json:"-"`
    Authorization    string        `json:"-"`
    PingInterval     time.Duration `json:"ping_interval"`
    MaxPingsOut      int           `json:"ping_max"`
    HTTPHost         string        `json:"http_host"`
    HTTPPort         int           `json:"http_port"`
    HTTPSPort        int           `json:"https_port"`
    AuthTimeout      float64       `json:"auth_timeout"`
    MaxControlLine   int32         `json:"max_control_line"`
    MaxPayload       int32         `json:"max_payload"`
    MaxPending       int64         `json:"max_pending"`
    Cluster          ClusterOpts   `json:"cluster,omitempty"`
    Gateway          GatewayOpts   `json:"gateway,omitempty"`
    LeafNode         LeafNodeOpts  `json:"leaf_node,omitempty"`
    ProfPort         int           `json:"-"`
    PidFile          string        `json:"-"`
    PortsFileDir     string        `json:"-"`
    LogFile          string        `json:"-"`
    Syslog           bool          `json:"-"`
    RemoteSyslog     string        `json:"-"`
    Routes           []*url.URL    `json:"-"`
    RoutesStr        string        `json:"-"`
    TLSTimeout       float64       `json:"tls_timeout"`
    TLS              bool          `json:"-"`
    TLSVerify        bool          `json:"-"`
    TLSMap           bool          `json:"-"`
    TLSCert          string        `json:"-"`
    TLSKey           string        `json:"-"`
    TLSCaCert        string        `json:"-"`
    TLSConfig        *tls.Config   `json:"-"`
    WriteDeadline    time.Duration `json:"-"`
    MaxClosedClients int           `json:"-"`
    LameDuckDuration time.Duration `json:"-"`

    // Operating a trusted NATS server
    TrustedKeys      []string              `json:"-"`
    TrustedOperators []*jwt.OperatorClaims `json:"-"`
    AccountResolver  AccountResolver       `json:"-"`

    CustomClientAuthentication Authentication `json:"-"`
    CustomRouterAuthentication Authentication `json:"-"`

    // CheckConfig configuration file syntax test was successful and exit.
    CheckConfig bool `json:"-"`
    // contains filtered or unexported fields

Options block for gnatsd server.

var FlagSnapshot *Options

FlagSnapshot captures the server options as specified by CLI flags at startup. This should not be modified once the server has started.

func ConfigureOptions Uses

func ConfigureOptions(fs *flag.FlagSet, args []string, printVersion, printHelp, printTLSHelp func()) (*Options, error)

ConfigureOptions accepts a flag set and augment it with NATS Server specific flags. On success, an options structure is returned configured based on the selected flags and/or configuration file. The command line options take precedence to the ones in the configuration file.

func MergeOptions Uses

func MergeOptions(fileOpts, flagOpts *Options) *Options

MergeOptions will merge two options giving preference to the flagOpts if the item is present.

func ProcessConfigFile Uses

func ProcessConfigFile(configFile string) (*Options, error)

ProcessConfigFile processes a configuration file. FIXME(dlc): A bit hacky

func (*Options) Clone Uses

func (o *Options) Clone() *Options

Clone performs a deep copy of the Options struct, returning a new clone with all values copied.

func (*Options) ProcessConfigFile Uses

func (o *Options) ProcessConfigFile(configFile string) error

ProcessConfigFile updates the Options structure with options present in the given configuration file. This version is convenient if one wants to set some default options and then override them with what is in the config file. For instance, this version allows you to do something such as:

opts := &Options{Debug: true} opts.ProcessConfigFile(myConfigFile)

If the config file contains "debug: false", after this call, opts.Debug would really be false. It would be impossible to achieve that with the non receiver ProcessConfigFile() version, since one would not know after the call if "debug" was not present or was present but set to false.

type Permissions Uses

type Permissions struct {
    Publish   *SubjectPermission `json:"publish"`
    Subscribe *SubjectPermission `json:"subscribe"`

Permissions are the allowed subjects on a per publish or subscribe basis.

type Ports Uses

type Ports struct {
    Nats       []string `json:"nats,omitempty"`
    Monitoring []string `json:"monitoring,omitempty"`
    Cluster    []string `json:"cluster,omitempty"`
    Profile    []string `json:"profile,omitempty"`

Ports describes URLs that the server can be contacted in

type RemoteGatewayOpts Uses

type RemoteGatewayOpts struct {
    Name       string      `json:"name"`
    TLSConfig  *tls.Config `json:"-"`
    TLSTimeout float64     `json:"tls_timeout,omitempty"`
    URLs       []*url.URL  `json:"urls,omitempty"`

RemoteGatewayOpts are options for connecting to a remote gateway

type RemoteLeafOpts Uses

type RemoteLeafOpts struct {
    LocalAccount string      `json:"local_account,omitempty"`
    URL          *url.URL    `json:"url,omitempty"`
    Credentials  string      `json:"-"`
    TLS          bool        `json:"-"`
    TLSConfig    *tls.Config `json:"-"`
    TLSTimeout   float64     `json:"tls_timeout,omitempty"`

RemoteLeafOpts are options for connecting to a remote server as a leaf node.

type RouteInfo Uses

type RouteInfo struct {
    Rid          uint64             `json:"rid"`
    RemoteID     string             `json:"remote_id"`
    DidSolicit   bool               `json:"did_solicit"`
    IsConfigured bool               `json:"is_configured"`
    IP           string             `json:"ip"`
    Port         int                `json:"port"`
    Import       *SubjectPermission `json:"import,omitempty"`
    Export       *SubjectPermission `json:"export,omitempty"`
    Pending      int                `json:"pending_size"`
    InMsgs       int64              `json:"in_msgs"`
    OutMsgs      int64              `json:"out_msgs"`
    InBytes      int64              `json:"in_bytes"`
    OutBytes     int64              `json:"out_bytes"`
    NumSubs      uint32             `json:"subscriptions"`
    Subs         []string           `json:"subscriptions_list,omitempty"`

RouteInfo has detailed information on a per connection basis.

type RoutePermissions Uses

type RoutePermissions struct {
    Import *SubjectPermission `json:"import"`
    Export *SubjectPermission `json:"export"`

RoutePermissions are similar to user permissions but describe what a server can import/export from and to another server.

type RouteStat Uses

type RouteStat struct {
    ID       uint64    `json:"rid"`
    Sent     DataStats `json:"sent"`
    Received DataStats `json:"received"`
    Pending  int       `json:"pending"`

type RouteType Uses

type RouteType int

RouteType designates the router type

const (
    // This route we learned from speaking to other routes.
    Implicit RouteType = iota
    // This route was explicitly configured.

Type of Route

type Routez Uses

type Routez struct {
    ID        string             `json:"server_id"`
    Now       time.Time          `json:"now"`
    Import    *SubjectPermission `json:"import,omitempty"`
    Export    *SubjectPermission `json:"export,omitempty"`
    NumRoutes int                `json:"num_routes"`
    Routes    []*RouteInfo       `json:"routes"`

Routez represents detailed information on current client connections.

type RoutezOptions Uses

type RoutezOptions struct {
    // Subscriptions indicates that Routez will return a route's subscriptions
    Subscriptions bool `json:"subscriptions"`

RoutezOptions are options passed to Routez

type Server Uses

type Server struct {
    // contains filtered or unexported fields

Server is our main struct.

func New Uses

func New(opts *Options) *Server

DEPRECATED: Use NewServer(opts) New will setup a new server struct after parsing the options.

func NewServer Uses

func NewServer(opts *Options) (*Server, error)

NewServer will setup a new server struct after parsing the options. Could return an error if options can not be validated.

func (*Server) AcceptLoop Uses

func (s *Server) AcceptLoop(clr chan struct{})

AcceptLoop is exported for easier testing.

func (*Server) AccountResolver Uses

func (s *Server) AccountResolver() AccountResolver

AccountResolver returns the registered account resolver.

func (*Server) Addr Uses

func (s *Server) Addr() net.Addr

Addr will return the net.Addr object for the current listener.

func (*Server) ClusterAddr Uses

func (s *Server) ClusterAddr() *net.TCPAddr

ClusterAddr returns the net.Addr object for the route listener.

func (*Server) ConfigTime Uses

func (s *Server) ConfigTime() time.Time

ConfigTime will report the last time the server configuration was loaded.

func (*Server) ConfigureLogger Uses

func (s *Server) ConfigureLogger()

ConfigureLogger configures and sets the logger for the server.

func (*Server) Connz Uses

func (s *Server) Connz(opts *ConnzOptions) (*Connz, error)

Connz returns a Connz struct containing inormation about connections.

func (*Server) Debugf Uses

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

Debugf logs a debug statement

func (*Server) Errorf Uses

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

Errorf logs an error

func (*Server) EventsEnabled Uses

func (s *Server) EventsEnabled() bool

EventsEnabled will report if the server has internal events enabled via a defined system account.

func (*Server) Fatalf Uses

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

Fatalf logs a fatal error

func (*Server) GatewayAddr Uses

func (s *Server) GatewayAddr() *net.TCPAddr

GatewayAddr returns the net.Addr object for the gateway listener.

func (*Server) GetClient Uses

func (s *Server) GetClient(cid uint64) *client

GetClient will return the client associated with cid.

func (*Server) GetLeafNode Uses

func (s *Server) GetLeafNode(cid uint64) *client

func (*Server) HTTPHandler Uses

func (s *Server) HTTPHandler() http.Handler

HTTPHandler returns the http.Handler object used to handle monitoring endpoints. It will return nil if the server is not configured for monitoring, or if the server has not been started yet (Server.Start()).

func (*Server) HandleConnz Uses

func (s *Server) HandleConnz(w http.ResponseWriter, r *http.Request)

HandleConnz process HTTP requests for connection information.

func (*Server) HandleRoot Uses

func (s *Server) HandleRoot(w http.ResponseWriter, r *http.Request)

HandleRoot will show basic info and links to others handlers.

func (*Server) HandleRoutez Uses

func (s *Server) HandleRoutez(w http.ResponseWriter, r *http.Request)

HandleRoutez process HTTP requests for route information.

func (*Server) HandleStacksz Uses

func (s *Server) HandleStacksz(w http.ResponseWriter, r *http.Request)

HandleStacksz processes HTTP requests for getting stacks

func (*Server) HandleSubsz Uses

func (s *Server) HandleSubsz(w http.ResponseWriter, r *http.Request)

HandleSubsz processes HTTP requests for subjects stats.

func (*Server) HandleVarz Uses

func (s *Server) HandleVarz(w http.ResponseWriter, r *http.Request)

HandleVarz will process HTTP requests for server information.

func (*Server) ID Uses

func (s *Server) ID() string

ID returns the server's ID

func (*Server) LookupAccount Uses

func (s *Server) LookupAccount(name string) (*Account, error)

LookupAccount is a public function to return the account structure associated with name.

func (*Server) LookupOrRegisterAccount Uses

func (s *Server) LookupOrRegisterAccount(name string) (account *Account, isNew bool)

LookupOrRegisterAccount will return the given account if known or create a new entry.

func (*Server) MonitorAddr Uses

func (s *Server) MonitorAddr() *net.TCPAddr

MonitorAddr will return the net.Addr object for the monitoring listener.

func (*Server) NewAccountsAllowed Uses

func (s *Server) NewAccountsAllowed() bool

NewAccountsAllowed returns whether or not new accounts can be created on the fly.

func (*Server) NonceRequired Uses

func (s *Server) NonceRequired() bool

NonceRequired tells us if we should send a nonce.

func (*Server) Noticef Uses

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

Noticef logs a notice statement

func (*Server) NumActiveAccounts Uses

func (s *Server) NumActiveAccounts() int

NumActiveAccounts reports number of active accounts on this server.

func (*Server) NumClients Uses

func (s *Server) NumClients() int

NumClients will report the number of registered clients.

func (*Server) NumLeafNodes Uses

func (s *Server) NumLeafNodes() int

NumLeafNodes will report number of leaf node connections.

func (*Server) NumOutboundGateways Uses

func (s *Server) NumOutboundGateways() int

NumOutboundGateways is public here mostly for testing.

func (*Server) NumRemotes Uses

func (s *Server) NumRemotes() int

NumRemotes will report number of registered remotes.

func (*Server) NumRoutes Uses

func (s *Server) NumRoutes() int

NumRoutes will report the number of registered routes.

func (*Server) NumSlowConsumers Uses

func (s *Server) NumSlowConsumers() int64

NumSlowConsumers will report the number of slow consumers.

func (*Server) NumSubscriptions Uses

func (s *Server) NumSubscriptions() uint32

NumSubscriptions will report how many subscriptions are active.

func (*Server) PortsInfo Uses

func (s *Server) PortsInfo(maxWait time.Duration) *Ports

PortsInfo attempts to resolve all the ports. If after maxWait the ports are not resolved, it returns nil. Otherwise it returns a Ports struct describing ports where the server can be contacted

func (*Server) ProfilerAddr Uses

func (s *Server) ProfilerAddr() *net.TCPAddr

ProfilerAddr returns the net.Addr object for the route listener.

func (*Server) ReOpenLogFile Uses

func (s *Server) ReOpenLogFile()

ReOpenLogFile if the logger is a file based logger, close and re-open the file. This allows for file rotation by 'mv'ing the file then signaling the process to trigger this function.

func (*Server) ReadyForConnections Uses

func (s *Server) ReadyForConnections(dur time.Duration) bool

ReadyForConnections returns `true` if the server is ready to accept clients and, if routing is enabled, route connections. If after the duration `dur` the server is still not ready, returns `false`.

func (*Server) RegisterAccount Uses

func (s *Server) RegisterAccount(name string) (*Account, error)

RegisterAccount will register an account. The account must be new or this call will fail.

func (*Server) Reload Uses

func (s *Server) Reload() error

Reload reads the current configuration file and applies any supported changes. This returns an error if the server was not started with a config file or an option which doesn't support hot-swapping was changed.

func (*Server) Routez Uses

func (s *Server) Routez(routezOpts *RoutezOptions) (*Routez, error)

Routez returns a Routez struct containing inormation about routes.

func (*Server) SetAccountResolver Uses

func (s *Server) SetAccountResolver(ar AccountResolver)

SetAccountResolver will assign the account resolver.

func (*Server) SetLogger Uses

func (s *Server) SetLogger(logger Logger, debugFlag, traceFlag bool)

SetLogger sets the logger of the server

func (*Server) SetSystemAccount Uses

func (s *Server) SetSystemAccount(accName string) error

SetSystemAccount will set the internal system account. If root operators are present it will also check validity.

func (*Server) Shutdown Uses

func (s *Server) Shutdown()

Shutdown will shutdown the server instance by kicking out the AcceptLoop and closing all associated clients.

func (*Server) Start Uses

func (s *Server) Start()

Start up the server, this will block. Start via a Go routine if needed.

func (*Server) StartHTTPMonitoring Uses

func (s *Server) StartHTTPMonitoring()

StartHTTPMonitoring will enable the HTTP monitoring port. DEPRECATED: Should use StartMonitoring.

func (*Server) StartHTTPSMonitoring Uses

func (s *Server) StartHTTPSMonitoring()

StartHTTPSMonitoring will enable the HTTPS monitoring port. DEPRECATED: Should use StartMonitoring.

func (*Server) StartMonitoring Uses

func (s *Server) StartMonitoring() error

StartMonitoring starts the HTTP or HTTPs server if needed.

func (*Server) StartProfiler Uses

func (s *Server) StartProfiler()

StartProfiler is called to enable dynamic profiling.

func (*Server) StartRouting Uses

func (s *Server) StartRouting(clientListenReady chan struct{})

StartRouting will start the accept loop on the cluster host:port and will actively try to connect to listed routes.

func (*Server) Subsz Uses

func (s *Server) Subsz(opts *SubszOptions) (*Subsz, error)

Subsz returns a Subsz struct containing subjects statistics

func (*Server) SystemAccount Uses

func (s *Server) SystemAccount() *Account

SystemAccount returns the system account if set.

func (*Server) Tracef Uses

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

Tracef logs a trace statement

func (*Server) UpdateAccountClaims Uses

func (s *Server) UpdateAccountClaims(a *Account, ac *jwt.AccountClaims)

UpdateAccountClaims will call updateAccountClaims.

func (*Server) Varz Uses

func (s *Server) Varz(varzOpts *VarzOptions) (*Varz, error)

Varz returns a Varz struct containing the server information.

func (*Server) Warnf Uses

func (s *Server) Warnf(format string, v ...interface{})

Warnf logs a warning error

type ServerInfo Uses

type ServerInfo struct {
    Host    string    `json:"host"`
    ID      string    `json:"id"`
    Cluster string    `json:"cluster,omitempty"`
    Version string    `json:"ver"`
    Seq     uint64    `json:"seq"`
    Time    time.Time `json:"time"`

type ServerStats Uses

type ServerStats struct {
    Start            time.Time      `json:"start"`
    Mem              int64          `json:"mem"`
    Cores            int            `json:"cores"`
    CPU              float64        `json:"cpu"`
    Connections      int            `json:"connections"`
    TotalConnections uint64         `json:"total_connections"`
    ActiveAccounts   int            `json:"active_accounts"`
    NumSubs          uint32         `json:"subscriptions"`
    Sent             DataStats      `json:"sent"`
    Received         DataStats      `json:"received"`
    SlowConsumers    int64          `json:"slow_consumers"`
    Routes           []*RouteStat   `json:"routes,omitempty"`
    Gateways         []*GatewayStat `json:"gateways,omitempty"`

Various statistics we will periodically send out.

type ServerStatsMsg Uses

type ServerStatsMsg struct {
    Server ServerInfo  `json:"server"`
    Stats  ServerStats `json:"statsz"`

ServerStatsMsg is sent periodically with stats updates.

type SortOpt Uses

type SortOpt string

SortOpt is a helper type to sort clients

const (
    ByCid      SortOpt = "cid"        // By connection ID
    ByStart    SortOpt = "start"      // By connection start time, same as CID
    BySubs     SortOpt = "subs"       // By number of subscriptions
    ByPending  SortOpt = "pending"    // By amount of data in bytes waiting to be sent to client
    ByOutMsgs  SortOpt = "msgs_to"    // By number of messages sent
    ByInMsgs   SortOpt = "msgs_from"  // By number of messages received
    ByOutBytes SortOpt = "bytes_to"   // By amount of bytes sent
    ByInBytes  SortOpt = "bytes_from" // By amount of bytes received
    ByLast     SortOpt = "last"       // By the last activity
    ByIdle     SortOpt = "idle"       // By the amount of inactivity
    ByUptime   SortOpt = "uptime"     // By the amount of time connections exist
    ByStop     SortOpt = "stop"       // By the stop time for a closed connection
    ByReason   SortOpt = "reason"     // By the reason for a closed connection


Possible sort options

func (SortOpt) IsValid Uses

func (s SortOpt) IsValid() bool

IsValid determines if a sort option is valid

type SubDetail Uses

type SubDetail struct {
    Subject string `json:"subject"`
    Queue   string `json:"qgroup,omitempty"`
    Sid     string `json:"sid"`
    Msgs    int64  `json:"msgs"`
    Max     int64  `json:"max,omitempty"`
    Cid     uint64 `json:"cid"`

SubDetail is for verbose information for subscriptions.

type SubjectPermission Uses

type SubjectPermission struct {
    Allow []string `json:"allow,omitempty"`
    Deny  []string `json:"deny,omitempty"`

SubjectPermission is an individual allow and deny struct for publish and subscribe authorizations.

type Sublist Uses

type Sublist struct {
    // contains filtered or unexported fields

A Sublist stores and efficiently retrieves subscriptions.

func NewSublist Uses

func NewSublist() *Sublist

NewSublist will create a default sublist

func NewSublistNoCache Uses

func NewSublistNoCache() *Sublist

NewSublistNoCache will create a default sublist without caching enabled.

func (*Sublist) All Uses

func (s *Sublist) All(subs *[]*subscription)

Used to collect all subscriptions.

func (*Sublist) CacheCount Uses

func (s *Sublist) CacheCount() int

CacheCount returns the number of result sets in the cache.

func (*Sublist) CacheEnabled Uses

func (s *Sublist) CacheEnabled() bool

CacheEnabled returns whether or not caching is enabled for this sublist.

func (*Sublist) Count Uses

func (s *Sublist) Count() uint32

Count returns the number of subscriptions.

func (*Sublist) Insert Uses

func (s *Sublist) Insert(sub *subscription) error

Insert adds a subscription into the sublist

func (*Sublist) Match Uses

func (s *Sublist) Match(subject string) *SublistResult

Match will match all entries to the literal subject. It will return a set of results for both normal and queue subscribers.

func (*Sublist) Remove Uses

func (s *Sublist) Remove(sub *subscription) error

Remove will remove a subscription.

func (*Sublist) RemoveAllForClient Uses

func (s *Sublist) RemoveAllForClient(c *client)

RemoveAllForClient will remove all subscriptions for a given client.

func (*Sublist) RemoveBatch Uses

func (s *Sublist) RemoveBatch(subs []*subscription) error

RemoveBatch will remove a list of subscriptions.

func (*Sublist) Stats Uses

func (s *Sublist) Stats() *SublistStats

Stats will return a stats structure for the current state.

func (*Sublist) UpdateRemoteQSub Uses

func (s *Sublist) UpdateRemoteQSub(sub *subscription)

UpdateRemoteQSub should be called when we update the weight of an existing remote queue sub.

type SublistResult Uses

type SublistResult struct {
    // contains filtered or unexported fields

SublistResult is a result structure better optimized for queue subs.

type SublistStats Uses

type SublistStats struct {
    NumSubs      uint32  `json:"num_subscriptions"`
    NumCache     uint32  `json:"num_cache"`
    NumInserts   uint64  `json:"num_inserts"`
    NumRemoves   uint64  `json:"num_removes"`
    NumMatches   uint64  `json:"num_matches"`
    CacheHitRate float64 `json:"cache_hit_rate"`
    MaxFanout    uint32  `json:"max_fanout"`
    AvgFanout    float64 `json:"avg_fanout"`

SublistStats are public stats for the sublist

type Subsz Uses

type Subsz struct {
    Total  int         `json:"total"`
    Offset int         `json:"offset"`
    Limit  int         `json:"limit"`
    Subs   []SubDetail `json:"subscriptions_list,omitempty"`

Subsz represents detail information on current connections.

type SubszOptions Uses

type SubszOptions struct {
    // Offset is used for pagination. Subsz() only returns connections starting at this
    // offset from the global results.
    Offset int `json:"offset"`

    // Limit is the maximum number of subscriptions that should be returned by Subsz().
    Limit int `json:"limit"`

    // Subscriptions indicates if subscriptions should be included in the results.
    Subscriptions bool `json:"subscriptions"`

    // Test the list against this subject. Needs to be literal since it signifies a publish subject.
    // We will only return subscriptions that would match if a message was sent to this subject.
    Test string `json:"test,omitempty"`

SubszOptions are the options passed to Subsz. As of now, there are no options defined.

type TLSConfigOpts Uses

type TLSConfigOpts struct {
    CertFile         string
    KeyFile          string
    CaFile           string
    Verify           bool
    Insecure         bool
    Map              bool
    Timeout          float64
    Ciphers          []uint16
    CurvePreferences []tls.CurveID

TLSConfigOpts holds the parsed tls config information, used with flag parsing

type URLAccResolver Uses

type URLAccResolver struct {
    // contains filtered or unexported fields

URLAccResolver implements an http fetcher.

func NewURLAccResolver Uses

func NewURLAccResolver(url string) (*URLAccResolver, error)

NewURLAccResolver returns a new resolver for the given base URL.

func (*URLAccResolver) Fetch Uses

func (ur *URLAccResolver) Fetch(name string) (string, error)

Fetch will fetch the account jwt claims from the base url, appending the account name onto the end.

func (*URLAccResolver) Store Uses

func (ur *URLAccResolver) Store(name, jwt string) error

Store is not implemented for URL Resolver.

type User Uses

type User struct {
    Username    string       `json:"user"`
    Password    string       `json:"password"`
    Permissions *Permissions `json:"permissions,omitempty"`
    Account     *Account     `json:"account,omitempty"`

User is for multiple accounts/users.

type Varz Uses

type Varz struct {
    Port             int               `json:"port"`
    MaxPayload       int               `json:"max_payload"`
    Start            time.Time         `json:"start"`
    Now              time.Time         `json:"now"`
    Uptime           string            `json:"uptime"`
    Mem              int64             `json:"mem"`
    Cores            int               `json:"cores"`
    CPU              float64           `json:"cpu"`
    Connections      int               `json:"connections"`
    TotalConnections uint64            `json:"total_connections"`
    Routes           int               `json:"routes"`
    Remotes          int               `json:"remotes"`
    InMsgs           int64             `json:"in_msgs"`
    OutMsgs          int64             `json:"out_msgs"`
    InBytes          int64             `json:"in_bytes"`
    OutBytes         int64             `json:"out_bytes"`
    SlowConsumers    int64             `json:"slow_consumers"`
    MaxPending       int64             `json:"max_pending"`
    WriteDeadline    time.Duration     `json:"write_deadline"`
    Subscriptions    uint32            `json:"subscriptions"`
    HTTPReqStats     map[string]uint64 `json:"http_req_stats"`
    ConfigLoadTime   time.Time         `json:"config_load_time"`

Varz will output server information on the monitoring port at /varz.

type VarzOptions Uses

type VarzOptions struct{}

VarzOptions are the options passed to Varz(). Currently, there are no options defined.



Package server imports 37 packages (graph) and is imported by 145 packages. Updated 2019-04-23. Refresh now. Tools for package owners.