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 ¶
- func GetCurrentMasterHostPort(dbConfig *Config) (string, string, error)
- func IsRetriable(err error) bool
- type Config
- type Conn
- type ConnPool
- func (p *ConnPool) AddMemberToSet(key string, member string) *errors.Error
- 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) CreateAggregateHostIndex(index, aggregateID string, hostIP []string) 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) Decr(table, key string) (int, *errors.Error)
- func (p *ConnPool) Del(index string, k string) error
- func (p *ConnPool) Delete(table, key string) *errors.Error
- func (p *ConnPool) DeleteAggregateHosts(index, aggregateID string) error
- func (p *ConnPool) DeleteDeviceSubscription(index, hostIP string) error
- func (p *ConnPool) DeleteEvtSubscriptions(index, removeKey string) error
- func (p *ConnPool) DeleteKey(key string) *errors.Error
- func (p *ConnPool) DeleteMultipleKeys(keys []string) *errors.Error
- func (p *ConnPool) DeleteServer(key string) *errors.Error
- func (p *ConnPool) EnableKeySpaceNotifier(notifierType, filterType string) *errors.Error
- func (p *ConnPool) FindOrNull(table, key string) (string, error)
- func (p *ConnPool) GetAggregateHosts(index string, match string) ([]string, error)
- func (p *ConnPool) GetAllDataByIndex(index string) ([]string, error)
- func (p *ConnPool) GetAllDetails(table string) ([]string, *errors.Error)
- func (p *ConnPool) GetAllKeysFromDb(table, pattern string, nextCursor int) ([]string, int, *errors.Error)
- func (p *ConnPool) GetAllMatchingDetails(table, pattern string) ([]string, *errors.Error)
- func (p *ConnPool) GetAllMembersInSet(key 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) GetKeyValue(key string) (string, *errors.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) GetWriteConnection() (*Conn, *errors.Error)
- func (p *ConnPool) Incr(table, key string) (int, *errors.Error)
- func (p *ConnPool) Ping() error
- func (p *ConnPool) Read(table, key string) (string, *errors.Error)
- func (p *ConnPool) ReadMultipleKeys(key []string) ([]string, *errors.Error)
- func (p *ConnPool) RemoveMemberFromSet(key string, member string) *errors.Error
- func (p *ConnPool) SaveBMCInventory(data map[string]interface{}) *errors.Error
- func (p *ConnPool) SaveUndeliveredEvents(table, key string, data []byte) *errors.Error
- func (p *ConnPool) SetExpire(table, key string, data interface{}, expiretime int) *errors.Error
- func (p *ConnPool) TTL(table, key string) (int, *errors.Error)
- func (p *ConnPool) Transaction(ctx context.Context, key string, cb func(context.Context, string) error) *errors.Error
- func (p *ConnPool) Update(table, key string, data interface{}) (string, *errors.Error)
- func (p *ConnPool) UpdateAggregateHosts(index, aggregateID string, hostIP []string) 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
- func (p *ConnPool) Upsert(table, key string, data interface{}) *errors.Error
- type DbType
- type RedisExternalCalls
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetCurrentMasterHostPort ¶
GetCurrentMasterHostPort is to get the current Redis Master IP and Port from Sentinel.
func IsRetriable ¶
IsRetriable checks fi the redis db operation can be retried or not by validating the error returned by redis
Types ¶
type Config ¶
type Config struct { Port string Protocol string Host string SentinelHost string SentinelPort string MasterSet string Password string }
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 Conn ¶
Conn contains the write connection instance retrieved from the connection pool
func MockDBWriteConnection ¶
MockDBWriteConnection provides a mock db write connection for unit testing
func (*Conn) Close ¶
func (c *Conn) Close()
Close closes the write connection retrieved from the connection pool
func (*Conn) SetExpiryTimeForKeys ¶
SetExpiryTimeForKeys will create the expiry time using pipelined transaction
SetExpiryTimeForKeys takes the taskID as input:
func (*Conn) UpdateTransaction ¶
UpdateTransaction will update the database using pipelined transaction
UpdateTransaction takes the following keys as input:
1."data" is of type map[string]interface{} and is the user data sent to be updated in DB. key of map should be the key in database.
type ConnPool ¶
type ConnPool struct { ReadPool *redis.Client WritePool *redis.Client MasterIP string Mux sync.Mutex }
ConnPool is the established connection
func GetDBConnection ¶
GetDBConnection is used to get the new Connection Pool for Inmemory/OnDisk DB
func MockDBConnection ¶
MockDBConnection provides a mock db for unit testing
func (*ConnPool) AddMemberToSet ¶
AddMemberToSet add a member to the redis set Following are the input parameters for adding member to redis set: 1. key - redis set name 2. member - member id that to be added to the redis set
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) CreateAggregateHostIndex ¶
CreateAggregateHostIndex is used to create and save secondary index
CreateAggregateHostIndex 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) 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) Decr ¶
Decr is for decrementing the count Decr takes "key" string as input which acts as a unique ID to decrement the count and return same
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) DeleteAggregateHosts ¶
DeleteAggregateHosts is for to Delete subscription details of aggregate 1. index is the name of the index to be created 2. removeKey is string parameter for remove
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) DeleteKey ¶
DeleteKey takes "key" sting as input which acts as a unique ID to delete specific data from DB
func (*ConnPool) DeleteMultipleKeys ¶
DeleteMultipleKeys data entry takes "keys" array of sting as input to delete data from DB at once
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) EnableKeySpaceNotifier ¶
EnableKeySpaceNotifier enable keyspace event notifications takes notifierType ad filterType as input to set value to filter redis event
func (*ConnPool) FindOrNull ¶
FindOrNull is a wrapper for Read function. If requested asset doesn't exist errors.DBKeyNotFound error returned by Read is converted to nil
func (*ConnPool) GetAggregateHosts ¶
GetAggregateHosts 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) GetAllDataByIndex ¶
GetAllDataByIndex - This function retrieves all data for a given index from sorted sets This maybe used to get all event/device subscriptions and aggregate hosts
func (*ConnPool) GetAllDetails ¶
GetAllDetails will fetch all the keys present in the database
func (*ConnPool) GetAllKeysFromDb ¶
func (p *ConnPool) GetAllKeysFromDb(table, pattern string, nextCursor int) ([]string, int, *errors.Error)
GetAllKeysFromDb will fetch all the keys which matches pattern present in the database using scan command, return list of key and nextCursor
func (*ConnPool) GetAllMatchingDetails ¶
GetAllMatchingDetails will fetch all the keys which matches pattern present in the database
func (*ConnPool) GetAllMembersInSet ¶
GetAllMembersInSet get all members in a redis set Following are the input parameters to get embers from redis set: 1. key - redis set name
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) GetKeyValue ¶
GetKeyValue takes "key" sting as input which acts as a unique ID to fetch specific data from DB
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) GetWriteConnection ¶
GetWriteConnection retrieve a write connection from the connection pool
func (*ConnPool) Incr ¶
Incr is for incrementing the count Incr takes "key" string as input which acts as a unique ID to increment the count and return same
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) ReadMultipleKeys ¶
ReadMultipleKeys function is used to read data for multiple keys from DB
func (*ConnPool) RemoveMemberFromSet ¶
RemoveMemberFromSet removes a member from the redis set Following are the input parameters for removing member from redis set: 1. key - redis set name 2. member - member id that to be added to the redis set
func (*ConnPool) SaveBMCInventory ¶
SaveBMCInventory function save all bmc inventory data togeter using the transaction model
func (*ConnPool) SaveUndeliveredEvents ¶
SaveUndeliveredEvents method store undelivered event data in db takes table name ,key data and connection pool as input
func (*ConnPool) SetExpire ¶
SetExpire key to hold the string value and set key to timeout after a given number of seconds
SetExpire 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. 4. "expiretime" is of type int, which acts as expiry time for the key
func (*ConnPool) TTL ¶
TTL is for getting singular data TTL takes "key" string as input which acts as a unique ID to fetch time left
func (*ConnPool) Transaction ¶
func (p *ConnPool) Transaction(ctx context.Context, key string, cb func(context.Context, string) error) *errors.Error
Transaction is to do a atomic operation using optimistic lock
func (*ConnPool) Update ¶
Update data
Update take the following keys 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) UpdateAggregateHosts ¶
UpdateAggregateHosts 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) 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
func (*ConnPool) UpdateResourceIndex ¶
UpdateResourceIndex is used to update the resource inforamtion which is indexed form contains index name and value:key for the index
func (*ConnPool) Upsert ¶
Upsert will insert new data in DB if the key does not exist. else it will update the existing key
Upsert 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 user data which is of type interface sent by the user to update/patch the already existing data
type RedisExternalCalls ¶
type RedisExternalCalls interface {
// contains filtered or unexported methods
}
RedisExternalCalls containes the methods to make calls to external client libraries of Redis DB
func NewRedisExternalCalls ¶
func NewRedisExternalCalls() RedisExternalCalls
NewRedisExternalCalls is Constructor for RedisExternalCalls