File: app.go

package info (click to toggle)
golang-github-rluisr-mysqlrouter-go 1.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 264 kB
  • sloc: sh: 215; javascript: 15; makefile: 11
file content (35 lines) | stat: -rw-r--r-- 683 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package mysqlrouter

import (
	"encoding/json"
	"time"
)

var (
	appURL = "/router"
)

// Router general information of MySQL Router
type Router struct {
	ProcessID      int       `json:"processId"`
	ProductEdition string    `json:"productEdition"`
	TimeStarted    time.Time `json:"timeStarted"`
	Version        string    `json:"version"`
	Hostname       string    `json:"hostname"`
}

// GetRouterStatus returns information of MySQL Router
func (c *Client) GetRouterStatus() (*Router, error) {
	b, err := c.request(c.URL + appURL + "/status")
	if err != nil {
		return nil, err
	}

	var r *Router
	err = json.Unmarshal(b, &r)
	if err != nil {
		return nil, err
	}

	return r, nil
}