natssysclient

package module
v0.1.1 Latest Latest
Warning

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

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

README

NATS System API Client

License Go Reference Build Status Go Report Card

NATS System API Client exposes APIs to interact with the NATS server monitoring endpoints.

Note: All response structures are compatible with the NATS server v2.10.23 and will be updated to support future additions.

Installation

go get github.com/synadia-io/orbit.go/natssysclient

Usage

Each endpoint can be used to get information from either a specific server (by server ID) or from the whole cluster. When pinging the cluster, the client will wait for a response from each server in the cluster and return the aggregated information.

The client can be configured to wait for a specific timeout for each server to respond (scatter-gather) or a specific number of servers to respond.

// To use the system client, you need to set up a NATS connection using the system account.
nc, err := nats.Connect(nats.DefaultURL, nats.UserInfo("admin", "s3cr3t!"))
if err != nil {
    // handle error
}
defer nc.Close()

sys, err := natssysclient.NewSysClient(nc)
if err != nil {
    // handle error
}

ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

// get VARZ from a specific server
varz, err := sys.Varz(ctx, "server_id", natssysclient.VarzEventOptions{})
if err != nil {
    // handle error
}
fmt.Println(varz.Varz.Name)

// get VARZ from all servers
varzs, err := sys.VarzPing(ctx, natssysclient.VarzEventOptions{})
if err != nil {
    // handle error
}
for _, v := range varzs {
    fmt.Println(v.Varz.Name)
}
Configuration

When creating the System API Client, you can configure the following options:

  • StallTimer: Utilized when pinging the cluster, sets the stall timer, aborting the request if a server does not respond within the specified time.
  • ServerCount: Utilized when pinging the cluster, sets the number of servers to wait for a response from.

The above options are not exclusive, you can set both to wait for a specific number of servers to respond within a specific time frame.

Documentation

Index

Constants

View Source
const (
	// DefaultRequestTimeout is the default timeout for requests, used when the provided context does not have a deadline.
	DefaultRequestTimeout = 10 * time.Second

	// DefaultStall is the default interval for subsequent responses when pinging the cluster.
	DefaultStall = 300 * time.Millisecond
)
View Source
const (
	// ConnOpen filters on open clients.
	ConnOpen = ConnState(iota)
	// ConnClosed filters on closed clients.
	ConnClosed
	// ConnAll returns all clients.
	ConnAll
)

Variables

View Source
var (
	ErrValidation      = errors.New("validation error")
	ErrInvalidServerID = errors.New("sever with given ID does not exist")
	ErrRequest         = errors.New("error sending API request")
	ErrPingResponse    = errors.New("error receiving ping response")
)

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Code        int    `json:"code"`
	ErrCode     uint16 `json:"err_code,omitempty"`
	Description string `json:"description,omitempty"`
}

APIError is a generic error response from nats-server.

type AccountDetail

type AccountDetail struct {
	Name string `json:"name"`
	Id   string `json:"id"`
	JetStreamStats
	Streams []StreamDetail `json:"stream_detail,omitempty"`
}

AccountDetail contains the details for an account.

type ClusterOptsVarz

type ClusterOptsVarz struct {
	Name        string   `json:"name,omitempty"`
	Host        string   `json:"addr,omitempty"`
	Port        int      `json:"cluster_port,omitempty"`
	AuthTimeout float64  `json:"auth_timeout,omitempty"`
	URLs        []string `json:"urls,omitempty"`
	TLSTimeout  float64  `json:"tls_timeout,omitempty"`
	TLSRequired bool     `json:"tls_required,omitempty"`
	TLSVerify   bool     `json:"tls_verify,omitempty"`
	PoolSize    int      `json:"pool_size,omitempty"`
}

ClusterOptsVarz contains monitoring cluster information

type ConnInfo

type ConnInfo struct {
	Cid            uint64         `json:"cid"`
	Kind           string         `json:"kind,omitempty"`
	Type           string         `json:"type,omitempty"`
	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"`
	TLSPeerCerts   []*TLSPeerCert `json:"tls_peer_certs,omitempty"`
	TLSFirst       bool           `json:"tls_first,omitempty"`
	AuthorizedUser string         `json:"authorized_user,omitempty"`
	Account        string         `json:"account,omitempty"`
	Subs           []string       `json:"subscriptions_list,omitempty"`
	SubsDetail     []SubDetail    `json:"subscriptions_list_detail,omitempty"`
	JWT            string         `json:"jwt,omitempty"`
	IssuerKey      string         `json:"issuer_key,omitempty"`
	NameTag        string         `json:"name_tag,omitempty"`
	Tags           jwt.TagList    `json:"tags,omitempty"`
	MQTTClient     string         `json:"mqtt_client,omitempty"` // This is the MQTT client id
}

ConnInfo has detailed information on a per connection basis.

type ConnState

type ConnState int

ConnState represents the state of a connection.

type Connz

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 contains the connection details.

type ConnzEventOptions

type ConnzEventOptions struct {
	ConnzOptions
	EventFilterOptions
}

ConnzEventOptions are the options for the Connz request.

type ConnzOptions

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"`

	// SubscriptionsDetail indicates if subscription details should be included in the results
	SubscriptionsDetail bool `json:"subscriptions_detail"`

	// 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 for this explicit client connection based on the MQTT client ID
	MQTTClient string `json:"mqtt_client"`

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

	// Filter by username.
	User string `json:"user"`

	// Filter by account.
	Account string `json:"acc"`

	// Filter by subject interest
	FilterSubject string `json:"filter_subject"`
}

ConnzOptions are the options for the Connz request.

type ConnzResp

type ConnzResp struct {
	Server ServerInfo `json:"server"`
	Connz  Connz      `json:"data"`
	Error  APIError   `json:"error,omitempty"`
}

ConnzResp is the response from a Connz request.

type DataStats

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 DenyRules

type DenyRules struct {
	Exports []string `json:"exports,omitempty"`
	Imports []string `json:"imports,omitempty"`
}

DenyRules Contains lists of subjects not allowed to be imported/exported

type EventFilterOptions

type EventFilterOptions struct {
	Name    string   `json:"server_name,omitempty"` // filter by server name
	Cluster string   `json:"cluster,omitempty"`     // filter by cluster name
	Host    string   `json:"host,omitempty"`        // filter by host name
	Tags    []string `json:"tags,omitempty"`        // filter by tags (must match all tags)
	Domain  string   `json:"domain,omitempty"`      // filter by JS domain
}

Common filter options for system requests STATSZ VARZ SUBSZ CONNZ ROUTEZ GATEWAYZ LEAFZ

type GatewayOptsVarz

type GatewayOptsVarz struct {
	Name           string                  `json:"name,omitempty"`
	Host           string                  `json:"host,omitempty"`
	Port           int                     `json:"port,omitempty"`
	AuthTimeout    float64                 `json:"auth_timeout,omitempty"`
	TLSTimeout     float64                 `json:"tls_timeout,omitempty"`
	TLSRequired    bool                    `json:"tls_required,omitempty"`
	TLSVerify      bool                    `json:"tls_verify,omitempty"`
	Advertise      string                  `json:"advertise,omitempty"`
	ConnectRetries int                     `json:"connect_retries,omitempty"`
	Gateways       []RemoteGatewayOptsVarz `json:"gateways,omitempty"`
	RejectUnknown  bool                    `json:"reject_unknown,omitempty"` // config got renamed to reject_unknown_cluster
}

GatewayOptsVarz contains monitoring gateway information

type GatewayStat

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

GatewayStat holds gateway statistics.

type HealthZErrorType

type HealthZErrorType int

HealthZErrorType is the type of error returned by the Healthz request.

const (
	HealthzErrorConn HealthZErrorType = iota
	HealthzErrorBadRequest
	HealthzErrorJetStream
	HealthzErrorAccount
	HealthzErrorStream
	HealthzErrorConsumer
)

type Healthz

type Healthz struct {
	Status     string         `json:"status"`
	StatusCode int            `json:"status_code,omitempty"`
	Error      string         `json:"error,omitempty"`
	Errors     []HealthzError `json:"errors,omitempty"`
}

Healthz is the health status of the server.

type HealthzError

type HealthzError struct {
	Type     HealthZErrorType `json:"type"`
	Account  string           `json:"account,omitempty"`
	Stream   string           `json:"stream,omitempty"`
	Consumer string           `json:"consumer,omitempty"`
	Error    string           `json:"error,omitempty"`
}

HealthzError is an error returned by the Healthz request.

type HealthzOptions

type HealthzOptions struct {
	// If set to true, only check if the server is connected to JetStream (without checking assets).
	JSEnabledOnly bool `json:"js-enabled-only,omitempty"`

	// If set to true, only check if the server is healthy (without checking JetStream).
	JSServerOnly bool `json:"js-server-only,omitempty"`

	// Used to check the health of a specific account. Must be used when requesting stream or consumer health.
	Account string `json:"account,omitempty"`

	// Used to check the health of a specific stream.
	Stream string `json:"stream,omitempty"`

	// Used to check the health of a specific consumer.
	Consumer string `json:"consumer,omitempty"`

	// If set to true, return detailed information about errors (if any).
	Details bool `json:"details,omitempty"`
}

HealthzOptions are options passed to Healthz.

type HealthzResp

type HealthzResp struct {
	Server  ServerInfo `json:"server"`
	Healthz Healthz    `json:"data"`
	Error   APIError   `json:"error,omitempty"`
}

HealthzResp is the response from the Healthz request.

type JSInfo

type JSInfo struct {
	ID       string          `json:"server_id"`
	Now      time.Time       `json:"now"`
	Disabled bool            `json:"disabled,omitempty"`
	Config   JetStreamConfig `json:"config,omitempty"`
	JetStreamStats
	Streams   int              `json:"streams"`
	Consumers int              `json:"consumers"`
	Messages  uint64           `json:"messages"`
	Bytes     uint64           `json:"bytes"`
	Meta      *MetaClusterInfo `json:"meta_cluster,omitempty"`

	// aggregate raft info
	AccountDetails []*AccountDetail `json:"account_details,omitempty"`
}

type JSZResp

type JSZResp struct {
	Server ServerInfo `json:"server"`
	JSInfo JSInfo     `json:"data"`
	Error  APIError   `json:"error,omitempty"`
}

JSZResp is the response from the JSZ request.

type JetStreamAPIStats

type JetStreamAPIStats struct {
	Total    uint64 `json:"total"`
	Errors   uint64 `json:"errors"`
	Inflight uint64 `json:"inflight,omitempty"`
}

type JetStreamConfig

type JetStreamConfig struct {
	MaxMemory    int64         `json:"max_memory"`
	MaxStore     int64         `json:"max_storage"`
	StoreDir     string        `json:"store_dir,omitempty"`
	SyncInterval time.Duration `json:"sync_interval,omitempty"`
	SyncAlways   bool          `json:"sync_always,omitempty"`
	Domain       string        `json:"domain,omitempty"`
	CompressOK   bool          `json:"compress_ok,omitempty"`
	UniqueTag    string        `json:"unique_tag,omitempty"`
}

JetStreamConfig determines this server's configuration. MaxMemory and MaxStore are in bytes.

type JetStreamStats

type JetStreamStats struct {
	Memory         uint64            `json:"memory"`
	Store          uint64            `json:"storage"`
	ReservedMemory uint64            `json:"reserved_memory"`
	ReservedStore  uint64            `json:"reserved_storage"`
	Accounts       int               `json:"accounts"`
	HAAssets       int               `json:"ha_assets"`
	API            JetStreamAPIStats `json:"api"`
}

Statistics about JetStream for this server.

type JetStreamVarz

type JetStreamVarz struct {
	Config *JetStreamConfig `json:"config,omitempty"`
	Stats  *JetStreamStats  `json:"stats,omitempty"`
	Meta   *MetaClusterInfo `json:"meta,omitempty"`
}

JetStreamVarz contains basic runtime information about jetstream

type JszEventOptions

type JszEventOptions struct {
	JszOptions
	EventFilterOptions
}

JsEventOptions are the options for the JSZ request.

type JszOptions

type JszOptions struct {
	// Account to filter on.
	Account string `json:"account,omitempty"`

	// Include account specific JetStream information
	Accounts bool `json:"accounts,omitempty"`

	// Include streams. When set, implies Accounts is set.
	Streams bool `json:"streams,omitempty"`

	// Include consumers. When set, implies Streams is set.
	Consumer bool `json:"consumer,omitempty"`

	// When stream or consumer are requested, include their respective configuration.
	Config bool `json:"config,omitempty"`

	// Only the leader responds.
	LeaderOnly bool `json:"leader_only,omitempty"`

	// Pagination offset.
	Offset int `json:"offset,omitempty"`

	// Pagination limit.
	Limit int `json:"limit,omitempty"`

	// Include detailed information about the raft group.
	RaftGroups bool `json:"raft,omitempty"`

	// Returns stream details only for the stream in which the server is the leader for that stream.
	StreamLeaderOnly bool `json:"stream_leader_only,omitempty"`
}

JszOptions are the options for the JSZ request.

type LeafNodeOptsVarz

type LeafNodeOptsVarz struct {
	Host              string               `json:"host,omitempty"`
	Port              int                  `json:"port,omitempty"`
	AuthTimeout       float64              `json:"auth_timeout,omitempty"`
	TLSTimeout        float64              `json:"tls_timeout,omitempty"`
	TLSRequired       bool                 `json:"tls_required,omitempty"`
	TLSVerify         bool                 `json:"tls_verify,omitempty"`
	Remotes           []RemoteLeafOptsVarz `json:"remotes,omitempty"`
	TLSOCSPPeerVerify bool                 `json:"tls_ocsp_peer_verify,omitempty"`
}

LeafNodeOptsVarz contains monitoring leaf node information

type MQTTOptsVarz

type MQTTOptsVarz struct {
	Host              string        `json:"host,omitempty"`
	Port              int           `json:"port,omitempty"`
	NoAuthUser        string        `json:"no_auth_user,omitempty"`
	AuthTimeout       float64       `json:"auth_timeout,omitempty"`
	TLSMap            bool          `json:"tls_map,omitempty"`
	TLSTimeout        float64       `json:"tls_timeout,omitempty"`
	TLSPinnedCerts    []string      `json:"tls_pinned_certs,omitempty"`
	JsDomain          string        `json:"js_domain,omitempty"`
	AckWait           time.Duration `json:"ack_wait,omitempty"`
	MaxAckPending     uint16        `json:"max_ack_pending,omitempty"`
	TLSOCSPPeerVerify bool          `json:"tls_ocsp_peer_verify,omitempty"`
}

MQTTOptsVarz contains monitoring MQTT information

type MetaClusterInfo

type MetaClusterInfo struct {
	Name     string      `json:"name,omitempty"`
	Leader   string      `json:"leader,omitempty"`
	Peer     string      `json:"peer,omitempty"`
	Replicas []*PeerInfo `json:"replicas,omitempty"`
	Size     int         `json:"cluster_size"`
	Pending  int         `json:"pending"`
}

MetaClusterInfo shows information about the meta group.

type OCSPResponseCacheVarz

type OCSPResponseCacheVarz struct {
	Type      string `json:"cache_type,omitempty"`
	Hits      int64  `json:"cache_hits,omitempty"`
	Misses    int64  `json:"cache_misses,omitempty"`
	Responses int64  `json:"cached_responses,omitempty"`
	Revokes   int64  `json:"cached_revoked_responses,omitempty"`
	Goods     int64  `json:"cached_good_responses,omitempty"`
	Unknowns  int64  `json:"cached_unknown_responses,omitempty"`
}

type PeerInfo

type PeerInfo struct {
	Name    string        `json:"name"`
	Current bool          `json:"current"`
	Offline bool          `json:"offline,omitempty"`
	Active  time.Duration `json:"active"`
	Lag     uint64        `json:"lag,omitempty"`
	Peer    string        `json:"peer"`
}

PeerInfo shows information about all the peers in the cluster that are supporting the stream or consumer.

type RaftGroupDetail

type RaftGroupDetail struct {
	Name      string `json:"name"`
	RaftGroup string `json:"raft_group,omitempty"`
}

RaftGroupDetail contains the details for a raft group.

type RemoteGatewayOptsVarz

type RemoteGatewayOptsVarz struct {
	Name       string   `json:"name"`
	TLSTimeout float64  `json:"tls_timeout,omitempty"`
	URLs       []string `json:"urls,omitempty"`
}

RemoteGatewayOptsVarz contains monitoring remote gateway information

type RemoteLeafOptsVarz

type RemoteLeafOptsVarz struct {
	LocalAccount      string     `json:"local_account,omitempty"`
	TLSTimeout        float64    `json:"tls_timeout,omitempty"`
	URLs              []string   `json:"urls,omitempty"`
	Deny              *DenyRules `json:"deny,omitempty"`
	TLSOCSPPeerVerify bool       `json:"tls_ocsp_peer_verify,omitempty"`
}

RemoteLeafOptsVarz contains monitoring remote leaf node information

type RouteStat

type RouteStat struct {
	ID       uint64    `json:"rid"`
	Name     string    `json:"name,omitempty"`
	Sent     DataStats `json:"sent"`
	Received DataStats `json:"received"`
	Pending  int       `json:"pending"`
}

RouteStat holds route statistics.

type ServerInfo

type ServerInfo struct {
	Name      string    `json:"name"`
	Host      string    `json:"host"`
	ID        string    `json:"id"`
	Cluster   string    `json:"cluster,omitempty"`
	Domain    string    `json:"domain,omitempty"`
	Version   string    `json:"ver"`
	Tags      []string  `json:"tags,omitempty"`
	Seq       uint64    `json:"seq"`
	JetStream bool      `json:"jetstream"`
	Time      time.Time `json:"time"`
}

ServerInfo identifies remote servers.

type ServerStats

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"`
	ActiveServers    int            `json:"active_servers,omitempty"`
	JetStream        *JetStreamVarz `json:"jetstream,omitempty"`
}

ServerStats hold various statistics that we will periodically send out.

type ServerStatszResp

type ServerStatszResp struct {
	Server ServerInfo  `json:"server"`
	Statsz ServerStats `json:"statsz"`
	Error  APIError    `json:"error,omitempty"`
}

ServerStatszResp is the response from the server for the Statsz request.

type SlowConsumersStats

type SlowConsumersStats struct {
	Clients  uint64 `json:"clients"`
	Routes   uint64 `json:"routes"`
	Gateways uint64 `json:"gateways"`
	Leafs    uint64 `json:"leafs"`
}

SlowConsumersStats reports slow consumers stats.

type SortOpt

type SortOpt string

SortOpt is the type for sorting options.

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

type StatszEventOptions

type StatszEventOptions struct {
	EventFilterOptions
}

StatszEventOptions are options passed to Statsz

type StreamDetail

type StreamDetail struct {
	Name               string                   `json:"name"`
	Created            time.Time                `json:"created"`
	Cluster            *nats.ClusterInfo        `json:"cluster,omitempty"`
	Config             *nats.StreamConfig       `json:"config,omitempty"`
	State              nats.StreamState         `json:"state,omitempty"`
	Consumer           []*nats.ConsumerInfo     `json:"consumer_detail,omitempty"`
	Mirror             *nats.StreamSourceInfo   `json:"mirror,omitempty"`
	Sources            []*nats.StreamSourceInfo `json:"sources,omitempty"`
	RaftGroup          string                   `json:"stream_raft_group,omitempty"`
	ConsumerRaftGroups []*RaftGroupDetail       `json:"consumer_raft_groups,omitempty"`
}

StreamDetail contains the details for a stream.

type SubDetail

type SubDetail struct {
	Account string `json:"account,omitempty"`
	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 contains detailed information about a subscription.

type SublistStats

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 the statistics for the subscriptions list.

type Subsz

type Subsz struct {
	ID  string    `json:"server_id"`
	Now time.Time `json:"now"`
	*SublistStats
	Total  int         `json:"total"`
	Offset int         `json:"offset"`
	Limit  int         `json:"limit"`
	Subs   []SubDetail `json:"subscriptions_list,omitempty"`
}

Subsz is the server subscriptions data.

type SubszOptions

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 subscription details should be included in the results.
	Subscriptions bool `json:"subscriptions"`

	// Filter based on this account name.
	Account string `json:"account,omitempty"`

	// 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.

type SubszResp

type SubszResp struct {
	Server ServerInfo `json:"server"`
	Subsz  Subsz      `json:"data"`
	Error  APIError   `json:"error,omitempty"`
}

SubszResp is the response from the server subscriptions request.

type SysClientOpt

type SysClientOpt func(*sysClientOpts) error

SysClientOpt is a functional option for configuring the System client.

func ServerCount

func ServerCount(count int) SysClientOpt

ServerCount sets the maximum number of servers to wait for the response from. Setting this value is not mandatory since the stall timer can be used to short-circuit the request. If set, the value should represent the number of servers in the cluster (as seen by the connected server).

func StallTimer

func StallTimer(initialTimeout, interval time.Duration) SysClientOpt

StallTimer sets the interval for subsequent responses when pinging the cluster.

type System

type System struct {
	// contains filtered or unexported fields
}

System can be used to request monitoring data from the server.

func NewSysClient

func NewSysClient(nc *nats.Conn, opts ...SysClientOpt) (*System, error)

NewSysClient creates a new System client.

func (*System) Connz

func (s *System) Connz(ctx context.Context, id string, opts ConnzEventOptions) (*ConnzResp, error)

Connz returns server connection details.

func (*System) ConnzPing

func (s *System) ConnzPing(ctx context.Context, opts ConnzEventOptions) ([]ConnzResp, error)

ConnzPing returns server connection details for all servers.

func (*System) Healthz

func (s *System) Healthz(ctx context.Context, id string, opts HealthzOptions) (*HealthzResp, error)

Healthz checks server health status.

func (*System) HealthzPing

func (s *System) HealthzPing(ctx context.Context, opts HealthzOptions) ([]HealthzResp, error)

HealthzPing checks the health status of all servers.

func (*System) Jsz

func (s *System) Jsz(ctx context.Context, id string, opts JszEventOptions) (*JSZResp, error)

Jsz returns server jetstream details.

func (*System) JszPing

func (s *System) JszPing(ctx context.Context, opts JszEventOptions) ([]JSZResp, error)

JszPing returns server jetstream details for all servers.

func (*System) ServerStatsz

func (s *System) ServerStatsz(ctx context.Context, id string, opts StatszEventOptions) (*ServerStatszResp, error)

ServerStatsz returns server statistics for the Statsz structs.

func (*System) ServerStatszPing

func (s *System) ServerStatszPing(ctx context.Context, opts StatszEventOptions) ([]ServerStatszResp, error)

ServerStatszPing returns server statistics for the Statsz structs from all servers.

func (*System) ServerSubsz

func (s *System) ServerSubsz(ctx context.Context, id string, opts SubszOptions) (*SubszResp, error)

ServerSubsz returns server subscriptions data

func (*System) ServerSubszPing

func (s *System) ServerSubszPing(ctx context.Context, opts SubszOptions) ([]SubszResp, error)

ServerSubszPing returns server subscriptions data from all servers.

func (*System) Varz

func (s *System) Varz(ctx context.Context, id string, opts VarzEventOptions) (*VarzResp, error)

Varz returns general server information.

func (*System) VarzPing

func (s *System) VarzPing(ctx context.Context, opts VarzEventOptions) ([]VarzResp, error)

VarzPing returns general server information from all servers.

type TLSPeerCert

type TLSPeerCert struct {
	Subject          string `json:"subject,omitempty"`
	SubjectPKISha256 string `json:"spki_sha256,omitempty"`
	CertSha256       string `json:"cert_sha256,omitempty"`
}

TLSPeerCert contains basic information about a TLS peer certificate

type Varz

type Varz struct {
	ID                    string                 `json:"server_id"`
	Name                  string                 `json:"server_name"`
	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"`
	TLSOCSPPeerVerify     bool                   `json:"tls_ocsp_peer_verify,omitempty"`
	IP                    string                 `json:"ip,omitempty"`
	ClientConnectURLs     []string               `json:"connect_urls,omitempty"`
	WSConnectURLs         []string               `json:"ws_connect_urls,omitempty"`
	MaxConn               int                    `json:"max_connections"`
	MaxSubs               int                    `json:"max_subscriptions,omitempty"`
	PingInterval          time.Duration          `json:"ping_interval"`
	MaxPingsOut           int                    `json:"ping_max"`
	HTTPHost              string                 `json:"http_host"`
	HTTPPort              int                    `json:"http_port"`
	HTTPBasePath          string                 `json:"http_base_path"`
	HTTPSPort             int                    `json:"https_port"`
	AuthTimeout           float64                `json:"auth_timeout"`
	MaxControlLine        int32                  `json:"max_control_line"`
	MaxPayload            int                    `json:"max_payload"`
	MaxPending            int64                  `json:"max_pending"`
	Cluster               ClusterOptsVarz        `json:"cluster,omitempty"`
	Gateway               GatewayOptsVarz        `json:"gateway,omitempty"`
	LeafNode              LeafNodeOptsVarz       `json:"leaf,omitempty"`
	MQTT                  MQTTOptsVarz           `json:"mqtt,omitempty"`
	Websocket             WebsocketOptsVarz      `json:"websocket,omitempty"`
	JetStream             JetStreamVarz          `json:"jetstream,omitempty"`
	TLSTimeout            float64                `json:"tls_timeout"`
	WriteDeadline         time.Duration          `json:"write_deadline"`
	Start                 time.Time              `json:"start"`
	Now                   time.Time              `json:"now"`
	Uptime                string                 `json:"uptime"`
	Mem                   int64                  `json:"mem"`
	Cores                 int                    `json:"cores"`
	MaxProcs              int                    `json:"gomaxprocs"`
	CPU                   float64                `json:"cpu"`
	Connections           int                    `json:"connections"`
	TotalConnections      uint64                 `json:"total_connections"`
	Routes                int                    `json:"routes"`
	Remotes               int                    `json:"remotes"`
	Leafs                 int                    `json:"leafnodes"`
	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"`
	Subscriptions         uint32                 `json:"subscriptions"`
	HTTPReqStats          map[string]uint64      `json:"http_req_stats"`
	ConfigLoadTime        time.Time              `json:"config_load_time"`
	Tags                  jwt.TagList            `json:"tags,omitempty"`
	TrustedOperatorsJwt   []string               `json:"trusted_operators_jwt,omitempty"`
	TrustedOperatorsClaim []*jwt.OperatorClaims  `json:"trusted_operators_claim,omitempty"`
	SystemAccount         string                 `json:"system_account,omitempty"`
	PinnedAccountFail     uint64                 `json:"pinned_account_fails,omitempty"`
	OCSPResponseCache     *OCSPResponseCacheVarz `json:"ocsp_peer_cache,omitempty"`
	SlowConsumersStats    *SlowConsumersStats    `json:"slow_consumer_stats"`
}

VarzResp is a server response from VARZ endpoint, containing general information about the server.

type VarzEventOptions

type VarzEventOptions struct {
	EventFilterOptions
}

In the context of system events, VarzEventOptions are options passed to Varz

type VarzResp

type VarzResp struct {
	Server ServerInfo `json:"server"`
	Varz   Varz       `json:"data"`
	Error  APIError   `json:"error,omitempty"`
}

VarzResp is the response from the server VARZ request.

type WebsocketOptsVarz

type WebsocketOptsVarz struct {
	Host              string        `json:"host,omitempty"`
	Port              int           `json:"port,omitempty"`
	Advertise         string        `json:"advertise,omitempty"`
	NoAuthUser        string        `json:"no_auth_user,omitempty"`
	JWTCookie         string        `json:"jwt_cookie,omitempty"`
	HandshakeTimeout  time.Duration `json:"handshake_timeout,omitempty"`
	AuthTimeout       float64       `json:"auth_timeout,omitempty"`
	NoTLS             bool          `json:"no_tls,omitempty"`
	TLSMap            bool          `json:"tls_map,omitempty"`
	TLSPinnedCerts    []string      `json:"tls_pinned_certs,omitempty"`
	SameOrigin        bool          `json:"same_origin,omitempty"`
	AllowedOrigins    []string      `json:"allowed_origins,omitempty"`
	Compression       bool          `json:"compression,omitempty"`
	TLSOCSPPeerVerify bool          `json:"tls_ocsp_peer_verify,omitempty"`
}

WebsocketOptsVarz contains monitoring websocket information

Jump to

Keyboard shortcuts

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