dbkvconfig

package module
v0.0.0-...-7f9ecc1 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2020 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DefaultApplication = "Default-Application"
	KeyRedisDefault    = "dbkvconfiglistener"
)

Const Default Config

View Source
const (
	ConfigNotFoundMsg   = "ConfigNotFound"
	UpdateTooFast       = "UpdateConfigIsTooFast"
	OnlyInsertNewConfig = "OnlyInsertNewConfig"
)

Const For Error

Variables

This section is empty.

Functions

This section is empty.

Types

type DBKVCfg

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

DBKVCfg struct library DBKV Config

func NewDBKVConfig

func NewDBKVConfig(listKey []KeyValueInit, master, slave *sqlx.DB, redisPool *redis.Pool, opts ...OptionsCfg) (*DBKVCfg, error)

NewDBKVConfig Init Library support slave master DB

func (*DBKVCfg) GetConfig

func (dbkv *DBKVCfg) GetConfig(key string) (interface{}, error)

GetConfig func to get config return interface

func (*DBKVCfg) InsertConfig

func (dbkv *DBKVCfg) InsertConfig(key, value string) error

InsertConfig insert new config value without publish message

func (*DBKVCfg) UpdateConfig

func (dbkv *DBKVCfg) UpdateConfig(key, value string) error

UpdateConfig validating first after that update on DB and set to redis

type KeyValueInit

type KeyValueInit struct {
	KeyConfig    string
	DefaultValue interface{}
}

KeyValueInit from User User must set default value ex. for int using 0 or string using "" If config with struct must using struct json with pointer

type OptionsCfg

type OptionsCfg struct {
	WatchInterval    int
	TTLRedis         int
	UseRedisPubSub   bool
	NameApplication  string
	KeyRedisListener string
	KeyNameColumn    string
	ValueNameColumn  string
	TableName        string
}

OptionsCfg Config for user preferences

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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