webserver

package
v1.23.4 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: Apache-2.0 Imports: 31 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

This section is empty.

Types

type BackupClient added in v1.21.1

type BackupClient interface {
	StatusWithErrors(ctx context.Context, podIP string) (*Response[BackupResultData], error)
	Start(
		ctx context.Context,
		podIP string,
		sbq StartBackupRequest,
	) error
	Stop(ctx context.Context, podIP string, sbq StopBackupRequest) error
}

BackupClient is a struct capable of interacting with the instance backup endpoints

func NewBackupClient added in v1.21.1

func NewBackupClient() BackupClient

NewBackupClient creates a client capable of interacting with the instance backup endpoints

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   postgresUtils.LSN     `json:"beginLSN,omitempty"`
	EndLSN     postgresUtils.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
	Log      log.Logger
}

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]) EnsureDataIsPresent added in v1.21.2

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

EnsureDataIsPresent returns an error if the data is 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"`
	Force               bool   `json:"force,omitempty"`
}

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 contains a server that interacts with postgres instance

func NewLocalWebServer

func NewLocalWebServer(instance *postgres.Instance) (*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(instance *postgres.Instance, server *http.Server) *Webserver

NewWebServer creates a Webserver given a postgres.Instance and a http.Server

func (*Webserver) Start

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

Start implements the runnable interface

Directories

Path Synopsis
Package metricserver contains the web server powering metrics
Package metricserver contains the web server powering metrics

Jump to

Keyboard shortcuts

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