Help us shape the future of Go! Take the 2026 Go Developer Survey

models

package
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2021 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package models provides Database Lab struct.

Index

Constants

View Source
const (
	StatusOK        StatusCode = "OK"
	StatusCreating  StatusCode = "CREATING"
	StatusResetting StatusCode = "RESETTING"
	StatusDeleting  StatusCode = "DELETING"
	StatusExporting StatusCode = "EXPORTING"
	StatusFatal     StatusCode = "FATAL"
	StatusWarning   StatusCode = "WARNING"

	CloneMessageOK        = "Clone is ready to accept Postgres connections."
	CloneMessageCreating  = "Clone is being created."
	CloneMessageResetting = "Clone is being reset."
	CloneMessageDeleting  = "Clone is being deleted."
	CloneMessageFatal     = "Cloning failure."

	InstanceMessageOK      = "Instance is ready"
	InstanceMessageWarning = "Subsystems that need attention"
)

Constants declares available status codes and messages.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alert

type Alert struct {
	Level    AlertLevel `json:"level"`
	Message  string     `json:"message"`
	LastSeen time.Time  `json:"lastSeen"`
	Count    int        `json:"count"`
}

Alert describes retrieval subsystem alert.

type AlertLevel

type AlertLevel string

AlertLevel defines levels of retrieval alert.

const (
	// ErrorLevel defines error alerts.
	ErrorLevel AlertLevel = "error"
	// WarningLevel defines warning alerts.
	WarningLevel AlertLevel = "warning"
	// UnknownLevel defines unknown alerts.
	UnknownLevel AlertLevel = "unknown"
)

func AlertLevelByType

func AlertLevelByType(alertType AlertType) AlertLevel

AlertLevelByType defines relations between alert type and its level.

type AlertType

type AlertType string

AlertType defines type of retrieval alert.

const (
	// RefreshFailed describes alert when data refreshing is failed.
	RefreshFailed AlertType = "refresh_failed"

	// RefreshSkipped describes alert when data refreshing is skipped.
	RefreshSkipped AlertType = "refresh_skipped"
)

type Checklist

type Checklist struct {
	Success  bool `json:"overall_success"`
	Duration bool `json:"session_duration_acceptable"`
	Locks    bool `json:"no_long_dangerous_locks"`
}

Checklist represents a list of observation checks.

type Clone

type Clone struct {
	ID        string        `json:"id"`
	Snapshot  *Snapshot     `json:"snapshot"`
	Protected bool          `json:"protected"`
	DeleteAt  string        `json:"deleteAt"`
	CreatedAt string        `json:"createdAt"`
	Status    Status        `json:"status"`
	DB        Database      `json:"db"`
	Metadata  CloneMetadata `json:"metadata"`
}

Clone defines a clone model.

type CloneList

type CloneList struct {
	Cloning Cloning `json:"cloning"`
}

CloneList represents a list of clones.

type CloneListView

type CloneListView struct {
	Cloning CloningView `json:"cloning"`
}

CloneListView represents cloning process views.

type CloneMetadata

type CloneMetadata struct {
	CloneDiffSize  uint64  `json:"cloneDiffSize"`
	LogicalSize    uint64  `json:"logicalSize"`
	CloningTime    float64 `json:"cloningTime"`
	MaxIdleMinutes uint    `json:"maxIdleMinutes"`
}

CloneMetadata contains fields describing a clone model.

type CloneMetadataView

type CloneMetadataView struct {
	*CloneMetadata
	CloneDiffSize Size `json:"cloneDiffSize"`
	LogicalSize   Size `json:"logicalSize"`
}

CloneMetadataView represents a view of clone metadata.

type CloneView

type CloneView struct {
	*Clone
	Snapshot *SnapshotView     `json:"snapshot"`
	Metadata CloneMetadataView `json:"metadata"`
}

CloneView represents a view of clone model.

type Cloning

type Cloning struct {
	ExpectedCloningTime float64  `json:"expectedCloningTime"`
	NumClones           uint64   `json:"numClones"`
	Clones              []*Clone `json:"clones"`
}

Cloning represents info about the cloning process.

type CloningView

type CloningView struct {
	Clones []*CloneView `json:"clones"`
}

CloningView represents a list of clone views.

type ContainerOptions

type ContainerOptions struct {
	DockerImage     string            `json:"dockerImage"`
	ContainerConfig map[string]string `json:"containerConfig"`
}

ContainerOptions describes options for running containers.

type Database

type Database struct {
	ConnStr  string `json:"connStr"`
	Host     string `json:"host"`
	Port     string `json:"port"`
	Username string `json:"username"`
	Password string `json:"password"`
	DBName   string `json:"dbName"`
}

Database defines clone database parameters.

type Engine

type Engine struct {
	Version   string     `json:"version"`
	StartedAt *time.Time `json:"startedAt,omitempty"`
	Telemetry *bool      `json:"telemetry,omitempty"`
}

Engine represents info about Database Lab Engine instance.

type Error

type Error struct {
	Code    ErrorCode `json:"code"`
	Message string    `json:"message"`
}

Error struct represents a response error.

func New

func New(code ErrorCode, message string) *Error

New creates ClientError instance with given code and message.

func (Error) Error

func (e Error) Error() string

Error prints an error message.

type ErrorCode

type ErrorCode string

ErrorCode defines a response error type.

const (
	ErrCodeInternal     ErrorCode = "INTERNAL_ERROR"
	ErrCodeBadRequest   ErrorCode = "BAD_REQUEST"
	ErrCodeUnauthorized ErrorCode = "UNAUTHORIZED"
	ErrCodeNotFound     ErrorCode = "NOT_FOUND"
)

ErrCode constants define a response error codes.

type FileSystem

type FileSystem struct {
	Mode            string  `json:"mode"`
	Size            uint64  `json:"size"`
	Free            uint64  `json:"free"`
	Used            uint64  `json:"used"`
	DataSize        uint64  `json:"dataSize"`
	UsedBySnapshots uint64  `json:"usedBySnapshots"`
	UsedByClones    uint64  `json:"usedByClones"`
	CompressRatio   float64 `json:"compressRatio"`
}

FileSystem describes state of a file system.

type FileSystemView

type FileSystemView struct {
	*FileSystem
	Size            Size `json:"size"`
	Free            Size `json:"free"`
	Used            Size `json:"used"`
	DataSize        Size `json:"dataSize"`
	UsedBySnapshots Size `json:"usedBySnapshots"`
	UsedByClones    Size `json:"usedByClones"`
}

FileSystemView describes a view of file system state.

type InstanceStatus

type InstanceStatus struct {
	Status      *Status          `json:"status"`
	Engine      Engine           `json:"engine"`
	Pools       []PoolEntry      `json:"pools"`
	Cloning     Cloning          `json:"cloning"`
	Retrieving  Retrieving       `json:"retrieving"`
	Provisioner ContainerOptions `json:"provisioner"`
}

InstanceStatus represents status of a Database Lab Engine instance.

type InstanceStatusView

type InstanceStatusView struct {
	*InstanceStatus
	Pools []PoolEntryView `json:"pools"`
}

InstanceStatusView represents view of a Database Lab Engine instance status.

type Interval

type Interval struct {
	StartedAt time.Time `json:"started_at"`
	Duration  float64   `json:"duration"`
	Warning   string    `json:"warning"`
}

Interval represents data of an observation interval.

type ObservationResult

type ObservationResult struct {
	Status    string     `json:"status"`
	Intervals []Interval `json:"intervals"`
	Summary   Summary    `json:"summary"`
}

ObservationResult represents a result of observation session.

type PoolEntry

type PoolEntry struct {
	Name        string               `json:"name"`
	Mode        string               `json:"mode"`
	DataStateAt string               `json:"dataStateAt"`
	Status      resources.PoolStatus `json:"status"`
	CloneList   []string             `json:"cloneList"`
	FileSystem  FileSystem           `json:"fileSystem"`
}

PoolEntry represents a pool entry.

type PoolEntryView

type PoolEntryView struct {
	*PoolEntry
	FileSystem FileSystemView `json:"fileSystem"`
}

PoolEntryView represents a pool entry view.

type RetrievalMode

type RetrievalMode string

RetrievalMode defines mode of retrieval subsystem.

const (
	// Physical defines physical retrieval mode.
	Physical RetrievalMode = "physical"
	// Logical defines logical retrieval mode.
	Logical RetrievalMode = "logical"
	// Unknown defines the case when retrieval mode is unknown or is not set.
	Unknown RetrievalMode = "unknown"
)

type RetrievalStatus

type RetrievalStatus string

RetrievalStatus defines status of refreshing data.

const (
	// Inactive defines status when data retrieving is disabled.
	Inactive RetrievalStatus = "inactive"
	// Failed defines status when data retrieving is failed.
	Failed RetrievalStatus = "failed"
	// Refreshing defines status when data retrieving is in progress.
	Refreshing RetrievalStatus = "refreshing"
	// Finished defines status when data retrieving is finished.
	Finished RetrievalStatus = "finished"
)

type Retrieving

type Retrieving struct {
	Mode        RetrievalMode       `json:"mode"`
	Status      RetrievalStatus     `json:"status"`
	LastRefresh *time.Time          `json:"lastRefresh"`
	NextRefresh *time.Time          `json:"nextRefresh"`
	Alerts      map[AlertType]Alert `json:"alerts"`
}

Retrieving represents state of retrieval subsystem.

type Size

type Size uint64

Size describes amount of disk space.

func (Size) MarshalJSON

func (s Size) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Size struct.

type Snapshot

type Snapshot struct {
	ID           string `json:"id"`
	CreatedAt    string `json:"createdAt"`
	DataStateAt  string `json:"dataStateAt"`
	PhysicalSize uint64 `json:"physicalSize"`
	LogicalSize  uint64 `json:"logicalSize"`
	Pool         string `json:"pool"`
	NumClones    int    `json:"numClones"`
}

Snapshot defines a snapshot entity.

type SnapshotView

type SnapshotView struct {
	*Snapshot
	PhysicalSize Size `json:"physicalSize"`
	LogicalSize  Size `json:"logicalSize"`
}

SnapshotView represents a view of snapshot.

type Status

type Status struct {
	Code    StatusCode `json:"code"`
	Message string     `json:"message"`
}

Status defines the status of clones and instance.

type StatusCode

type StatusCode string

StatusCode defines the status code of clones and instance.

type Summary

type Summary struct {
	TotalDuration    float64   `json:"total_duration"`
	TotalIntervals   uint      `json:"total_intervals"`
	WarningIntervals uint      `json:"warning_intervals"`
	Checklist        Checklist `json:"checklist"`
}

Summary represents a summary of observation.

Jump to

Keyboard shortcuts

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