You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Thomas Lynch
a2738e5bc1
|
2 months ago | |
---|---|---|
.. | ||
options | 2 months ago | |
README.md | 3 months ago | |
acls.go | 3 months ago | |
acls_test.go | 3 months ago | |
certs.go | 3 months ago | |
certs_test.go | 3 months ago | |
crt-lists.go | 3 months ago | |
crt-lists_test.go | 2 years ago | |
frontends.go | 3 years ago | |
haproxy_mock.go | 6 months ago | |
info.go | 3 months ago | |
interface.go | 2 months ago | |
maps.go | 3 months ago | |
runtime_client.go | 2 months ago | |
runtime_client_test.go | 3 months ago | |
runtime_const.go | 3 years ago | |
runtime_single_client.go | 2 months ago | |
servers.go | 2 months ago | |
stats.go | 3 months ago | |
stick_tables.go | 3 months ago | |
version.go | 1 year ago | |
version_test.go | 3 months ago |
README.md
HAProxy runtime client
usage
package main
import (
"log"
"github.com/haproxytech/client-native/v6/runtime"
runtime_options "github.com/haproxytech/client-native/v6/runtime/options"
)
func main() {
nbproc := 8
ms := runtime_options.MasterSocket("/var/run/haproxy-mw.sock", nbproc)
client, err = runtime_api.New(ctx, ms)
if err != nil {
return nil, fmt.Errorf("error setting up runtime client: %s", err.Error())
}
// or if not using master-worker
socketList := map[int]string{
1: "/var/run/haproxy-runtime-api.sock"
}
sockets := runtime_options.Sockets(socketList)
client, err = runtime_api.New(ctx, mapsDir, sockets)
if err != nil {
return nil, fmt.Errorf("error setting up runtime client: %s", err.Error())
}
statsCollection := client.GetStats()
if statsCollection.Error != "" {
log.Println(err)
}
log.Println(statsCollection.Stats)
processInfo := client.GetInfo()
if processInfo.Error != "" {
log.Println(err)
}
log.Println(processInfo.Info)
env, err := client.ExecuteRaw("show env")
if err != nil {
log.Println(err)
}
log.Println(env)
}