grpcServerApi

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContinueSubscribe bool = true
	StopSubscribe     bool = false
)

Variables

View Source
var ErrInstanceOffline error = errors.New("instance offline")

Functions

This section is empty.

Types

type CreateDbRequest

type CreateDbRequest struct {
	InstanceFilter
	Owner       string `json:"owner" binding:"max=63,id"`
	Password    string `json:"password" binding:"required,min=8,max=256"`
	Reason      string `json:"reason" binding:"max=1024"`
	MigrateFrom string `json:"migrate_from" binding:"max=63,iname"`
	BackupPath  string `json:"backup_path" binding:"max=256"`
}

type DbManager

type DbManager interface {
	GetDbStatus(request *DbRequest) (*DbStatusResponse, error)
	CreateDb(request *CreateDbRequest) error

	SubscribeDbStatus
	SubscribeInstanceStatus
}

type DbReadyWaiter

type DbReadyWaiter interface {
	WaitReady(instName string, dbName string, timeout time.Duration) bool
}

type DbRequest

type DbRequest struct {
	InstanceFilter
}

type DbStatusResponse

type DbStatusResponse struct {
	Name      string    `json:"name"`
	Stage     string    `json:"stage"`
	Status    string    `json:"status"`
	UpdatedAt time.Time `json:"updated_at"`
	ErrorMsg  string    `json:"error_msg"`

	InstanceName string `json:"instance_name"`
	Version      int32  `json:"version"`
}

func (*DbStatusResponse) IsFailed

func (status *DbStatusResponse) IsFailed() bool

func (*DbStatusResponse) IsMigrateOutReady

func (status *DbStatusResponse) IsMigrateOutReady(name string, instanceName string) bool

func (*DbStatusResponse) IsReady

func (status *DbStatusResponse) IsReady(name string, instanceName string) bool

type InstanceFilter

type InstanceFilter struct {
	// The Instance InstanceName
	InstanceName string `form:"instance_name" json:"instance_name" binding:"max=63,iname"`
	// The Postgres major version
	Version int32 `form:"version" json:"version" binding:"pg_ver"`
	// The database name
	Name string `form:"name" json:"name" binding:"required,max=63,id"`
	// Database must be in the instance
	MustExist bool `form:"must_exist" json:"must_exist" binding:""`
}

type InstanceStatusResponse

type InstanceStatusResponse struct {
	Name    string `json:"name"`
	Version int32  `json:"version"`
	Online  bool   `json:"online"`

	Databases map[string]*DbStatusResponse `json:"all_db_statuses"`
}

type MigrateOutDbRequest

type MigrateOutDbRequest struct {
	Name         string    `json:"name" binding:"required,max=63,id"`
	InstanceName string    `json:"instance_name" binding:"required,max=63,iname"`
	Reason       string    `json:"reason" binding:"max=1024"`
	MigrateTo    string    `json:"migrate_to" binding:"required,max=63,iname"`
	ExpireAt     time.Time `json:"-"`
}

type SubscribeDbStatus

type SubscribeDbStatus interface {
	// Subscribe to database status changes, the callback will be called when the status changes
	// The callback should return true if it wants to continue receiving notifications
	// and false if it wants to unsubscribe
	//
	// This function will report on following stage changed:
	// - Ready
	// - Idle
	// - DropCompleted
	SubscribeDbStatus(callback SubscribeDbStatusFunc)
}

type SubscribeDbStatusFunc

type SubscribeDbStatusFunc func(*DbStatusResponse) bool

SubscribeDbStatusFunc is a callback function to be called when the status of the database changes The function should return true if it wants to continue receiving notifications and false if it wants to unsubscribe

type SubscribeInstanceStatus

type SubscribeInstanceStatus interface {
	SubscribeInstanceStatus(callback SubscribeInstanceStatusFunc)
}

type SubscribeInstanceStatusFunc

type SubscribeInstanceStatusFunc func(*InstanceStatusResponse) bool

Jump to

Keyboard shortcuts

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