mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-05 01:01:09 +01:00
d5dddb0953
This will simplify examining the returned errors such as httpserver.ErrorWithStatusCode . See https://blog.golang.org/go1.13-errors for details.
29 lines
550 B
Go
29 lines
550 B
Go
package consul
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
)
|
|
|
|
// Agent is Consul agent.
|
|
//
|
|
// See https://www.consul.io/api/agent.html#read-configuration
|
|
type Agent struct {
|
|
Config AgentConfig
|
|
}
|
|
|
|
// AgentConfig is Consul agent config.
|
|
//
|
|
// See https://www.consul.io/api/agent.html#read-configuration
|
|
type AgentConfig struct {
|
|
Datacenter string
|
|
}
|
|
|
|
func parseAgent(data []byte) (*Agent, error) {
|
|
var a Agent
|
|
if err := json.Unmarshal(data, &a); err != nil {
|
|
return nil, fmt.Errorf("cannot unmarshal agent info from %q: %w", data, err)
|
|
}
|
|
return &a, nil
|
|
}
|