consul

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: Apache-2.0 Imports: 14 Imported by: 3

Documentation

Index

Constants

View Source
const (
	JSON                      ConfigType = "json"
	YAML                      ConfigType = "yaml"
	HCL                       ConfigType = "hcl"
	ConsulDefaultConfigAddr              = "127.0.0.1:8500"
	ConsulDefaultConfiGPrefix            = "KitexConfig"
	ConsulDefaultTimeout                 = 5 * time.Second
	ConsulDefaultDataCenter              = "dc1"
	ConsulDefaultClientPath              = "{{.ClientServiceName}}/{{.ServerServiceName}}/{{.Category}}"
	ConsulDefaultServerPath              = "{{.ServerServiceName}}/{{.Category}}"
)
View Source
const WatchByKey = "key"

Variables

This section is empty.

Functions

func AllocateUniqueID

func AllocateUniqueID() int64

Types

type Client

type Client interface {
	SetParser(configParser ConfigParser)
	ClientConfigParam(cpc *ConfigParamConfig, cfs ...CustomFunction) (Key, error)
	ServerConfigParam(cpc *ConfigParamConfig, cfs ...CustomFunction) (Key, error)
	RegisterConfigCallback(key string, uniqueID int64, callback func(string, ConfigParser))
	DeregisterConfig(key string, uniqueID int64)
}

func NewClient

func NewClient(opts Options) (Client, error)

type ConfigParamConfig

type ConfigParamConfig struct {
	Category          string
	ClientServiceName string
	ServerServiceName string
}

type ConfigParser

type ConfigParser interface {
	Decode(configType ConfigType, data string, config interface{}) error
}

type ConfigType

type ConfigType string

type CustomFunction

type CustomFunction func(*Key)

CustomFunction use for customize the config parameters.

type Key

type Key struct {
	Type   ConfigType
	Prefix string
	Path   string
}

type ListenConfig

type ListenConfig struct {
	Key        string
	Type       string
	DataCenter string
	Token      string
	ConsulAddr string
	Namespace  string
	Partition  string
}

type Options

type Options struct {
	Addr             string
	Prefix           string
	ServerPathFormat string
	ClientPathFormat string
	DataCenter       string
	TimeOut          time.Duration
	NamespaceId      string
	Token            string
	Partition        string
	LoggerConfig     *zap.Config
	ConfigParser     ConfigParser
}

Jump to

Keyboard shortcuts

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