Files
nats-server/server/monitor_sort_opts.go
Ivan Kozlovic a3e8fba6b3 Add options for each monitoring endpoint and added Connz
Even for endpoints that currently do not need options (such as
Subsz and Varz), I added some options and a return of error so that
we don't break the API if we ever need to add options for those.
2018-03-13 10:30:46 -06:00

52 lines
1.4 KiB
Go

// Copyright 2013-2016 Apcera Inc. All rights reserved.
package server
// SortOpt is a helper type to sort by ConnInfo values
type SortOpt string
// Possible sort options
const (
ByCid SortOpt = "cid" // By connection ID
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
)
// IsValid determines if a sort option is valid
func (s SortOpt) IsValid() bool {
switch s {
case "", ByCid, BySubs, ByPending, ByOutMsgs, ByInMsgs, ByOutBytes, ByInBytes, ByLast, ByIdle, ByUptime:
return true
default:
return false
}
}
// Pair type is internally used.
type Pair struct {
Key *client
Val int64
}
// Pairs type is internally used.
type Pairs []Pair
func (d Pairs) Len() int {
return len(d)
}
func (d Pairs) Swap(i, j int) {
d[i], d[j] = d[j], d[i]
}
func (d Pairs) Less(i, j int) bool {
return d[i].Val < d[j].Val
}