database

package
v2.2.0-rc8 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() (plugin.Plugin, error)

New New

Types

type CloudConfig

type CloudConfig struct {
	Database struct {
		Type            string `yaml:"type" json:"type" validate:"nonzero"`
		URL             string `yaml:"url" json:"url" validate:"nonzero"`
		MaxConns        int    `yaml:"maxConns" json:"maxConns" default:20`
		MaxIdleConns    int    `yaml:"maxIdleConns" json:"maxIdleConns" default:5`
		ConnMaxLifetime int    `yaml:"connMaxLifetime" json:"connMaxLifetime" default:150`
	} `yaml:"database" json:"database" default:"{}"`
}

CloudConfig baetyl-cloud config

type DB added in v2.1.1

type DB struct {
	Log *log.Logger
	// contains filtered or unexported fields
}

DBStorage

func NewDB added in v2.1.1

func NewDB(cfg CloudConfig) (*DB, error)

func (*DB) Close added in v2.1.1

func (d *DB) Close() (err error)

Close Close

func (*DB) CountApplicationHis

func (d *DB) CountApplicationHis(tx *sqlx.Tx, name, namespace string) (int, error)

func (DB) CountCertByParentId added in v2.1.1

func (d DB) CountCertByParentId(parentId string) (int, error)

func (*DB) CountProperty added in v2.1.1

func (d *DB) CountProperty(name string) (int, error)

func (*DB) CountTask added in v2.1.1

func (d *DB) CountTask(task *models.Task) (int, error)

func (*DB) Create added in v2.1.1

func (d *DB) Create(shadow *models.Shadow) (*models.Shadow, error)

func (*DB) CreateApplicationHis

func (d *DB) CreateApplicationHis(app *specV1.Application) (sql.Result, error)

func (*DB) CreateApplicationHisWithTx

func (d *DB) CreateApplicationHisWithTx(tx *sqlx.Tx, app *specV1.Application) (sql.Result, error)

func (DB) CreateCert added in v2.1.1

func (d DB) CreateCert(cert plugin.Cert) error

func (*DB) CreateIndex added in v2.1.1

func (d *DB) CreateIndex(namespace string, keyA, keyB common.Resource, valueA, valueB string) (sql.Result, error)

func (*DB) CreateIndexTx added in v2.1.1

func (d *DB) CreateIndexTx(tx *sqlx.Tx, namespace string, keyA, keyB common.Resource, valueA, valueB string) (sql.Result, error)

func (*DB) CreateProperty added in v2.1.1

func (d *DB) CreateProperty(property *models.Property) error

func (*DB) CreateShadowTx added in v2.1.1

func (d *DB) CreateShadowTx(tx *sqlx.Tx, shadow *models.Shadow) (sql.Result, error)

func (*DB) CreateTask added in v2.1.1

func (d *DB) CreateTask(task *models.Task) (sql.Result, error)

func (*DB) CreateTaskTx added in v2.1.1

func (d *DB) CreateTaskTx(tx *sqlx.Tx, task *models.Task) (sql.Result, error)

func (*DB) Delete added in v2.1.1

func (d *DB) Delete(namespace, name string) error

func (*DB) DeleteApplicationHis

func (d *DB) DeleteApplicationHis(name, namespace, version string) (sql.Result, error)

func (*DB) DeleteApplicationHisWithTx

func (d *DB) DeleteApplicationHisWithTx(tx *sqlx.Tx, name, namespace, version string) (sql.Result, error)

func (DB) DeleteCert added in v2.1.1

func (d DB) DeleteCert(certId string) error

func (*DB) DeleteIndex added in v2.1.1

func (d *DB) DeleteIndex(namespace string, keyA, byKeyB common.Resource, valueB string) (sql.Result, error)

func (*DB) DeleteIndexTx added in v2.1.1

func (d *DB) DeleteIndexTx(tx *sqlx.Tx, namespace string, keyA, byKeyB common.Resource, valueB string) (sql.Result, error)

func (*DB) DeleteProperty added in v2.1.1

func (d *DB) DeleteProperty(name string) error

func (*DB) DeleteShadowTx added in v2.1.1

func (d *DB) DeleteShadowTx(tx *sqlx.Tx, namespace, name string) (sql.Result, error)

func (*DB) DeleteTask added in v2.1.1

func (d *DB) DeleteTask(traceId string) (sql.Result, error)

func (*DB) DeleteTaskTx added in v2.1.1

func (d *DB) DeleteTaskTx(tx *sqlx.Tx, traceId string) (sql.Result, error)

func (*DB) Exec added in v2.1.1

func (d *DB) Exec(tx *sqlx.Tx, sql string, args ...interface{}) (res sql.Result, err error)

func (*DB) Get added in v2.1.1

func (d *DB) Get(namespace, name string) (*models.Shadow, error)

func (*DB) GetApplicationHis

func (d *DB) GetApplicationHis(name, namespace, version string) (*specV1.Application, error)

func (DB) GetCert added in v2.1.1

func (d DB) GetCert(certId string) (*plugin.Cert, error)

func (*DB) GetProperty added in v2.1.1

func (d *DB) GetProperty(name string) (*models.Property, error)

func (*DB) GetPropertyValue added in v2.1.1

func (d *DB) GetPropertyValue(name string) (string, error)

func (*DB) GetShadowTx added in v2.1.1

func (d *DB) GetShadowTx(tx *sqlx.Tx, namespace, name string) (*models.Shadow, error)

func (*DB) GetTask added in v2.1.1

func (d *DB) GetTask(traceId string) (*models.Task, error)

func (*DB) GetTaskTx added in v2.1.1

func (d *DB) GetTaskTx(tx *sqlx.Tx, traceId string) (*models.Task, error)

func (*DB) List added in v2.1.1

func (d *DB) List(namespace string, nodeList *models.NodeList) (*models.ShadowList, error)

func (*DB) ListApplicationHis

func (d *DB) ListApplicationHis(namespace string, filter *models.Filter) ([]specV1.Application, error)

func (*DB) ListIndex added in v2.1.1

func (d *DB) ListIndex(namespace string, keyA, byKeyB common.Resource, valueB string) ([]string, error)

func (*DB) ListIndexTx added in v2.1.1

func (d *DB) ListIndexTx(tx *sqlx.Tx, namespace string, keyA, byKeyB common.Resource, valueB string) ([]string, error)

func (*DB) ListProperty added in v2.1.1

func (d *DB) ListProperty(filter *models.Filter) ([]models.Property, error)

func (*DB) ListShadowByNamesTx added in v2.1.1

func (d *DB) ListShadowByNamesTx(tx *sqlx.Tx, namespace string, names []string) ([]entities.Shadow, error)

func (*DB) Query added in v2.1.1

func (d *DB) Query(tx *sqlx.Tx, sql string, data interface{}, args ...interface{}) (err error)

func (*DB) RefreshIndex added in v2.1.1

func (d *DB) RefreshIndex(namespace string, keyA, keyB common.Resource, valueA string, valueBs []string) error

func (*DB) Transact added in v2.1.1

func (d *DB) Transact(handler func(*sqlx.Tx) error) (err error)

func (*DB) UpdateApplicationHis

func (d *DB) UpdateApplicationHis(app *specV1.Application, oldVersion string) (sql.Result, error)

func (*DB) UpdateApplicationHisWithTx

func (d *DB) UpdateApplicationHisWithTx(tx *sqlx.Tx, app *specV1.Application, oldVersion string) (sql.Result, error)

func (DB) UpdateCert added in v2.1.1

func (d DB) UpdateCert(cert plugin.Cert) error

func (*DB) UpdateDesire added in v2.1.1

func (d *DB) UpdateDesire(shadow *models.Shadow) (*models.Shadow, error)

func (*DB) UpdateProperty added in v2.1.1

func (d *DB) UpdateProperty(property *models.Property) error

func (*DB) UpdateReport added in v2.1.1

func (d *DB) UpdateReport(shadow *models.Shadow) (*models.Shadow, error)

func (*DB) UpdateShadowDesireTx added in v2.1.1

func (d *DB) UpdateShadowDesireTx(tx *sqlx.Tx, shadow *models.Shadow) (sql.Result, error)

func (*DB) UpdateShadowReportTx added in v2.1.1

func (d *DB) UpdateShadowReportTx(tx *sqlx.Tx, shadow *models.Shadow) (sql.Result, error)

func (*DB) UpdateTask added in v2.1.1

func (d *DB) UpdateTask(task *models.Task) (sql.Result, error)

func (*DB) UpdateTaskTx added in v2.1.1

func (d *DB) UpdateTaskTx(tx *sqlx.Tx, task *models.Task) (sql.Result, error)

type DBStorage added in v2.1.1

type DBStorage interface {
	Transact(func(*sqlx.Tx) error) error
	Exec(tx *sqlx.Tx, sql string, args ...interface{}) (sql.Result, error)
	Query(tx *sqlx.Tx, sql string, data interface{}, args ...interface{}) error

	io.Closer
}

DBStorage

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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