dbdrivers

package
v1.1.9 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetJson

func GetJson(key string) (map[string]interface{}, error)

GetJson returns a json representation of associated key.

func GetRedisCachePrefix

func GetRedisCachePrefix() string

func GetString

func GetString(key string) (string, error)

GetString returns a string val of associated key.

func InitBadgerConn

func InitBadgerConn(config BadgerConfig) *badger.DB

Initialize the Badger database.

func InitMongoMasterConn

func InitMongoMasterConn(config MongoConfig) (*mongo.Client, string)

func InitMongoTenantConns

func InitMongoTenantConns(config MongoConfig, master *gorm.DB, tenantDBPassPhraseKey string) (map[uint64]*mongo.Client, map[uint64]string)

Init the mongo database connection map.

func InitMysqlMasterConn

func InitMysqlMasterConn(config SQLConfig) (*gorm.DB, string)

InitMysqlMasterConn returns mysql master db connection.

func InitMysqlTenantConns

func InitMysqlTenantConns(config SQLConfig, master *gorm.DB, tenantDBPassPhraseKey string) (map[uint64]*gorm.DB, map[uint64]string)

func InitRedisMasterConn

func InitRedisMasterConn(config RedisConfig) (*redis.Client, int)

func InitRedisTenantConns

func InitRedisTenantConns(config RedisConfig, master *gorm.DB, tenantDBPassPhraseKey string) (map[uint64]*redis.Client, map[uint64]int)

func SetBytes

func SetBytes(key string, val []byte) error

SetBytes saves a string key and it's value in bytes into badgerdb.

func SetString

func SetString(key string, val string) error

SetString saves a string key value pair to badgerdb.

Types

type BadgerConfig

type BadgerConfig struct {
	Path     string
	InMemory bool
}

type MongoConfig

type MongoConfig struct {
	Master *struct {
		Database string
		Username string
		Password string
		Host     string
		Port     string
	}
	ConnectTimeout        time.Duration
	MaxConnectionPoolSize uint64
	MaxConnectionLifeTime time.Duration
}

type RedisConfig

type RedisConfig struct {
	Master *struct {
		Database int
		Password string
		Host     string
		Port     string
	}
	Prefix     string
	Maxretries int
}

type SQLConfig

type SQLConfig struct {
	Master *struct {
		Database string
		Username string
		Password string
		Host     string
		Port     string
	}
	MaxIdleConnections    int
	MaxOpenConnections    int
	MaxConnectionLifeTime time.Duration
	Debug                 bool
}

type TenantConnections

type TenantConnections struct {
	ID          uint64         `gorm:"primary_key;AUTO_INCREMENT;column:Id"`
	UUID        string         `gorm:"type:CHAR(36);not null;unique;column:Uuid"`
	TenantID    uint64         `gorm:"not null;column:TenantId"`
	Code        string         `gorm:"type:VARCHAR(20);not null;unique;column:Code"`
	Connections datatypes.JSON `gorm:"not null;column:Connections"`
	CreatedBy   uint64         `gorm:"not null;default:0;column:CreatedBy"`
	UpdatedBy   uint64         `gorm:"not null;default:0;column:UpdatedBy"`
	DeletedBy   uint64         `gorm:"default:NULL;column:DeletedBy"`
	CreatedAt   time.Time      `gorm:"type:timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP;column:CreatedAt"`
	UpdatedAt   time.Time      `gorm:"type:timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;column:UpdatedAt"`
	DeletedAt   gorm.DeletedAt `gorm:"type:timestamp NULL DEFAULT NULL;column:DeletedAt"`
}

TenantConnections represent a tenant database configuration record in master database

func GetAllTenantCfgs

func GetAllTenantCfgs(db *gorm.DB) []*TenantConnections

GetAllTenantCfgs return all Tenant data from master db.

func (TenantConnections) TableName

func (TenantConnections) TableName() string

Jump to

Keyboard shortcuts

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