package
0.0.0-20200507081720-b49f4acfab80
Repository: https://github.com/mytokenio/go_sdk.git
Documentation: pkg.go.dev

# README

Config

Usage

import package

import (
    "github.com/mytokenio/go/config"
)

Service Config

custom struct

type MyConfig struct {...}

bind config like this:

mc := &MyConfig{}
c := config.GetConfig()
c.BindJSON(mc)
// or
c.BindTOML(mc)

Watch Change

default watch interval 5 seconds,

c.Watch(func(configString string) error {
    err := c.BindTOML(mc)
    if err != nil {
        log.Errorf("config bind error %s", err)
        return err
    }

    log.Infof("service config changed %v", mc)
    return nil
})

you can pass second parameter to control interval

c.Watch(callback, 10 * time.Second)

File Driver

the default config driver, default file name config.toml

c := config.NewConfig()
c.BindTOML(...)
// or
c.Watch(...)

Http Driver

if env CONFIG_SERVER not empty, the default config driver would be http driver

c := config.NewConfig(config.Service("your-service-name"))

or use shortcut:

c := config.NewHttpConfig("your-service-name")

UI (for http driver)

moved to mytokenio/config-manager

Other

TODO

# Packages

No description provided by the author

# Functions

No description provided by the author
get config object.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Constants

测试环境配置中心域名.
本地配置文件.
配置中心.
No description provided by the author
No description provided by the author
No description provided by the author
开发环境配置中心域名.
测试环境.
开发环境(默认).
生产环境.
正式环境配置中心域名.

# Structs

No description provided by the author
No description provided by the author

# Type aliases

No description provided by the author
No description provided by the author