runtime

package
v1.2.7 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2020 License: Apache-2.0 Imports: 9 Imported by: 2

README

HAProxy runtime client

usage

package main

import (
	"log"

	"github.com/haproxytech/client-native/runtime"
)

func main() {
	client := runtime.SingleRuntime{}
	err := client.Init("/var/run/haproxy-runtime-api.sock")

	response, err := client.GetStats()
	if err != nil {
		log.Println(err)
	}
	log.Println(response)

	result, err := client.GetInfo()
	if err != nil {
		log.Println(err)
	}
	log.Println(result)

	result, err = client.ExecuteRaw("show env")
	if err != nil {
		log.Println(err)
	}
	log.Println(result)
}

Documentation

Index

Constants

View Source
const (
	// DefaultSocketPath sane default for runtime API socket path
	DefaultSocketPath string = "/var/run/haproxy.sock"
)

Variables

This section is empty.

Functions

func ServerHealthValid

func ServerHealthValid(state string) bool

ServerHealthValid checks if server state is valid

func ServerStateValid

func ServerStateValid(state string) bool

ServerStateValid checks if server state is valid

func ServerWeightValid

func ServerWeightValid(weight string) bool

ServerWeightValid checks if server state is valid

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client handles multiple HAProxy clients

func DefaultClient

func DefaultClient() (*Client, error)

DefaultClient return runtime Client with sane defaults

func (*Client) ExecuteRaw

func (c *Client) ExecuteRaw(command string) ([]string, error)

ExecuteRaw does not procces response, just returns its values for all processes

func (*Client) GetInfo

func (c *Client) GetInfo() ([]models.ProcessInfoHaproxy, error)

GetInfo returns info from the socket

func (*Client) GetStats

func (c *Client) GetStats() models.NativeStats

GetStats returns stats from the socket

func (*Client) Init

func (c *Client) Init(socketPath []string, masterSocketPath string, nbproc int) error

Init must be given path to runtime socket and nbproc that is not 0 when in master worker mode

func (*Client) SetFrontendMaxConn

func (c *Client) SetFrontendMaxConn(frontend string, maxconn int) error

SetFrontendMaxConn set maxconn for frontend

func (*Client) SetServerAddr

func (c *Client) SetServerAddr(backend, server string, ip string, port int) error

SetServerAddr set ip [port] for server

func (*Client) SetServerHealth

func (c *Client) SetServerHealth(backend, server string, health string) error

SetServerHealth set health for server

func (*Client) SetServerState

func (c *Client) SetServerState(backend, server string, state string) error

SetServerState set state for server

func (*Client) SetServerWeight

func (c *Client) SetServerWeight(backend, server string, weight string) error

SetServerWeight set weight for server

type SingleRuntime

type SingleRuntime struct {
	// contains filtered or unexported fields
}

SingleRuntime handles one runtime API

func (*SingleRuntime) Execute

func (s *SingleRuntime) Execute(command string) error

Execute executes command on runtime API

func (*SingleRuntime) ExecuteRaw

func (s *SingleRuntime) ExecuteRaw(command string) (string, error)

ExecuteRaw executes command on runtime API and returns raw result

func (*SingleRuntime) GetInfo

func (s *SingleRuntime) GetInfo() (models.ProcessInfoHaproxy, error)

GetInfo fetches HAProxy info from runtime API

func (*SingleRuntime) GetStats

GetStats fetches HAProxy stats from runtime API

func (*SingleRuntime) Init

func (s *SingleRuntime) Init(socketPath string, worker int) error

Init must be given path to runtime socket and worker number. If in master-worker mode, give the path to the master socket path, and non 0 number for workers.

func (*SingleRuntime) SetFrontendMaxConn

func (s *SingleRuntime) SetFrontendMaxConn(frontend string, maxconn int) error

SetFrontendMaxConn set maxconn for frontend

func (*SingleRuntime) SetServerAddr

func (s *SingleRuntime) SetServerAddr(backend, server string, ip string, port int) error

SetServerAddr set ip [port] for server

func (*SingleRuntime) SetServerHealth

func (s *SingleRuntime) SetServerHealth(backend, server string, health string) error

SetServerHealth set health for server

func (*SingleRuntime) SetServerState

func (s *SingleRuntime) SetServerState(backend, server string, state string) error

SetServerState set state for server

func (*SingleRuntime) SetServerWeight

func (s *SingleRuntime) SetServerWeight(backend, server string, weight string) error

SetServerWeight set weight for server

type Task

type Task struct {
	// contains filtered or unexported fields
}

Task has command to execute on runtime api, and response channel for result

type TaskResponse

type TaskResponse struct {
	// contains filtered or unexported fields
}

TaskResponse ...

Jump to

Keyboard shortcuts

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