func RegisterModuleListener(listenerObj event.ModuleListener, prefix ...string) error {
	return manager.RegisterModuleListener(listenerObj, prefix...)
}
RegisterModuleListener to Register all moduleListener for different key(prefix) changes
package archaius
import (
	"errors"
	"fmt"
	"io"
	filesource "github.com/go-chassis/go-archaius/source/file"
	"os"
	"strings"
	"github.com/go-chassis/go-archaius/event"
	"github.com/go-chassis/go-archaius/pkg/cast"
	"github.com/go-chassis/go-archaius/source"
	"github.com/go-chassis/go-archaius/source/cli"
	"github.com/go-chassis/go-archaius/source/env"
	"github.com/go-chassis/go-archaius/source/mem"
	"github.com/go-chassis/openlog"
)
var (
	manager             *source.Manager
	fs                  filesource.FileSource
	running             = false
	configServerRunning = false
)
func initFileSource(o *Options) (source.ConfigSource, error) {
	files := make([]string, 0)
	fs = filesource.NewFileSource()
	for _, v := range o.RequiredFiles {
		if err := fs.AddFile(v, filesource.DefaultFilePriority, o.FileHandler); err != nil {
			openlog.Error(fmt.Sprintf("add file source error [%s].", err.Error()))
			return nil, err
		}
		files = append(files, v)
	}
	for _, v := range o.OptionalFiles {
		_, err := os.Stat(v)
		if os.IsNotExist(err) {
			openlog.Info(fmt.Sprintf("[%s] not exist", v))
			continue
		}
		if err := fs.AddFile(v, filesource.DefaultFilePriority, o.FileHandler); err != nil {
			openlog.Info(err.Error())
			return nil, err
		}
		files = append(files, v)
	}
	openlog.Info(fmt.Sprintf("Configuration files: %s", strings.Join(files, ", ")))
	return fs, nil
}
func Init(opts ...Option) error {
	if running {
		openlog.Warn("can not init archaius again, call Clean first")
		return nil
	}
	var err error
	o := &Options{}
	for _, opt := range opts {
		opt(o)
	}
	manager = source.NewManager()
	fs, err := initFileSource(o)
	if err != nil {
		return err
	}
	err = manager.AddSource(fs)
	if err != nil {
		return err
	}
	if o.RemoteSource != "" {
		if err = EnableRemoteSource(o.RemoteSource, o.RemoteInfo); err != nil {
			return err
		}
	}
	if o.UseMemSource {
		ms := mem.NewMemoryConfigurationSource()
		if err = manager.AddSource(ms); err != nil {
			return err
		}
	}
	if o.UseCLISource {
		cmdSource := cli.NewCommandlineConfigSource()
		if err = manager.AddSource(cmdSource); err != nil {
			return err
		}
	}
	if o.UseENVSource {
		envSource := env.NewEnvConfigurationSource()
		if err = manager.AddSource(envSource); err != nil {
			return err
		}
	}
	openlog.Info("archaius init success")
	running = true
	return nil
}
func CustomInit(sources ...source.ConfigSource) error {
	if running {
		openlog.Warn("can not init archaius again, call Clean first")
		return nil
	}
	var err error
	manager = source.NewManager()
	for _, s := range sources {
		err = manager.AddSource(s)
		if err != nil {
			return err
		}
	}
	running = true
	return err
}
func EnableRemoteSource(remoteSource string, ci *RemoteInfo) error {
	if ci == nil {
		return errors.New("RemoteInfo can not be empty")
	}
	if configServerRunning {
		openlog.Warn("can not init config server again, call Clean first")
		return nil
	}
	f, ok := newFuncMap[remoteSource]
	if !ok {
		return errors.New("don not support remote source: " + remoteSource)
	}
	s, err := f(ci)
	if err != nil {
		return err
	}
	err = manager.AddSource(s)
	if err != nil {
		return err
	}
	configServerRunning = true
	return nil
}
func Get(key string) interface{} {
	return manager.GetConfig(key)
}
func GetValue(key string) cast.Value {
	var confValue cast.Value
	val := manager.GetConfig(key)
	if val == nil {
		confValue = cast.NewValue(nil, source.ErrKeyNotExist)
	} else {
		confValue = cast.NewValue(val, nil)
	}
	return confValue
}
func Exist(key string) bool {
	return manager.IsKeyExist(key)
}
func UnmarshalConfig(obj interface{}) error {
	return manager.Unmarshal(obj)
}
func WriteTo(w io.Writer) error {
	return manager.Marshal(w)
}
func GetBool(key string, defaultValue bool) bool {
	b, err := GetValue(key).ToBool()
	if err != nil {
		return defaultValue
	}
	return b
}
func GetFloat64(key string, defaultValue float64) float64 {
	result, err := GetValue(key).ToFloat64()
	if err != nil {
		return defaultValue
	}
	return result
}
func GetInt(key string, defaultValue int) int {
	result, err := GetValue(key).ToInt()
	if err != nil {
		return defaultValue
	}
	return result
}
func GetInt64(key string, defaultValue int64) int64 {
	result, err := GetValue(key).ToInt64()
	if err != nil {
		return defaultValue
	}
	return result
}
func GetString(key string, defaultValue string) string {
	result, err := GetValue(key).ToString()
	if err != nil {
		return defaultValue
	}
	return result
}
func GetConfigs() map[string]interface{} {
	return manager.Configs()
}
func GetConfigsWithSourceNames() map[string]interface{} {
	return manager.ConfigsWithSourceNames()
}
func AddDimensionInfo(labels map[string]string) (map[string]string, error) {
	config, err := manager.AddDimensionInfo(labels)
	return config, err
}
func RegisterListener(listenerObj event.Listener, key ...string) error {
	return manager.RegisterListener(listenerObj, key...)
}
func UnRegisterListener(listenerObj event.Listener, key ...string) error {
	return manager.UnRegisterListener(listenerObj, key...)
}