Help us shape the future of Go! Take the 2026 Go Developer Survey

ccclient

package module
v0.2.0 Latest Latest
Warning

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

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

README

go-cc-client

Build Status
config center client can pull and push configs in distributed configuration management service

Supported distributed configuration management service:

Example

Get a client of config center

  1. import the config client you want to use
_ "github.com/go-chassis/go-cc-client/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/go-chassis/pkg/httpclient"
	_ "github.com/go-chassis/go-cc-client/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) ConfigClient)

InstallConfigClientPlugin install a config client plugin

Types

type ConfigClient

type ConfigClient interface {
	//Init the Configuration for the Server
	//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)
}

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

var DefaultClient ConfigClient

DefaultClient is config server's client

func NewClient

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

Enable enable config server client

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
}

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