Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TarsConfigObserver

Make life easier, read tars remote config with spf13/viper

Usage

First, create an observer and add one or more remote config names:

    // Init remote config
    rconf_obs := TarsConfigObserver.NewObserver(60, "")
    _, err := rconf_obs.AddRemoteConfig("config.yaml")
    if err != nil {
        return err
    }

Second, use viper like local config:

    // any file in project
    viper.GetString("foo.bar")

Mutil configs

    rconf_obs := TarsConfigObserver.NewObserver(60, "")
    _, err := rconf_obs.AddRemoteConfig("config.yaml")
    if err != nil {
        return err
    }

    json_viper, err := rconf_obs.AddRemoteConfig("second_config.json")
    if err != nil {
        return err
    }

    // read second configs
    json_viper.GetString("key")

    // or get from GetViper()
    other_viper := rconf_obs.GetViper("second_config.json")
    other_viper.GetString("key")

About

Make life easier, read tars remote config with spf13/viper

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages