configcenter

package
v1.5.6 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (

	//StatusUP is a variable of type string
	StatusUP = "UP"
	//HeaderContentType is a variable of type string
	HeaderContentType = "Content-Type"
	//HeaderUserAgent is a variable of type string
	HeaderUserAgent = "User-Agent"
	//HeaderEnvironment specifies the environment of a service
	HeaderEnvironment = "X-Environment"

	// Name of the Plugin
	Name = "config_center"
)

Variables

View Source
var (
	//HeaderTenantName is a variable of type string
	HeaderTenantName = "X-Tenant-Name"
	//ConfigMembersPath is a variable of type string
	ConfigMembersPath = ""
	//ConfigPath is a variable of type string
	ConfigPath = ""
	//ConfigRefreshPath is a variable of type string
	ConfigRefreshPath = ""
)

Functions

func GetConfigs

func GetConfigs(actionData []byte) (map[string]interface{}, error)

GetConfigs get KV from a event

func GetDefaultHeaders

func GetDefaultHeaders(tenantName string) http.Header

GetDefaultHeaders gets default headers

Types

type Client

type Client struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Client is a struct

func New

func New(opts Options) (*Client, error)

New create cc client

func (*Client) AddConfig

func (c *Client) AddConfig(data *CreateConfigAPI) (map[string]interface{}, error)

AddConfig post new config

func (*Client) DeleteConfig

func (c *Client) DeleteConfig(data *DeleteConfigAPI) (map[string]interface{}, error)

DeleteConfig delete configs

func (*Client) Do

func (c *Client) Do(method string, data interface{}) (map[string]interface{}, error)

Do is common http remote call

func (*Client) Flatten

func (c *Client) Flatten(dimensionInfo string) (map[string]interface{}, error)

Flatten pulls all the configuration from config center and merge kv in different dimension

func (*Client) GetConfigServer

func (c *Client) GetConfigServer() ([]string, error)

GetConfigServer is a method used for getting server configuration

func (*Client) HTTPDo

func (c *Client) HTTPDo(method string, rawURL string, headers http.Header, body []byte) (resp *http.Response, err error)

HTTPDo Use http-client package for rest communication

func (*Client) PullGroupByDimension

func (c *Client) PullGroupByDimension(dimensionInfo string) (map[string]map[string]interface{}, error)

PullGroupByDimension pulls all the configuration from Config-Server group by dimesion Info

func (*Client) Shuffle

func (c *Client) Shuffle() error

Shuffle is a method to log error

func (*Client) Watch

func (c *Client) Watch(f func(map[string]interface{}), errHandler func(err error)) error

Watch use websocket

type CreateConfigAPI

type CreateConfigAPI struct {
	DimensionInfo string                 `json:"dimensionsInfo"`
	Items         map[string]interface{} `json:"items"`
}

CreateConfigAPI for new config

type DeleteConfigAPI

type DeleteConfigAPI struct {
	DimensionInfo string   `json:"dimensionsInfo"`
	Keys          []string `json:"keys"`
}

DeleteConfigAPI for deleting

type Event

type Event struct {
	Action string `json:"action"`
	Value  string `json:"value"`
}

Event stores info about an config center event

type Options

type Options struct {
	DefaultDimension string
	Service          string
	App              string
	Version          string
	Env              string

	ConfigServerAddresses []string
	RefreshPort           string
	APIVersion            string
	TLSConfig             *tls.Config
	TenantName            string
	EnableSSL             bool
}

Options is remote client option

Jump to

Keyboard shortcuts

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