webserver

package
v1.27.1 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2025 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Overview

Package webserver contains the web server powering probes, backups and metrics

Index

Constants

View Source
const (
	// DefaultReadTimeout is the default value to be used by the webservers
	DefaultReadTimeout = 20 * time.Second
	// DefaultReadHeaderTimeout is the default value to be used by the webservers
	DefaultReadHeaderTimeout = 3 * time.Second
)

Variables

This section is empty.

Functions

func IsRetryableError added in v1.24.3

func IsRetryableError(err *Error) bool

IsRetryableError checks if the error is retryable

Types

type ArchiveStatusRequest added in v1.25.0

type ArchiveStatusRequest struct {
	Error string `json:"error,omitempty"`
}

ArchiveStatusRequest is the request body for the archive status endpoint

type BackupConnectionPhase added in v1.21.1

type BackupConnectionPhase string

BackupConnectionPhase a connection phase of the backup

const (
	Starting  BackupConnectionPhase = "starting"
	Started   BackupConnectionPhase = "started"
	Closing   BackupConnectionPhase = "closing"
	Completed BackupConnectionPhase = "completed"
)

A backup phase

type BackupResultData added in v1.21.1

type BackupResultData struct {
	BeginLSN   types.LSN             `json:"beginLSN,omitempty"`
	EndLSN     types.LSN             `json:"endLSN,omitempty"`
	LabelFile  []byte                `json:"labelFile,omitempty"`
	SpcmapFile []byte                `json:"spcmapFile,omitempty"`
	BackupName string                `json:"backupName,omitempty"`
	Phase      BackupConnectionPhase `json:"phase,omitempty"`
}

BackupResultData is the result of executing pg_start_backup and pg_stop_backup

type Error added in v1.21.1

type Error struct {
	// One of a server-defined set of error codes
	Code string `json:"code"`
	// A human-readable representation of the error.
	Message string `json:"message"`
	// An array of details about specific errors that led to this reported error.
	Details []Error `json:"details,omitempty"`
}

Error an error response from http webserver

type PluginBackupCommand added in v1.23.0

type PluginBackupCommand struct {
	Cluster  *apiv1.Cluster
	Backup   *apiv1.Backup
	Client   client.Client
	Recorder record.EventRecorder
}

PluginBackupCommand represent a backup command that is being executed

func NewPluginBackupCommand added in v1.23.0

func NewPluginBackupCommand(
	cluster *apiv1.Cluster,
	backup *apiv1.Backup,
	client client.Client,
	recorder record.EventRecorder,
) *PluginBackupCommand

NewPluginBackupCommand initializes a BackupCommand object, taking a physical backup using Barman Cloud

func (*PluginBackupCommand) Start added in v1.23.0

func (b *PluginBackupCommand) Start(ctx context.Context)

Start starts a backup using the Plugin

type Response added in v1.21.1

type Response[T interface{}] struct {
	Data  *T     `json:"data,omitempty"`
	Error *Error `json:"error,omitempty"`
}

Response a response from the http webserver

func (Response[T]) GetError added in v1.24.3

func (body Response[T]) GetError() error

GetError returns an error if an error response is detected or if the data field is nil

type StartBackupRequest added in v1.21.1

type StartBackupRequest struct {
	ImmediateCheckpoint bool   `json:"immediateCheckpoint"`
	WaitForArchive      bool   `json:"waitForArchive"`
	BackupName          string `json:"backupName"`
}

StartBackupRequest the required data to execute the pg_start_backup

type StopBackupRequest added in v1.21.2

type StopBackupRequest struct {
	BackupName string `json:"backupName"`
}

StopBackupRequest the required data to execute the pg_stop_backup

func NewStopBackupRequest added in v1.21.2

func NewStopBackupRequest(backupName string) *StopBackupRequest

NewStopBackupRequest constructor

type Webserver

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

Webserver wraps a webserver to make it a kubernetes Runnable

func NewLocalWebServer

func NewLocalWebServer(
	instance *postgres.Instance,
	cli client.Client,
	recorder record.EventRecorder,
) (*Webserver, error)

NewLocalWebServer returns a webserver that allows connection only from localhost

func NewRemoteWebServer

func NewRemoteWebServer(
	instance *postgres.Instance,
	cancelFunc context.CancelFunc,
	exitedConditions concurrency.MultipleExecuted,
) (*Webserver, error)

NewRemoteWebServer returns a webserver that allows connection from external clients

func NewWebServer

func NewWebServer(server *http.Server) *Webserver

NewWebServer creates a Webserver as a Kubernetes Runnable, given a http.Server

func (*Webserver) Start

func (ws *Webserver) Start(ctx context.Context) error

Start starts a webserver listener, implementing the K8s runnable interface

Directories

Path Synopsis
client
common
Package common provides common utilities for the webserver client.
Package common provides common utilities for the webserver client.
local
Package local provides a client to interact with the local webserver endpoints.
Package local provides a client to interact with the local webserver endpoints.
remote
Package remote contains the client capable of querying the webserver remote endpoint.
Package remote contains the client capable of querying the webserver remote endpoint.
Package metricserver contains the web server powering metrics
Package metricserver contains the web server powering metrics
Package probes contains the implementation of startup, liveness and readiness probes
Package probes contains the implementation of startup, liveness and readiness probes

Jump to

Keyboard shortcuts

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