database

package
v2.1.1-rc17 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2020 License: Apache-2.0 Imports: 10 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 {
	// contains filtered or unexported fields
}

DBStorage

func (*DB) Close added in v2.1.1

func (d *DB) Close() error

Close Close

func (*DB) CountApplication added in v2.1.1

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

func (*DB) CountBatch

func (d *DB) CountBatch(ns, name string) (int, error)

func (*DB) CountBatchByCallback

func (d *DB) CountBatchByCallback(callbackName, ns string) (int, error)

func (*DB) CountBatchByCallbackTx

func (d *DB) CountBatchByCallbackTx(tx *sqlx.Tx, callbackName, ns string) (int, error)

func (*DB) CountBatchTx

func (d *DB) CountBatchTx(tx *sqlx.Tx, ns, name 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) CountRecord

func (d *DB) CountRecord(batchName, fingerprintValue, ns string) (int, error)

func (*DB) CountRecordTx

func (d *DB) CountRecordTx(tx *sqlx.Tx, batchName, fingerprintValue, ns 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) CreateApplication added in v2.1.1

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

func (*DB) CreateApplicationWithTx added in v2.1.1

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

func (*DB) CreateBatch

func (d *DB) CreateBatch(batch *models.Batch) (sql.Result, error)

func (*DB) CreateBatchTx

func (d *DB) CreateBatchTx(tx *sqlx.Tx, batch *models.Batch) (sql.Result, error)

func (*DB) CreateCallback

func (d *DB) CreateCallback(callback *models.Callback) (sql.Result, error)

func (*DB) CreateCallbackTx

func (d *DB) CreateCallbackTx(tx *sqlx.Tx, callback *models.Callback) (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) CreateRecord

func (d *DB) CreateRecord(records []models.Record) (sql.Result, error)

func (*DB) CreateRecordTx

func (d *DB) CreateRecordTx(tx *sqlx.Tx, records []models.Record) (sql.Result, 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) DeleteApplication added in v2.1.1

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

func (*DB) DeleteApplicationWithTx added in v2.1.1

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

func (*DB) DeleteBatch

func (d *DB) DeleteBatch(name, ns string) (sql.Result, error)

func (*DB) DeleteBatchTx

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

func (*DB) DeleteCallback

func (d *DB) DeleteCallback(name, ns string) (sql.Result, error)

func (*DB) DeleteCallbackTx

func (d *DB) DeleteCallbackTx(tx *sqlx.Tx, name, ns 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) DeleteRecord

func (d *DB) DeleteRecord(batchName, recordName, ns string) (sql.Result, error)

func (*DB) DeleteRecordTx

func (d *DB) DeleteRecordTx(tx *sqlx.Tx, batchName, recordName, ns string) (sql.Result, 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{}) (sql.Result, error)

func (*DB) Get added in v2.1.1

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

func (*DB) GetApplication added in v2.1.1

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

func (*DB) GetBatch

func (d *DB) GetBatch(name, ns string) (*models.Batch, error)

TODO: 抽象 batch 操作的 interface

func (*DB) GetBatchTx

func (d *DB) GetBatchTx(tx *sqlx.Tx, name, ns string) (*models.Batch, error)

func (*DB) GetCallback

func (d *DB) GetCallback(name, namespace string) (*models.Callback, error)

func (*DB) GetCallbackTx

func (d *DB) GetCallbackTx(tx *sqlx.Tx, name, namespace string) (*models.Callback, 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) GetRecord

func (d *DB) GetRecord(batchName, recordName, ns string) (*models.Record, error)

func (*DB) GetRecordByFingerprint

func (d *DB) GetRecordByFingerprint(batchName, ns, value string) (*models.Record, error)

func (*DB) GetRecordByFingerprintTx

func (d *DB) GetRecordByFingerprintTx(tx *sqlx.Tx, batchName, ns, value string) (*models.Record, error)

func (*DB) GetRecordTx

func (d *DB) GetRecordTx(tx *sqlx.Tx, batchName, recordName, ns string) (*models.Record, 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) ListApplication added in v2.1.1

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

func (*DB) ListBatch

func (d *DB) ListBatch(ns string, filter *models.Filter) ([]models.Batch, error)

func (*DB) ListBatchTx

func (d *DB) ListBatchTx(tx *sqlx.Tx, ns string, filter *models.Filter) ([]models.Batch, 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) ListRecord

func (d *DB) ListRecord(batchName, ns string, filter *models.Filter) ([]models.Record, error)

func (*DB) ListRecordByBatchTx

func (d *DB) ListRecordByBatchTx(tx *sqlx.Tx, batchName, namespace string) ([]models.Record, error)

func (*DB) ListRecordTx

func (d *DB) ListRecordTx(tx *sqlx.Tx, batchName, ns string, filter *models.Filter) ([]models.Record, 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{}) 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) UpdateApplication added in v2.1.1

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

func (*DB) UpdateApplicationWithTx added in v2.1.1

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

func (*DB) UpdateBatch

func (d *DB) UpdateBatch(batch *models.Batch) (sql.Result, error)

func (*DB) UpdateBatchTx

func (d *DB) UpdateBatchTx(tx *sqlx.Tx, batch *models.Batch) (sql.Result, error)

func (*DB) UpdateCallback

func (d *DB) UpdateCallback(callback *models.Callback) (sql.Result, error)

func (*DB) UpdateCallbackTx

func (d *DB) UpdateCallbackTx(tx *sqlx.Tx, callback *models.Callback) (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) UpdateRecord

func (d *DB) UpdateRecord(record *models.Record) (sql.Result, error)

func (*DB) UpdateRecordTx

func (d *DB) UpdateRecordTx(tx *sqlx.Tx, record *models.Record) (sql.Result, 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)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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