database

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Initial    = "initial"
	Processing = "processing"
	Success    = "success"
	Failed     = "failed"
)

Variables

View Source
var (

	//DBPath - sqlite db file path
	DBPath *string
	//InitSQL - sql file to init db
	InitSQL *string
)

Functions

This section is empty.

Types

type Cluster

type Cluster struct {
	ID          string       `xorm:"varchar(255) notnull pk 'id'" json:"id"`
	Name        string       `xorm:"varchar(255) notnull unique 'name'" json:"name"`
	Description string       `xorm:"varchar(255) 'description'" json:"description"`
	State       string       `xorm:"varchar(255) 'state'" json:"state"`
	Hosts       []*Host      `xorm:"-" json:"hosts,omitempty"`
	Components  []*Component `xorm:"-" json:"components,omitempty"`
}

type ClusterComponent

type ClusterComponent struct {
	ClusterID     string     `xorm:"varchar(255) notnull pk 'cluster_id'"`
	ComponentID   string     `xorm:"varchar(255) notnull pk 'component_id'"`
	ComponentName string     `xorm:"varchar(255) notnull 'component_name'"`
	Component     *Component `xorm:"json notnull 'component'"`
}

type ClusterHost

type ClusterHost struct {
	ClusterID string `xorm:"varchar(255) notnull pk 'cluster_id'"`
	HostID    string `xorm:"varchar(255) notnull pk 'host_id'"`
	IP        string `xorm:"varchar(25) notnull unique 'ip'"`
	Hostname  string `xorm:"varchar(255) notnull unique 'hostname'"`
	Host      *Host  `xorm:"json notnull 'host'"`
}

type ClusterLog

type ClusterLog struct {
	ClusterID string        `xorm:"varchar(255) notnull 'cluster_id'"`
	Created   time.Time     `xorm:"created"`
	Log       *Notification `xorm:"json notnull 'log'"`
}

type Component

type Component struct {
	MetaComponent
	Hosts map[string][]string `json:"hosts"`
}

type EngineConfig

type EngineConfig struct {
	SQLType      string
	ShowSQL      bool
	ShowExecTime bool
	DBPath       string
	InitSQL      string
}

type Host

type Host struct {
	ID          string `json:"id"`
	HostName    string `json:"hostname"`
	IP          string `json:"ip"`
	Description string `json:"description"`
}

type MetaComponent

type MetaComponent struct {
	ID       string                 `json:"id"`
	Name     string                 `json:"name"`
	Version  string                 `json:"version"`
	Property map[string]interface{} `json:"properties"`
}

type Notification

type Notification struct {
	Data map[string]interface{} `json:"data"`
	Now  string                 `json:"time"`
	Task struct {
		Name  string `json:"name"`
		State string `json:"state"`
	} `json:"task"`
	Stage string `json:"stage"`
	State string `json:"state"`
	Host  string `json:"host"`
}

type SQLEngine

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

func Instance

func Instance() *SQLEngine

func (*SQLEngine) CreateCluster

func (e *SQLEngine) CreateCluster(c *Cluster) error

func (*SQLEngine) CreateComponent

func (e *SQLEngine) CreateComponent(clusterID string, cp *Component) error

func (*SQLEngine) CreateHost

func (e *SQLEngine) CreateHost(clusterID string, h *Host) error

func (*SQLEngine) CreateLog

func (e *SQLEngine) CreateLog(clusterID string, n *Notification) error

func (*SQLEngine) DeleteCluster

func (e *SQLEngine) DeleteCluster(id string) error

func (*SQLEngine) DeleteComponent

func (e *SQLEngine) DeleteComponent(clusterID string, id string) error

func (*SQLEngine) DeleteHost

func (e *SQLEngine) DeleteHost(clusterID string, hostID string) error

func (*SQLEngine) DeleteLogs

func (e *SQLEngine) DeleteLogs(clusterID string) error

func (*SQLEngine) RetrieveCluster

func (e *SQLEngine) RetrieveCluster(id string) (c *Cluster, err error)

func (*SQLEngine) RetrieveClusters

func (e *SQLEngine) RetrieveClusters() ([]*Cluster, error)

func (*SQLEngine) RetrieveComponent

func (e *SQLEngine) RetrieveComponent(
	clusterID string,
	id string,
) (*Component, error)

func (*SQLEngine) RetrieveComponents

func (e *SQLEngine) RetrieveComponents(
	clusterID string,
) (cs []*Component, err error)

func (*SQLEngine) RetrieveHost

func (e *SQLEngine) RetrieveHost(
	clusterID string,
	hostID string,
) (*Host, error)

func (*SQLEngine) RetrieveHosts

func (e *SQLEngine) RetrieveHosts(
	clusterID string,
) (hs []*Host, err error)

func (*SQLEngine) RetrieveLogs

func (e *SQLEngine) RetrieveLogs(clusterID string) ([]*Notification, error)

func (*SQLEngine) UpdateCluster

func (e *SQLEngine) UpdateCluster(c *Cluster) error

func (*SQLEngine) UpdateComponent

func (e *SQLEngine) UpdateComponent(clusterID string, cp *Component) error

func (*SQLEngine) UpdateHost

func (e *SQLEngine) UpdateHost(clusterID string, h *Host) error

Jump to

Keyboard shortcuts

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