agollo

package module
v2.2.5 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

README

Agollo - Go Client for Apollo

golang Build Status Go Report Card codebeat badge Coverage Status License GoDoc GitHub release 996.icu

方便Golang接入配置中心框架 Apollo 所开发的Golang版本客户端。

Features

  • 实时同步配置
  • 灰度配置
  • 延迟加载(运行时)namespace
  • 客户端,配置文件容灾
  • 自定义日志,缓存组件

Usage

使用Demoagollo_demo

其他语言agollo-agent 做本地agent接入,如:PHP

欢迎查阅 Wiki 或者 godoc 获取更多有用的信息

如果你觉得该工具还不错或者有问题,一定要让我知道,可以发邮件或者留言

User

Contribution

License

The project is licensed under the Apache 2 license.

Reference

Apollo : https://github.com/ctripcorp/apollo

Documentation

Index

Constants

View Source
const (
	APP_CONFIG_FILE_NAME = "app.properties"
	ENV_CONFIG_FILE_PATH = "AGOLLO_CONF"
)

Variables

This section is empty.

Functions

func AddChangeListener

func AddChangeListener(listener ChangeListener)

AddChangeListener 增加变更监控

func GetApolloConfigCache

func GetApolloConfigCache() agcache.CacheInterface

GetApolloConfigCache 获取默认namespace的apollo配置

func GetBoolValue

func GetBoolValue(key string, defaultValue bool) bool

func GetConfigCache

func GetConfigCache(namespace string) agcache.CacheInterface

GetConfigCache 根据namespace获取apollo配置的缓存

func GetCurrentApolloConfig

func GetCurrentApolloConfig() map[string]*ApolloConnConfig

GetCurrentApolloConfig 获取Apollo链接配置

func GetFloatValue

func GetFloatValue(key string, defaultValue float64) float64

func GetIntValue

func GetIntValue(key string, defaultValue int) int

func GetStringValue

func GetStringValue(key string, defaultValue string) string

func InitCustomConfig

func InitCustomConfig(loadAppConfig func() (*AppConfig, error))

InitCustomConfig init config by custom

func SetCache

func SetCache(cacheFactory *agcache.DefaultCacheFactory)

SetCache 设置自定义cache组件

func SetLogger

func SetLogger(loggerInterface LoggerInterface)

SetLogger 设置自定义logger组件

func Start

func Start() error

start apollo

func StartRefreshConfig

func StartRefreshConfig(component AbsComponent)

func StartWithCache

func StartWithCache(cacheFactory *agcache.DefaultCacheFactory) error

StartWithCache 通过自定义cache启动agollo

func StartWithLogger

func StartWithLogger(loggerInterface LoggerInterface) error

StartWithLogger 通过自定义logger启动agollo

Types

type AbsComponent

type AbsComponent interface {
	Start()
}

type ApolloConfig

type ApolloConfig struct {
	ApolloConnConfig
	Configurations map[string]string `json:"configurations"`
}

type ApolloConnConfig

type ApolloConnConfig struct {
	AppId         string `json:"appId"`
	Cluster       string `json:"cluster"`
	NamespaceName string `json:"namespaceName"`
	ReleaseKey    string `json:"releaseKey"`
	sync.RWMutex
}

type AppConfig

type AppConfig struct {
	AppId            string `json:"appId"`
	Cluster          string `json:"cluster"`
	NamespaceName    string `json:"namespaceName"`
	Ip               string `json:"ip"`
	NextTryConnTime  int64  `json:"-"`
	BackupConfigPath string `json:"backupConfigPath"`
}

func GetAppConfig

func GetAppConfig(newAppConfig *AppConfig) *AppConfig

type CallBack

type CallBack struct {
	SuccessCallBack   func([]byte) (interface{}, error)
	NotModifyCallBack func() error
}

type ChangeEvent

type ChangeEvent struct {
	Namespace string
	Changes   map[string]*ConfigChange
}

config change event

type ChangeListener

type ChangeListener interface {
	//OnChange 增加变更监控
	OnChange(event *ChangeEvent)
}

ChangeListener 监听器

type Config

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

Config apollo配置项

func GetConfig

func GetConfig(namespace string) *Config

GetConfig 根据namespace获取apollo配置

func GetConfigAndInit

func GetConfigAndInit(namespace string) *Config

GetConfigAndInit 根据namespace获取apollo配置

func (*Config) GetBoolValue

func (this *Config) GetBoolValue(key string, defaultValue bool) bool

GetBoolValue 获取配置值(bool),获取不到则取默认值

func (*Config) GetContent

func (c *Config) GetContent(format ConfigFileFormat) string

GetContent 获取配置文件内容

func (*Config) GetFloatValue

func (this *Config) GetFloatValue(key string, defaultValue float64) float64

GetFloatValue 获取配置值(float),获取不到则取默认值

func (*Config) GetIntValue

func (this *Config) GetIntValue(key string, defaultValue int) int

GetIntValue 获取配置值(int),获取不到则取默认值

func (*Config) GetStringValue

func (this *Config) GetStringValue(key string, defaultValue string) string

GetStringValue 获取配置值(string),获取不到则取默认值

type ConfigChange

type ConfigChange struct {
	OldValue   string
	NewValue   string
	ChangeType ConfigChangeType
}

type ConfigChangeType

type ConfigChangeType int

config change type

const (
	ADDED ConfigChangeType = iota
	MODIFIED
	DELETED
)

type ConfigFileFormat

type ConfigFileFormat string

ConfigFileFormat 配置文件类型

const (
	//Properties
	Properties ConfigFileFormat = "properties"
	//XML
	XML ConfigFileFormat = "xml"
	//JSON
	JSON ConfigFileFormat = "json"
	//YML
	YML ConfigFileFormat = "yml"
	//YAML
	YAML ConfigFileFormat = "yaml"
)

type ConnectConfig

type ConnectConfig struct {
	//设置到http.client中timeout字段
	Timeout time.Duration
	//连接接口的uri
	Uri string
}

type ContentParser

type ContentParser interface {
	// contains filtered or unexported methods
}

ContentParser 内容转换

type DefaultLogger

type DefaultLogger struct {
}

func (*DefaultLogger) Debug

func (this *DefaultLogger) Debug(v ...interface{})

func (*DefaultLogger) Debugf

func (this *DefaultLogger) Debugf(format string, params ...interface{})

func (*DefaultLogger) Error

func (this *DefaultLogger) Error(v ...interface{}) error

func (*DefaultLogger) Errorf

func (this *DefaultLogger) Errorf(format string, params ...interface{}) error

func (*DefaultLogger) Info

func (this *DefaultLogger) Info(v ...interface{})

func (*DefaultLogger) Infof

func (this *DefaultLogger) Infof(format string, params ...interface{})

func (*DefaultLogger) Warn

func (this *DefaultLogger) Warn(v ...interface{}) error

func (*DefaultLogger) Warnf

func (this *DefaultLogger) Warnf(format string, params ...interface{}) error

type DefaultParser

type DefaultParser struct {
}

DefaultParser 默认内容转换器

type LoggerInterface

type LoggerInterface interface {
	Debugf(format string, params ...interface{})

	Infof(format string, params ...interface{})

	Warnf(format string, params ...interface{}) error

	Errorf(format string, params ...interface{}) error

	Debug(v ...interface{})

	Info(v ...interface{})

	Warn(v ...interface{}) error

	Error(v ...interface{}) error
}

type NotifyConfigComponent

type NotifyConfigComponent struct {
}

func (*NotifyConfigComponent) Start

func (this *NotifyConfigComponent) Start()

type PropertiesParser

type PropertiesParser struct {
}

PropertiesParser properties转换器

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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