storage

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PREFIX_CLIENT_CONFIG = 0x01
)

any item prefix

View Source
const (
	REGEX_DB_URL = "^(sqlite|rqlite)://(.+)$"
)

rqlite://127.0.0.1:4000 sqlite:///home/curve/.curveadm/data/curveadm.db

Variables

View Source
var (
	// table: version
	CreateVersionTable = `` /* 141-byte string literal not displayed */

	// insert version
	InsertVersion = `INSERT INTO version(version, lastconfirm) VALUES(?, "")`

	// set version
	SetVersion = `UPDATE version SET version = ?, lastconfirm = ? WHERE id = ?`

	// select version
	SelectVersion = `SELECT * FROM version`
)
View Source
var (
	// table: hosts
	CreateHostsTable = `` /* 142-byte string literal not displayed */

	// insert hosts
	InsertHosts = `INSERT INTO hosts(data, lastmodified_time) VALUES(?, datetime('now','localtime'))`

	// set hosts
	SetHosts = `UPDATE hosts SET data = ?, lastmodified_time = datetime('now','localtime') WHERE id = ?`

	// select hosts
	SelectHosts = `SELECT * FROM hosts`
)
View Source
var (
	// table: clusters
	CreateClustersTable = `` /* 262-byte string literal not displayed */

	// insert cluster
	InsertCluster = `` /* 133-byte string literal not displayed */

	// delete cluster
	DeleteCluster = `DELETE from clusters WHERE name = ?`

	// select cluster
	SelectCluster = `SELECT * FROM clusters WHERE name LIKE ?`

	// get current cluster
	GetCurrentCluster = `SELECT * FROM clusters WHERE current = 1`

	// checkout cluster
	CheckoutCluster = `
		UPDATE clusters
		SET current = CASE name
			WHEN ? THEN 1
			ELSE 0
		END
	`

	// set cluster topology
	SetClusterTopology = `UPDATE clusters SET topology = ? WHERE id = ?`

	// set cluster pool
	SetClusterPool = `UPDATE clusters SET topology = ?, pool = ? WHERE id = ?`
)
View Source
var (
	// table: containers
	// id: clusterId_role_host_(sequence/name)
	CreateContainersTable = `` /* 134-byte string literal not displayed */

	// insert service
	InsertService = `INSERT INTO containers(id, cluster_id, container_id) VALUES(?, ?, ?)`

	// select service
	SelectService = `SELECT * FROM containers WHERE id = ?`

	// select services in cluster
	SelectServicesInCluster = `SELECT * FROM containers WHERE cluster_id = ?`

	// set service container id
	SetContainerId = `UPDATE containers SET container_id = ? WHERE id = ?`
)
View Source
var (
	// table: clients
	CreateClientsTable = `` /* 172-byte string literal not displayed */

	// insert client
	InsertClient = `INSERT INTO clients(id, kind, host, container_id, aux_info) VALUES(?, ?, ?, ?, ?)`

	// set client aux info
	SetClientAuxInfo = `UPDATE clients SET aux_info = ? WHERE id = ?`

	// select clients
	SelectClients = `SELECT * FROM clients`

	// select client by id
	SelectClientById = `SELECT * FROM clients WHERE id = ?`

	// delete client
	DeleteClient = `DELETE from clients WHERE id = ?`
)
View Source
var (
	// table: playground
	CreatePlaygroundTable = `` /* 204-byte string literal not displayed */

	// insert playground
	InsertPlayground = `` /* 133-byte string literal not displayed */

	// set playground status
	SetPlaygroundStatus = `UPDATE playgrounds SET status = ? WHERE name = ?`

	// select playground
	SelectPlayground = `SELECT * FROM playgrounds WHERE name LIKE ?`

	// select playground by id
	SelectPlaygroundById = `SELECT * FROM playgrounds WHERE id = ?`

	// delete playground
	DeletePlayground = `DELETE from playgrounds WHERE name = ?`
)
View Source
var (
	// table: audit
	CreateAuditTable = `` /* 235-byte string literal not displayed */

	// insert audit log
	InsertAuditLog = `
		INSERT INTO audit(execute_time, work_directory, command, status)
		            VALUES(?, ?, ?, ?)
	`

	// set audit log status
	SetAuditLogStatus = `UPDATE audit SET status = ?, error_code = ? WHERE id = ?`

	// select audit log
	SelectAuditLog = `SELECT * FROM audit`

	// select audit log by id
	SelectAuditLogById = `SELECT * FROM audit WHERE id = ?`
)
View Source
var (
	// table: any
	CreateAnyTable = `
		CREATE TABLE IF NOT EXISTS any (
			id TEXT PRIMARY KEY,
			data TEXT NOT NULL
		)
	`

	// insert item
	InsertAnyItem = `INSERT INTO any(id, data) VALUES(?, ?)`

	// set item
	SetAnyItem = `UPDATE any SET data = ? WHERE id = ?`

	// select item by id
	SelectAnyItem = `SELECT * FROM any WHERE id = ?`

	// delete item
	DeleteAnyItem = `DELETE from any WHERE id = ?`
)
View Source
var (
	// check pool column
	CheckPoolColumn = `
		SELECT COUNT(*) AS total
		FROM pragma_table_info('clusters')
		WHERE name='pool'
	`

	// rename clusters table
	RenameClustersTable = `ALTER TABLE clusters RENAME TO clusters_old`

	// insert clusters from old table
	InsertClustersFromOldTable = `` /* 185-byte string literal not displayed */

	// statement: drom old clusters table
	DropOldClustersTable = `DROP TABLE clusters_old`
)
View Source
var (
	// monitor
	CreateMonitorTable = `
		CREATE TABLE IF NOT EXISTS monitors (
			cluster_id INTEGER PRIMARY KEY,
			monitor TEXT NOT NULL
		)
	`
	// monitor
	InsertMonitor = `INSERT INTO monitors(cluster_id, monitor) VALUES(?, ?)`

	UpdateMonitor = `UPDATE monitors SET monitor = ? WHERE cluster_id = ?`

	SelectMonitor = `SELECT monitor FROM monitors WHERE cluster_id = ?`

	DeleteMonitor = `DELETE FROM monitors WHERE cluster_id = ?`

	ReplaceMonitor = `REPLACE INTO monitors (cluster_id, monitor) VALUES(?, ?)`
)
View Source
var (
	ErrInvalidDBUrl = fmt.Errorf("invalid database url")
)

Functions

This section is empty.

Types

type Any added in v0.3.0

type Any struct {
	Id   string
	Data string
}

any: we can store anything

type AuditLog added in v0.0.23

type AuditLog struct {
	Id            int
	ExecuteTime   time.Time
	WorkDirectory string
	Command       string
	Status        int
	ErrorCode     int
}

audit log

type Client added in v0.1.0

type Client struct {
	Id          string
	Kind        string
	Host        string
	ContainerId string
	AuxInfo     string
}

client

type Cluster

type Cluster struct {
	Id          int
	UUId        string
	Name        string
	Description string
	CreateTime  time.Time
	Topology    string
	Pool        string
	Current     bool
}

cluster

type Hosts added in v0.1.0

type Hosts struct {
	Id               int
	Data             string
	LastModifiedTime time.Time
}

hosts

type Monitor added in v0.3.0

type Monitor struct {
	ClusterId int
	Monitor   string
}

type Playground added in v0.0.25

type Playground struct {
	Id         int
	Name       string
	CreateTime time.Time
	MountPoint string
	Status     string
}

playground

type Service

type Service struct {
	Id          string
	ClusterId   int
	ContainerId string
}

service

type Storage

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

func NewStorage

func NewStorage(dbURL string) (*Storage, error)

func (*Storage) CheckoutCluster

func (s *Storage) CheckoutCluster(name string) error

func (*Storage) Close

func (s *Storage) Close() error

func (*Storage) DeleteClient added in v0.1.0

func (s *Storage) DeleteClient(id string) error

func (*Storage) DeleteClientConfig added in v0.3.0

func (s *Storage) DeleteClientConfig(id string) error

func (*Storage) DeleteCluster

func (s *Storage) DeleteCluster(name string) error

func (*Storage) DeleteMonitor added in v0.3.0

func (s *Storage) DeleteMonitor(clusterId int) error

func (*Storage) DeletePlayground added in v0.0.25

func (s *Storage) DeletePlayground(name string) error

func (*Storage) GetAuditLog added in v0.1.0

func (s *Storage) GetAuditLog(id int64) ([]AuditLog, error)

func (*Storage) GetAuditLogs added in v0.0.23

func (s *Storage) GetAuditLogs() ([]AuditLog, error)

func (*Storage) GetClient added in v0.1.0

func (s *Storage) GetClient(id string) ([]Client, error)

func (*Storage) GetClientConfig added in v0.3.0

func (s *Storage) GetClientConfig(id string) ([]Any, error)

func (*Storage) GetClientContainerId added in v0.1.0

func (s *Storage) GetClientContainerId(id string) (string, error)

func (*Storage) GetClients added in v0.1.0

func (s *Storage) GetClients() ([]Client, error)

func (*Storage) GetClusters

func (s *Storage) GetClusters(name string) ([]Cluster, error)

func (*Storage) GetContainerId

func (s *Storage) GetContainerId(serviceId string) (string, error)

func (*Storage) GetCurrentCluster

func (s *Storage) GetCurrentCluster() (Cluster, error)

func (*Storage) GetHostses added in v0.1.0

func (s *Storage) GetHostses() ([]Hosts, error)

func (*Storage) GetMonitor added in v0.3.0

func (s *Storage) GetMonitor(clusterId int) (Monitor, error)

func (*Storage) GetPlaygroundById added in v0.2.0

func (s *Storage) GetPlaygroundById(id string) ([]Playground, error)

func (*Storage) GetPlaygrounds added in v0.0.25

func (s *Storage) GetPlaygrounds(name string) ([]Playground, error)

func (*Storage) GetServices

func (s *Storage) GetServices(clusterId int) ([]Service, error)

func (*Storage) GetVersions added in v0.2.0

func (s *Storage) GetVersions() ([]Version, error)

func (*Storage) InsertAuditLog added in v0.0.23

func (s *Storage) InsertAuditLog(time time.Time, workDir, command string, status int) (int64, error)

audit

func (*Storage) InsertClient added in v0.1.0

func (s *Storage) InsertClient(id, kind, host, containerId, auxInfo string) error

client

func (*Storage) InsertClientConfig added in v0.3.0

func (s *Storage) InsertClientConfig(id, data string) error

func (*Storage) InsertCluster

func (s *Storage) InsertCluster(name, uuid, description, topology string) error

cluster

func (*Storage) InsertMonitor added in v0.3.0

func (s *Storage) InsertMonitor(m Monitor) error

func (*Storage) InsertPlayground added in v0.0.25

func (s *Storage) InsertPlayground(name, mountPoint string) error

playground

func (*Storage) InsertService

func (s *Storage) InsertService(clusterId int, serviceId, containerId string) error

service

func (*Storage) ReplaceMonitor added in v0.3.0

func (s *Storage) ReplaceMonitor(m Monitor) error

func (*Storage) SetAuditLogStatus added in v0.1.0

func (s *Storage) SetAuditLogStatus(id int64, status, errorCode int) error

func (*Storage) SetClientAuxInfo added in v0.3.0

func (s *Storage) SetClientAuxInfo(id, auxInfo string) error

func (*Storage) SetClusterPool added in v0.0.23

func (s *Storage) SetClusterPool(id int, topology, pool string) error

func (*Storage) SetClusterTopology

func (s *Storage) SetClusterTopology(id int, topology string) error

func (*Storage) SetContainId

func (s *Storage) SetContainId(serviceId, containerId string) error

func (*Storage) SetHosts added in v0.1.0

func (s *Storage) SetHosts(data string) error

hosts

func (*Storage) SetPlaygroundStatus added in v0.0.25

func (s *Storage) SetPlaygroundStatus(name, status string) error

func (*Storage) SetVersion added in v0.2.0

func (s *Storage) SetVersion(version, lastConfirm string) error

version

func (*Storage) UpdateMonitor added in v0.3.0

func (s *Storage) UpdateMonitor(m Monitor) error

type Version added in v0.2.0

type Version struct {
	Id          int
	Version     string
	LastConfirm string
}

version

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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