mysqlrouter

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2023 License: Apache-2.0 Imports: 6 Imported by: 4

README

mysqlrouter-go

Build Status

client for getting mysql-router information.

Supported version

  • 20190715 (8.0.17 - 8.0.34 / 8.1.0)

Enable HTTP Server and REST API

See MySQL Router 8.0.17 and the REST API by lefred.

Usage

mysqlrouter.New("http://localhost:8080", "luis", "luis", nil)

See example and client_test.go

Supported endpoint

server
  • HTTPS with verify
cluster
  • /metadata
  • /metadata/metadata_name/config
  • /metadata/metadata_name/status
app
  • /router/status
route
  • /routes
  • /routes/route_name/status
  • /routes/route_name/health
  • /routes/route_name/destinations
  • /routes/route_name/connections

Developer

$ cd test && make local

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	URL      string
	Username string
	Password string
	Options  *Options
}

Client holds the configuration for 20190715 version API client.

func New

func New(url, user, pass string, Options *Options) (*Client, error)

New creates a new API client.

func (*Client) GetAllMetadata

func (c *Client) GetAllMetadata() ([]*Metadata, error)

GetAllMetadata returns all metadata.

func (*Client) GetAllRoutes

func (c *Client) GetAllRoutes() ([]*Routes, error)

GetAllRoutes returns all routes.

func (*Client) GetMetadataConfig

func (c *Client) GetMetadataConfig(cName string) (*MetadataConfig, error)

GetMetadataConfig returns the configuration of metadata.

func (*Client) GetMetadataStatus

func (c *Client) GetMetadataStatus(cName string) (*MetadataStatus, error)

GetMetadataStatus returns the state of metadata.

func (*Client) GetRouteConnections

func (c *Client) GetRouteConnections(rName string) ([]*RouteConnections, error)

GetRouteConnections return connections of the route.

func (*Client) GetRouteDestinations

func (c *Client) GetRouteDestinations(rName string) ([]*RouteDestinations, error)

GetRouteDestinations returns destinations of the route.

func (*Client) GetRouteHealth

func (c *Client) GetRouteHealth(rName string) (*RouteHealth, error)

GetRouteHealth returns the health check of the route.

func (*Client) GetRouteStatus

func (c *Client) GetRouteStatus(rName string) (*RouteStatus, error)

GetRouteStatus return the status of the route.

func (*Client) GetRouterStatus

func (c *Client) GetRouterStatus() (*Router, error)

GetRouterStatus returns information of MySQL Router

type Metadata

type Metadata struct {
	Name string `json:"name"`
}

Metadata is the structure of getting all metadata endpoint.

type MetadataConfig

type MetadataConfig struct {
	ClusterName        string         `json:"clusterName"`
	TimeRefreshInMs    int            `json:"timeRefreshInMs"`
	GroupReplicationID string         `json:"groupReplicationId"`
	Nodes              []MetadataNode `json:"nodes"`
}

MetadataConfig is the structure of the configuration of metadata.

type MetadataNode

type MetadataNode struct {
	Hostname string `json:"hostname"`
	Port     int    `json:"port"`
}

MetadataNode is the structure of metadata of a node.

type MetadataResponse

type MetadataResponse struct {
	Item []*Metadata `json:"items"`
}

MetadataResponse is the response of getting all metadata endpoint.

type MetadataStatus

type MetadataStatus struct {
	RefreshFailed            int       `json:"refreshFailed"`
	RefreshSucceeded         int       `json:"refreshSucceeded"`
	TimeLastRefreshSucceeded time.Time `json:"timeLastRefreshSucceeded"`
	LastRefreshHostname      string    `json:"lastRefreshHostname"`
	LastRefreshPort          int       `json:"lastRefreshPort"`
}

MetadataStatus is the structure of the information of metadata.

type Options added in v1.1.0

type Options struct {
	Transport *http.Transport
}

type RouteConnections

type RouteConnections struct {
	BytesFromServer            int       `json:"bytesFromServer"`
	BytesToServer              int       `json:"bytesToServer"`
	SourceAddress              string    `json:"sourceAddress"`
	DestinationAddress         string    `json:"destinationAddress"`
	TimeStarted                time.Time `json:"timeStarted"`
	TimeConnectedToServer      time.Time `json:"timeConnectedToServer"`
	TimeLastSentToServer       time.Time `json:"timeLastSentToServer"`
	TimeLastReceivedFromServer time.Time `json:"timeLastReceivedFromServer"`
}

RouteConnections is the structure of the information of the connection of route.

type RouteConnectionsResponse

type RouteConnectionsResponse struct {
	Item []*RouteConnections `json:"items"`
}

RouteConnectionsResponse is the response of getting the information of route connection endpoint.

type RouteDestinations

type RouteDestinations struct {
	Address string `json:"address"`
	Port    int    `json:"port"`
}

RouteDestinations is the structure of destination of the route.

type RouteDestinationsResponse

type RouteDestinationsResponse struct {
	Item []*RouteDestinations `json:"items"`
}

RouteDestinationsResponse is the response of getting the information of the route destination endpoint.

type RouteHealth

type RouteHealth struct {
	IsAlive bool `json:"isAlive"`
}

RouteHealth is the structure of health check of the route.

type RouteStatus

type RouteStatus struct {
	ActiveConnections int `json:"activeConnections"`
	TotalConnections  int `json:"totalConnections"`
	BlockedHosts      int `json:"blockedHosts"`
}

RouteStatus is the state of the route.

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

Router general information of MySQL Router

type Routes

type Routes struct {
	Name string `json:"name"`
}

Routes is the response of getting all routes endpoint.

type RoutesResponse

type RoutesResponse struct {
	Item []*Routes `json:"items"`
}

RoutesResponse is the response of getting all routes endpoint.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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