persistencemgr

package
v0.0.0-...-695150b Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2020 License: Apache-2.0 Imports: 10 Imported by: 1

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Port     string
	Protocol string
	Host     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

func GetMockDBConfig() (*Config, *errors.Error)

GetMockDBConfig will initiate mock db and will provide the config file

func (*Config) Connection

func (c *Config) Connection() (*ConnPool, *errors.Error)

Connection returns connection pool Connection does not take any input and returns a connection object used to interact with the DB

type ConnPool

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

ConnPool is the established connection

func MockDBConnection

func MockDBConnection() (*ConnPool, *errors.Error)

MockDBConnection provides a mock db for unit testing

func (*ConnPool) AddResourceData

func (p *ConnPool) AddResourceData(table, key string, data interface{}) *errors.Error

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

func (p *ConnPool) CleanUpDB() *errors.Error

CleanUpDB will delete all database entries The flush command will be executed without warnings please be cautious in using this

func (*ConnPool) Create

func (p *ConnPool) Create(table, key string, data interface{}) *errors.Error

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

func (p *ConnPool) CreateEvtSubscriptionIndex(index string, key interface{}) error

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

func (p *ConnPool) CreateIndex(form map[string]interface{}, uuid string) error

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

func (p *ConnPool) CreateTaskIndex(index string, value int64, key string) error

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

func (p *ConnPool) Del(index, key string) error

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

func (p *ConnPool) Delete(table, key string) *errors.Error

Delete data entry Read takes "key" sting as input which acts as a unique ID to delete specific data from DB

func (*ConnPool) DeleteDeviceSubscription

func (p *ConnPool) DeleteDeviceSubscription(index, hostIP string) error

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

func (p *ConnPool) DeleteEvtSubscriptions(index, removeKey string) error

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

func (p *ConnPool) DeleteServer(key string) *errors.Error

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

func (p *ConnPool) GetAllDetails(table string) ([]string, *errors.Error)

GetAllDetails will fetch all the keys present in the database

func (*ConnPool) GetAllMatchingDetails

func (p *ConnPool) GetAllMatchingDetails(table, pattern string) ([]string, *errors.Error)

GetAllMatchingDetails will fetch all the keys which matches pattern present in the database

func (*ConnPool) GetDeviceSubscription

func (p *ConnPool) GetDeviceSubscription(index string, match string) ([]string, error)

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

func (p *ConnPool) GetEvtSubscriptions(index, searchKey string) ([]string, error)

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

func (p *ConnPool) GetRange(index string, min, max int, regexFlag bool) ([]string, error)

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

func (p *ConnPool) GetResourceDetails(key string) (string, *errors.Error)

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

func (p *ConnPool) GetTaskList(index string, min, max int) ([]string, error)

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) Ping

func (p *ConnPool) Ping() error

Ping will check the DB connection health

func (*ConnPool) Read

func (p *ConnPool) Read(table, key string) (string, *errors.Error)

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

func (p *ConnPool) Transaction(key string, cb func(string) error) *errors.Error

Transaction is to do a atomic operation using optimistic lock

func (*ConnPool) Update

func (p *ConnPool) Update(table, key string, data interface{}) (string, *errors.Error)

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

func (p *ConnPool) UpdateEvtSubscriptions(index, subscritionID string, key interface{}) error

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

func (p *ConnPool) UpdateResourceIndex(form map[string]interface{}, uuid string) error

UpdateResourceIndex is used to update the resource inforamtion which is indexed form contains index name and value:key for the index

Jump to

Keyboard shortcuts

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