expand account information
@@ -20,29 +20,34 @@ import (
"gopkg.in/alecthomas/kingpin.v2"
)
-type actCmd struct {
- json bool
-}
+type actCmd struct{}
func configureActCommand(app *kingpin.Application) {
c := &actCmd{}
- act := app.Command("account", "JetStream account information")
+ act := app.Command("account", "Account information and status")
act.Command("info", "Account information").Alias("nfo").Action(c.infoAction)
- act.Flag("json", "Produce JSON output").Short('j').BoolVar(&c.json)
}
func (c *actCmd) infoAction(pc *kingpin.ParseContext) error {
- _, mgr, err := prepareHelper("", natsOpts()...)
+ nc, mgr, err := prepareHelper("", natsOpts()...)
kingpin.FatalIfError(err, "setup failed")
- info, err := mgr.JetStreamAccountInfo()
- kingpin.FatalIfError(err, "could not request account info")
+ id, _ := nc.GetClientID()
+ ip, _ := nc.GetClientIP()
+ fmt.Println("Connection Information:")
+ fmt.Println()
+ fmt.Printf(" Client ID: %v\n", id)
+ fmt.Printf(" Client IP: %v\n", ip)
+ fmt.Printf(" Headers Supported: %v\n", nc.HeadersSupported())
+ fmt.Printf(" Connected URL: %v\n", nc.ConnectedUrl())
+ fmt.Printf(" Connected Address: %v\n", nc.ConnectedAddr())
+ fmt.Printf(" Connected Server ID: %v\n", nc.ConnectedServerId())
+ fmt.Printf(" Maximum Payload: %v\n", humanize.IBytes(uint64(nc.MaxPayload())))
- if c.json {
- printJSON(info)
- return nil
- }
+ fmt.Println()
+ info, err := mgr.JetStreamAccountInfo()
+ if err == nil {
fmt.Println("JetStream Account Information:")
fmt.Println()
fmt.Printf(" Memory: %s of %s\n", humanize.IBytes(info.Memory), humanize.IBytes(uint64(info.Limits.MaxMemory)))
@@ -59,6 +64,11 @@ func (c *actCmd) infoAction(pc *kingpin.ParseContext) error {
} else {
fmt.Printf(" Max Consumers: %d\n", info.Limits.MaxConsumers)
}
+ } else {
+ fmt.Println("JetStream Account Information:")
+ fmt.Println()
+ fmt.Printf(" JetStream is not supported in this account")
+ }
fmt.Println()
