Documentation ¶
Overview ¶
Package apollo implements gcfg.Adapter using apollo service.
Index ¶
- func New(ctx context.Context, config Config) (adapter gcfg.Adapter, err error)
- type Client
- func (c *Client) Available(ctx context.Context, resource ...string) (ok bool)
- func (c *Client) Data(ctx context.Context) (data map[string]interface{}, err error)
- func (c *Client) Get(ctx context.Context, pattern string) (value interface{}, err error)
- func (c *Client) OnChange(event *storage.ChangeEvent)
- func (c *Client) OnNewestChange(event *storage.FullChangeEvent)
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements gcfg.Adapter implementing using apollo service.
func (*Client) Available ¶
Available checks and returns the backend configuration service is available. The optional parameter `resource` specifies certain configuration resource.
Note that this function does not return error as it just does simply check for backend configuration service.
func (*Client) Data ¶
Data retrieves and returns all configuration data in current resource as map. Note that this function may lead lots of memory usage if configuration data is too large, you can implement this function if necessary.
func (*Client) Get ¶
Get retrieves and returns value by specified `pattern` in current resource. Pattern like: "x.y.z" for map item. "x.0.y" for slice item.
func (*Client) OnChange ¶
func (c *Client) OnChange(event *storage.ChangeEvent)
OnChange is called when config changes.
func (*Client) OnNewestChange ¶
func (c *Client) OnNewestChange(event *storage.FullChangeEvent)
OnNewestChange is called when any config changes.
type Config ¶
type Config struct { AppID string `v:"required"` // See apolloConfig.Config. IP string `v:"required"` // See apolloConfig.Config. Cluster string `v:"required"` // See apolloConfig.Config. NamespaceName string // See apolloConfig.Config. IsBackupConfig bool // See apolloConfig.Config. BackupConfigPath string // See apolloConfig.Config. Secret string // See apolloConfig.Config. SyncServerTimeout int // See apolloConfig.Config. MustStart bool // See apolloConfig.Config. Watch bool // Watch watches remote configuration updates, which updates local configuration in memory immediately when remote configuration changes. }
Config is the configuration object for apollo client.