loader

package module
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2022 License: MIT Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

loader

program config load from db and overwrite by CLI

example database

  • run_config table create
CREATE TABLE `run_config` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT 'incr id',
  `config_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'config name',
  `config_key` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'config key',
  `config_value` text COLLATE utf8mb4_unicode_ci COMMENT 'config value',
  `remark` varchar(256) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'remark',
  `deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'is deleted(0=false 1=true)',
  `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'created time',
  PRIMARY KEY (`id`),
  UNIQUE KEY `UNIQ_NAME_KEY` (`config_name`,`config_key`)
) ENGINE=InnoDB AUTO_INCREMENT=131 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='run config table';

  • run_config table records
+----+----------------+------------+-------------------------------------------+
| id | config_name    | config_key | config_value                              |
+----+----------------+------------+-------------------------------------------+
|  1 | user-service   | http_addr  | "0.0.0.0:80"                              |
|  2 | user-service   | static     | "/var/www/html"                           |
|  3 | user-service   | image_path | "/data/images"                            |
|  4 | user-service   | domain     | "http://user.mydomain.com/images"         |
|  5 | user-service   | debug      | true                                      |                                                                |
+----+----------------+------------+-------------------------------------------+

Documentation

Index

Constants

View Source
const (
	TagName_DB   = "db"
	TagName_JSON = "json"
	TagName_BSON = "bson"
	TagName_TOML = "toml"
	TagName_CLI  = "cli"
)
View Source
const (
	RUN_CONFIG_COLUMN_ID           = "id"
	RUN_CONFIG_COLUMN_CONFIG_NAME  = "config_name"
	RUN_CONFIG_COLUMN_CONFIG_KEY   = "config_key"
	RUN_CONFIG_COLUMN_CONFIG_VALUE = "config_value"
	RUN_CONFIG_COLUMN_REMARK       = "remark"
	RUN_CONFIG_COLUMN_DELETED      = "deleted"
	RUN_CONFIG_COLUMN_CREATED_TIME = "created_time"
)
View Source
const TableNameRunConfig = "run_config" //运行参数表

Variables

This section is empty.

Functions

func Configure

func Configure(ctx *cli.Context, strDSN, strConfigName string, model interface{}) error

Configure initialize or load run config from database

func SetRefreshInterval added in v1.3.0

func SetRefreshInterval(seconds int)

Types

type RunConfigDO

type RunConfigDO struct {
	Id          int32  `json:"id" db:"id" bson:"id"`                                                //自增ID
	ConfigName  string `json:"config_name" db:"config_name" bson:"config_name"`                     //配置名称
	ConfigKey   string `json:"config_key" db:"config_key" bson:"config_key"`                        //配置KEY
	ConfigValue string `json:"config_value" db:"config_value" bson:"config_value"`                  //配置VALUE
	Remark      string `json:"remark" db:"remark" bson:"remark"`                                    //配置备注
	Deleted     bool   `json:"deleted" db:"deleted" bson:"deleted"`                                 //是否已删除(0=否 1=是)
	CreatedTime string `json:"created_time" db:"created_time" sqlca:"readonly" bson:"created_time"` //创建时间
}

func (*RunConfigDO) GetConfigKey

func (do *RunConfigDO) GetConfigKey() string

func (*RunConfigDO) GetConfigName

func (do *RunConfigDO) GetConfigName() string

func (*RunConfigDO) GetConfigValue

func (do *RunConfigDO) GetConfigValue() string

func (*RunConfigDO) GetCreatedTime

func (do *RunConfigDO) GetCreatedTime() string

func (*RunConfigDO) GetDeleted

func (do *RunConfigDO) GetDeleted() bool

func (*RunConfigDO) GetId

func (do *RunConfigDO) GetId() int32

func (*RunConfigDO) GetRemark

func (do *RunConfigDO) GetRemark() string

func (*RunConfigDO) SetConfigKey

func (do *RunConfigDO) SetConfigKey(v string)

func (*RunConfigDO) SetConfigName

func (do *RunConfigDO) SetConfigName(v string)

func (*RunConfigDO) SetConfigValue

func (do *RunConfigDO) SetConfigValue(v string)

func (*RunConfigDO) SetCreatedTime

func (do *RunConfigDO) SetCreatedTime(v string)

func (*RunConfigDO) SetDeleted

func (do *RunConfigDO) SetDeleted(v bool)

func (*RunConfigDO) SetId

func (do *RunConfigDO) SetId(v int32)

func (*RunConfigDO) SetRemark

func (do *RunConfigDO) SetRemark(v string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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