dbutils

package
v0.0.0-...-613b6cb Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2017 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DB_CONNECT_TIME_INTERVAL   = 2
	DB_CONNECT_RETRY_LOG_COUNT = 100
)

Variables

This section is empty.

Functions

func ConvertBoolToInt

func ConvertBoolToInt(val bool) int

func ConvertIntToBool

func ConvertIntToBool(val int) bool

func ConvertStrBoolIntToBool

func ConvertStrBoolIntToBool(val string) bool

func ConvertStringToBool

func ConvertStringToBool(val string) bool

func ExecuteSQLStmt

func ExecuteSQLStmt(dbCmd string, dbHdl *sql.DB) (driver.Result, error)

Types

type DBIntf

type DBIntf interface {
	Connect() error
	Disconnect()
	StoreObjectInDb(objects.ConfigObj) error
	StoreObjectDefaultInDb(objects.ConfigObj) error
	DeleteObjectFromDb(objects.ConfigObj) error
	GetObjectFromDb(objects.ConfigObj, string) (objects.ConfigObj, error)
	GetKey(objects.ConfigObj) string
	GetAllObjFromDb(objects.ConfigObj) ([]objects.ConfigObj, error)
	CompareObjectsAndDiff(objects.ConfigObj, map[string]bool, objects.ConfigObj) ([]bool, error)
	CompareObjectDefaultAndDiff(objects.ConfigObj, objects.ConfigObj) ([]bool, error)
	UpdateObjectInDb(objects.ConfigObj, objects.ConfigObj, []bool) error
	MergeDbAndConfigObj(objects.ConfigObj, objects.ConfigObj, []bool) (objects.ConfigObj, error)
	GetBulkObjFromDb(obj objects.ConfigObj, startIndex, count int64) (error, int64, int64, bool, []objects.ConfigObj)
	Publish(string, interface{}, interface{})
	StoreValInDb(interface{}, interface{}, interface{}) error
	DeleteValFromDb(interface{}) error
	GetAllKeys(interface{}) (interface{}, error)
	GetValFromDB(key interface{}, field interface{}) (val interface{}, err error)
	StoreEventObjectInDb(events.EventObj) error
	GetEventObjectFromDb(events.EventObj, string) (events.EventObj, error)
	GetAllEventObjFromDb(events.EventObj) ([]events.EventObj, error)
	MergeDbAndConfigObjForPatchUpdate(objects.ConfigObj, objects.ConfigObj, []objects.PatchOpInfo) (objects.ConfigObj, []bool, error)
	StoreUUIDToObjKeyMap(objKey string) (string, error)
	DeleteUUIDToObjKeyMap(uuid, objKey string) error
	GetUUIDFromObjKey(objKey string) (string, error)
	GetObjKeyFromUUID(uuid string) (string, error)
	MergeDbObjKeys(obj, dbObj objects.ConfigObj) (objects.ConfigObj, error)
}

type DBNotConnectedError

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

func (DBNotConnectedError) Error

func (e DBNotConnectedError) Error() string

type DBUtil

type DBUtil struct {
	redis.Conn

	DbLock sync.RWMutex
	// contains filtered or unexported fields
}

func NewDBUtil

func NewDBUtil(logger logging.LoggerIntf) *DBUtil

func (*DBUtil) CompareObjectDefaultAndDiff

func (db *DBUtil) CompareObjectDefaultAndDiff(obj objects.ConfigObj, inObj objects.ConfigObj) (
	[]bool, error)

func (*DBUtil) CompareObjectsAndDiff

func (db *DBUtil) CompareObjectsAndDiff(obj objects.ConfigObj, updateKeys map[string]bool, inObj objects.ConfigObj) (
	[]bool, error)

func (*DBUtil) Connect

func (db *DBUtil) Connect() error

func (*DBUtil) DeleteObjectFromDb

func (db *DBUtil) DeleteObjectFromDb(obj objects.ConfigObj) error

func (*DBUtil) DeleteObjectWithKeyFromDb

func (db *DBUtil) DeleteObjectWithKeyFromDb(key interface{}) error

func (*DBUtil) DeleteUUIDToObjKeyMap

func (db *DBUtil) DeleteUUIDToObjKeyMap(uuid, objKey string) error

func (*DBUtil) DeleteValFromDb

func (db *DBUtil) DeleteValFromDb(key interface{}) error

func (*DBUtil) Disconnect

func (db *DBUtil) Disconnect()

func (*DBUtil) GetAllEventObjFromDb

func (db *DBUtil) GetAllEventObjFromDb(obj events.EventObj) ([]events.EventObj, error)

func (*DBUtil) GetAllKeys

func (db *DBUtil) GetAllKeys(pattern interface{}) (val interface{}, err error)

func (*DBUtil) GetAllObjFromDb

func (db *DBUtil) GetAllObjFromDb(obj objects.ConfigObj) ([]objects.ConfigObj, error)

func (*DBUtil) GetBulkObjFromDb

func (db *DBUtil) GetBulkObjFromDb(obj objects.ConfigObj, startIndex, count int64) (error, int64, int64, bool,
	[]objects.ConfigObj)

func (*DBUtil) GetEventObjectFromDb

func (db *DBUtil) GetEventObjectFromDb(obj events.EventObj, objKey string) (events.EventObj, error)

func (*DBUtil) GetKey

func (db *DBUtil) GetKey(obj objects.ConfigObj) string

func (*DBUtil) GetObjKeyFromUUID

func (db *DBUtil) GetObjKeyFromUUID(uuid string) (string, error)

func (*DBUtil) GetObjectFromDb

func (db *DBUtil) GetObjectFromDb(obj objects.ConfigObj, objKey string) (objects.ConfigObj, error)

func (*DBUtil) GetUUIDFromObjKey

func (db *DBUtil) GetUUIDFromObjKey(objKey string) (string, error)

func (*DBUtil) GetValFromDB

func (db *DBUtil) GetValFromDB(key interface{}, field interface{}) (val interface{}, err error)

func (*DBUtil) MergeDbAndConfigObj

func (db *DBUtil) MergeDbAndConfigObj(obj, dbObj objects.ConfigObj, attrSet []bool) (objects.ConfigObj, error)

func (*DBUtil) MergeDbAndConfigObjForPatchUpdate

func (db *DBUtil) MergeDbAndConfigObjForPatchUpdate(obj, dbObj objects.ConfigObj, patchInfo []objects.PatchOpInfo) (objects.ConfigObj, []bool, error)

func (*DBUtil) MergeDbObjKeys

func (db *DBUtil) MergeDbObjKeys(obj, dbObj objects.ConfigObj) (objects.ConfigObj, error)

func (*DBUtil) Publish

func (db *DBUtil) Publish(op string, channel interface{}, msg interface{})

func (*DBUtil) StoreEventObjectInDb

func (db *DBUtil) StoreEventObjectInDb(obj events.EventObj) error

func (*DBUtil) StoreObjectDefaultInDb

func (db *DBUtil) StoreObjectDefaultInDb(obj objects.ConfigObj) error

func (*DBUtil) StoreObjectInDb

func (db *DBUtil) StoreObjectInDb(obj objects.ConfigObj) error

func (*DBUtil) StoreUUIDToObjKeyMap

func (db *DBUtil) StoreUUIDToObjKeyMap(objKey string) (string, error)

func (*DBUtil) StoreValInDb

func (db *DBUtil) StoreValInDb(key interface{}, val interface{}, field interface{}) error

func (*DBUtil) UpdateObjectInDb

func (db *DBUtil) UpdateObjectInDb(obj, inObj objects.ConfigObj, attrSet []bool) error

Jump to

Keyboard shortcuts

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