nacos_viper_remote

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2021 License: MIT Imports: 11 Imported by: 5

README

Viper remote for Nacos

Golang configuration,use to Viper reading from remote Nacos config systems. Viper remote for Naocs.

runtime_viper := viper.New()

remote.SetOptions(&remote.Option{
   Url:         "localhost",
   Port:        80,
   NamespaceId: "public",
   GroupName:   "DEFAULT_GROUP",
   Config: 	remote.Config{ DataId: "config_dev" },
   Auth:        nil,
})

err := remote_viper.AddRemoteProvider("nacos", "localhost", "")
remote_viper.SetConfigType("yaml")

_ = remote_viper.ReadRemoteConfig()             //sync get remote configs to remote_viper instance memory . for example , remote_viper.GetString(key)
_ = remote_viper.WatchRemoteConfigOnChannel()   //async watch , auto refresh configs.

appName := remote_viper.GetString("key")   // sync get config by key

fmt.Println(appName)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewNacosConfigManager

func NewNacosConfigManager(option *Option) (*nacosConfigManager, error)

func SetOptions

func SetOptions(option *Option)

Types

type Auth

type Auth struct {
	Enable   bool   `mapstructure:"enable"`
	User     string `mapstructure:"username"`
	Password string `mapstructure:"password"`

	// ACM Endpoint
	Endpoint string `mapstructure:"endpoint"`
	// ACM RegionId
	RegionId string `mapstructure:"regionId"`
	// ACM AccessKey
	AccessKey string `mapstructure:"accessKey"`
	// ACM SecretKey
	SecretKey string `mapstructure:"secretKey"`
	// ACM OpenKMS
	OpenKMS bool `mapstructure:"openKMS"`
}

type Config

type Config struct {
	DataId string `mapstructure:"dataId"`
}

type Option

type Option struct {
	Url         string `mapstructure:"url"`
	Port        uint64 `mapstructure:"port"`
	NamespaceId string `mapstructure:"namespace"`
	GroupName   string `mapstructure:"group"`
	Config      Config `mapstructure:"configserver"`
	Auth        *Auth  `mapstructure:"auth"`
}

type ViperRemoteProvider

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

func NewRemoteProvider

func NewRemoteProvider(configType string) *ViperRemoteProvider

func (*ViperRemoteProvider) GetProvider

func (provider *ViperRemoteProvider) GetProvider(runtime_viper *viper.Viper) *viper.Viper

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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