hareply

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidAgentCheckResponse is returned when the response to an agent check request is invalid.
	ErrInvalidAgentCheckResponse = errors.New("invalid agent check response value")
)

Functions

func ValidateAgentCheckResponse

func ValidateAgentCheckResponse(v string) error

ValidateAgentCheckResponse validates the response, making sure it is a valid response to an agent check request. See the docs here https://www.haproxy.com/documentation/haproxy-configuration-manual/latest/#5.2-agent-check

Types

type App

type App struct {
	sync.Mutex
	// contains filtered or unexported fields
}

App is a hareply application. An application reads responses from a file and serves them over TCP. It can only be started once.

func New

func New(filepath string, opts ...Option) (*App, error)

New creates a new hareply application that reads responses from the given file.

func (*App) ListenAddr

func (a *App) ListenAddr() net.Addr

ListenAddr returns the address the hareply application is listening on. This will return `nil` if the application is not currently serving.

func (*App) Serve

func (a *App) Serve(ctx context.Context) error

Serve starts the hareply application with the given arguments. It will block until the context is canceled.

type Option

type Option func(*App)

Option is a configuration option for the hareply application.

func WithFS

func WithFS(fs fs.FS) Option

WithFS sets the file system to use for the hareply application. It defaults to the host file system.

func WithHost

func WithHost(host string) Option

WithHost sets the host to listen on for the hareply application. It defaults to an empty string `""` which means "all interfaces".

func WithLogger

func WithLogger(logger *slog.Logger) Option

WithLogger sets the logger to use for the hareply application. It defaults to `slog.Default()“.

func WithPort

func WithPort(port int) Option

WithPort sets the port to listen on for the hareply application. If not set, it will pick an available port.

Jump to

Keyboard shortcuts

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