devlopment branch (#1736)

This commit is contained in:
zryfish
2020-01-02 20:52:00 +08:00
committed by GitHub
parent ff0ffe8650
commit eceadec69c
440 changed files with 61524 additions and 3699 deletions

View File

@@ -27,14 +27,17 @@ import (
"time"
)
type PrometheusClient struct {
type Interface interface {
}
type Client struct {
client *http.Client
endpoint string
secondaryEndpoint string
}
func NewPrometheusClient(options *PrometheusOptions) (*PrometheusClient, error) {
return &PrometheusClient{
func NewPrometheusClient(options *Options) (*Client, error) {
return &Client{
client: &http.Client{
Timeout: 10 * time.Second,
},
@@ -43,17 +46,17 @@ func NewPrometheusClient(options *PrometheusOptions) (*PrometheusClient, error)
}, nil
}
func (c *PrometheusClient) QueryToK8SPrometheus(queryType string, params string) (apiResponse v1alpha2.APIResponse) {
func (c *Client) QueryToK8SPrometheus(queryType string, params string) (apiResponse v1alpha2.APIResponse) {
return c.query(c.endpoint, queryType, params)
}
func (c *PrometheusClient) QueryToK8SSystemPrometheus(queryType string, params string) (apiResponse v1alpha2.APIResponse) {
func (c *Client) QueryToK8SSystemPrometheus(queryType string, params string) (apiResponse v1alpha2.APIResponse) {
return c.query(c.secondaryEndpoint, queryType, params)
}
var jsonIter = jsoniter.ConfigCompatibleWithStandardLibrary
func (c *PrometheusClient) query(endpoint string, queryType string, params string) (apiResponse v1alpha2.APIResponse) {
func (c *Client) query(endpoint string, queryType string, params string) (apiResponse v1alpha2.APIResponse) {
url := fmt.Sprintf("%s/api/v1/%s?%s", endpoint, queryType, params)
response, err := c.client.Get(url)