Documentation ¶
Overview ¶
Package persistencemgr provides an interfaces for database communication
Package persistencemgr provides an interfaces for database communication ¶
Package persistencemgr provides an interfaces for database communication
Index ¶
- type Config
- type ConnPool
- func (p *ConnPool) AddResourceData(table, key string, data interface{}) *errors.Error
- func (p *ConnPool) CleanUpDB() *errors.Error
- func (p *ConnPool) Create(table, key string, data interface{}) *errors.Error
- func (p *ConnPool) CreateDeviceSubscriptionIndex(index, hostIP, location string, originResources []string) error
- func (p *ConnPool) CreateEvtSubscriptionIndex(index string, key interface{}) error
- func (p *ConnPool) CreateIndex(form map[string]interface{}, uuid string) error
- func (p *ConnPool) CreateTaskIndex(index string, value int64, key string) error
- func (p *ConnPool) Del(index, key string) error
- func (p *ConnPool) Delete(table, key string) *errors.Error
- func (p *ConnPool) DeleteDeviceSubscription(index, hostIP string) error
- func (p *ConnPool) DeleteEvtSubscriptions(index, removeKey string) error
- func (p *ConnPool) DeleteServer(key string) *errors.Error
- func (p *ConnPool) GetAllDetails(table string) ([]string, *errors.Error)
- func (p *ConnPool) GetAllMatchingDetails(table, pattern string) ([]string, *errors.Error)
- func (p *ConnPool) GetDeviceSubscription(index string, match string) ([]string, error)
- func (p *ConnPool) GetEvtSubscriptions(index, searchKey string) ([]string, error)
- func (p *ConnPool) GetRange(index string, min, max int, regexFlag bool) ([]string, error)
- func (p *ConnPool) GetResourceDetails(key string) (string, *errors.Error)
- func (p *ConnPool) GetStorageList(index string, cursor, match float64, condition string, regexFlag bool) ([]string, error)
- func (p *ConnPool) GetString(index string, cursor float64, match string, regexFlag bool) ([]string, error)
- func (p *ConnPool) GetTaskList(index string, min, max int) ([]string, error)
- func (p *ConnPool) Ping() error
- func (p *ConnPool) Read(table, key string) (string, *errors.Error)
- func (p *ConnPool) Transaction(key string, cb func(string) error) *errors.Error
- func (p *ConnPool) Update(table, key string, data interface{}) (string, *errors.Error)
- func (p *ConnPool) UpdateDeviceSubscription(index, hostIP, location string, originResources []string) error
- func (p *ConnPool) UpdateEvtSubscriptions(index, subscritionID string, key interface{}) error
- func (p *ConnPool) UpdateResourceIndex(form map[string]interface{}, uuid string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
Config is the configuration for db which is set by the wrapper package.
Port is the port number for the database connection Protocol is the type of protocol with which the connection takes place Host is hostname/IP on which the database is running
func GetMockDBConfig ¶
GetMockDBConfig will initiate mock db and will provide the config file
type ConnPool ¶
type ConnPool struct {
// contains filtered or unexported fields
}
ConnPool is the established connection
func MockDBConnection ¶
MockDBConnection provides a mock db for unit testing
func (*ConnPool) AddResourceData ¶
AddResourceData will make an entry into the database with the given values
AddResourceData takes the following keys as input:
1."table" is a string which is used identify what kind of data we are storing. 2."data" is of type interface and is the userdata sent to be stored in DB. 3."key" is a string which acts as a unique ID to the data entry.
func (*ConnPool) CleanUpDB ¶
CleanUpDB will delete all database entries The flush command will be executed without warnings please be cautious in using this
func (*ConnPool) Create ¶
Create will make an entry into the database with the given values
Create takes the following keys as input:
1."table" is a string which is used identify what kind of data we are storing. 2."data" is of type interface and is the userdata sent to be stored in DB. 3."key" is a string which acts as a unique ID to the data entry.
func (*ConnPool) CreateDeviceSubscriptionIndex ¶
func (p *ConnPool) CreateDeviceSubscriptionIndex(index, hostIP, location string, originResources []string) error
CreateDeviceSubscriptionIndex is used to create and save secondary index
CreateDeviceSubscriptionIndex take the following keys are input:
1. index is the name of the index to be created 2. key is for the index
func (*ConnPool) CreateEvtSubscriptionIndex ¶
CreateEvtSubscriptionIndex is used to create and save secondary index
CreateSubscriptionIndex take the following keys are input:
1. index is the name of the index to be created 2. key and value are the key value pair for the index
func (*ConnPool) CreateIndex ¶
CreateIndex is used to create and save secondary index
CreateIndex take the following keys are input:
1. form is a map of the index to be created and the data along with it 2. uuid is the resource id with witch the value is stored
func (*ConnPool) CreateTaskIndex ¶
CreateTaskIndex is used to create secondary indexing for task service Following are the input parameters for creating task index: 1. index name 2. value takes the Endtime for sorting with range 3. key if of the format `UserName::Endtime::TaskID`
func (*ConnPool) Del ¶
Del is used to delete the index key
1. index is the name of the index under which the key needs to be deleted 2. key is the id of the resource to be deleted under an index
func (*ConnPool) Delete ¶
Delete data entry Read takes "key" sting as input which acts as a unique ID to delete specific data from DB
func (*ConnPool) DeleteDeviceSubscription ¶
DeleteDeviceSubscription is for to Delete subscription details of Device 1. index is the name of the index to be created 2. removeKey is string parameter for remove
func (*ConnPool) DeleteEvtSubscriptions ¶
DeleteEvtSubscriptions is for to Delete subscription details 1. index is the name of the index to be created 2. removeKey is string parameter for remove
func (*ConnPool) DeleteServer ¶
DeleteServer data entry without table Read takes "key" sting as input which acts as a unique ID to delete specific data from DB
func (*ConnPool) GetAllDetails ¶
GetAllDetails will fetch all the keys present in the database
func (*ConnPool) GetAllMatchingDetails ¶
GetAllMatchingDetails will fetch all the keys which matches pattern present in the database
func (*ConnPool) GetDeviceSubscription ¶
GetDeviceSubscription is used to retrive index values of type string
Inputs:
1. index is the index name to search with 2. match is the value to match with
TODO : Handle cursor
func (*ConnPool) GetEvtSubscriptions ¶
GetEvtSubscriptions is for to get subscription details 1. index is the name of the index to be created 2. searchKey is for search TODO: Add support for cursors and multiple data
func (*ConnPool) GetRange ¶
GetRange is used to range over float type values
1. index is the name of the index to search under 2. min is the minimum value for the search 3. max is the maximum value for the search
func (*ConnPool) GetResourceDetails ¶
GetResourceDetails will fetch the key and also fetch the data
func (*ConnPool) GetStorageList ¶
func (p *ConnPool) GetStorageList(index string, cursor, match float64, condition string, regexFlag bool) ([]string, error)
GetStorageList is used to storage list of capacity
1.index name to search with 2. cursor is the redis cursor value 3. match is the search for list float type 4. condition is the value for condition operation
func (*ConnPool) GetString ¶
func (p *ConnPool) GetString(index string, cursor float64, match string, regexFlag bool) ([]string, error)
GetString is used to retrive index values of type string
Inputs:
1. index is the index name to search with 2. cursor is the redis db cursor value 3. match is the value to match with
func (*ConnPool) GetTaskList ¶
GetTaskList is used to range over float type values
1. index is the name of the index to search under 2. min is the minimum value for the search 3. max is the maximum value for the search
func (*ConnPool) Read ¶
Read is for getting singular data Read takes "key" sting as input which acts as a unique ID to fetch specific data from DB
func (*ConnPool) Transaction ¶
Transaction is to do a atomic operation using optimistic lock
func (*ConnPool) Update ¶
Update data
Update take the following leys as input:
1."uid" is a string which acts as a unique ID to fetch the data from the DB 2."data" is userdata which is of type interface sent by the user to update/patch the already existing data
func (*ConnPool) UpdateDeviceSubscription ¶
func (p *ConnPool) UpdateDeviceSubscription(index, hostIP, location string, originResources []string) error
UpdateDeviceSubscription is for to Update subscription details 1. index is the name of the index to be created 2. key and value are the key value pair for the index
func (*ConnPool) UpdateEvtSubscriptions ¶
UpdateEvtSubscriptions is for to Update subscription details 1. index is the name of the index to be created 2. key and value are the key value pair for the index