config

package module
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

README

go-chassis-config

Build Status
go-chassis-config is able to pull configs from heterogeneous distributed configuration management service. it is decoupled with go chassis. you can use it directly without go chassis.

Supported distributed configuration management service:

name import description
config_center github.com/go-chassis/go-chassis-config/configcenter huawei cloud CSE config center https://www.huaweicloud.com/product/cse.html
apollo github.com/go-chassis/go-chassis-config/apollo ctrip apollo https://github.com/ctripcorp/apollo

Example

Get a client of config center

  1. import the config client you want to use
import _ "github.com/go-chassis/go-chassis-config/configcenter"
  1. Create a client
c, err := ccclient.NewClient("config_center", ccclient.Options{
		ServerURI: "http://127.0.0.1:30200",
	})

Use huawei cloud

import (
	"github.com/huaweicse/auth"
	"github.com/go-chassis/foundation/httpclient"
	_ "github.com/go-chassis/go-chassis-config/configcenter"
)

func main() {
	var err error
	httpclient.SignRequest,err =auth.GetShaAKSKSignFunc("your ak", "your sk", "")
	if err!=nil{
        //handle err
	}
	ccclient.NewClient("config_center",ccclient.Options{
		ServerURI:"the address of CSE endpoint",
	})
}

Documentation

Overview

Package client created on 2017/6/22.

Index

Constants

View Source
const (
	LoggerInitFailed            = "logger initialization failed"
	PackageInitError            = "package not initialize successfully"
	ConfigServerMemRefreshError = "error in poulating config server member"
	EmptyConfigServerMembers    = "empty config server member"
	EmptyConfigServerConfig     = "empty config sevrer passed"
	RefreshModeError            = "refreshMode must be 0 or 1."
)

error response constants

Variables

This section is empty.

Functions

func InstallConfigClientPlugin

func InstallConfigClientPlugin(name string, f func(options Options) Client)

InstallConfigClientPlugin install a config client plugin

Types

type Client added in v0.6.0

type Client interface {
	//PullConfigs pull all configs from remote
	PullConfigs(serviceName, version, app, env string) (map[string]interface{}, error)
	//PullConfig pull one config from remote
	PullConfig(serviceName, version, app, env, key, contentType string) (interface{}, error)
	//PullConfigsByDI pulls the configurations with customized DimensionInfo/Project
	PullConfigsByDI(dimensionInfo, diInfo string) (map[string]map[string]interface{}, error)
	// PushConfigs push config to cc
	PushConfigs(data map[string]interface{}, dimensionInfo string) (map[string]interface{}, error)
	// DeleteConfigsByKeys delete config for cc by keys
	DeleteConfigsByKeys(keys []string, dimensionInfo string) (map[string]interface{}, error)
	//Watch get kv change results, you can compare them with local kv cache and refresh local cache
	Watch(f func(map[string]interface{}), errHandler func(err error)) error
}

Client is the interface of config server client, it has basic func to interact with config server

var DefaultClient Client

DefaultClient is config server's client

func NewClient

func NewClient(name string, options Options) (Client, error)

NewClient create config client implementation

type Options

type Options struct {
	ServerURI         string
	Endpoint          string
	ServiceName       string
	ApolloServiceName string
	Cluster           string
	Namespace         string
	App               string
	Env               string
	Version           string
	TLSConfig         *tls.Config
	TenantName        string
	EnableSSL         bool
	APIVersion        string
	AutoDiscovery     bool
	RefreshPort       string
	DimensionInfo     string
}

Directories

Path Synopsis
Package memberdiscovery created on 2017/6/20.
Package memberdiscovery created on 2017/6/20.
Package serializers created on 2017/6/22.
Package serializers created on 2017/6/22.
json
Package json is used for marshalling and unmarshalling
Package json is used for marshalling and unmarshalling

Jump to

Keyboard shortcuts

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