Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultClient() *http.Client
- func DefaultPooledClient() *http.Client
- func DefaultPooledTransport() *http.Transport
- func DefaultTransport() *http.Transport
- func GetLocalIP() string
- func IsGzipFile(data []byte) bool
- type Client
- type Config
- type ConfigClient
- type EventListener
- type Instance
- type InstanceQueryOptions
- type LogLevel
- type Logger
- type Metadata
- func (m Metadata) Contains(key string) bool
- func (m *Metadata) Encode() string
- func (m *Metadata) Get(key string) string
- func (m *Metadata) GetOrDefault(key string, defaultValue string) string
- func (m *Metadata) GetWithDefault(key string, defaultValue interface{}, ...) interface{}
- func (m *Metadata) Put(key, value string) *Metadata
- type NamingClient
- type Request
- type Response
- type Selector
- type SelectorType
- type Service
- type ServiceInfo
- type ServiceList
- type ServiceOptions
- type ServiceQueryOptions
Constants ¶
const ( DefaultGroup = "DEFAULT_GROUP" DefaultCluster = "DEFAULT" ClientVersion = "1.1.3" )
const ( // GET http method GET GET = "GET" // POST http method POST POST = "POST" // DELETE http method DELETE DELETE = "DELETE" // PUT http method PUT PUT = "PUT" )
const ( SelectorTypeNone = "none" SelectorTypeUnknown = "unknown" SelectorTypeLabel = "label" )
Variables ¶
var (
GZIP_MAGIC = []byte("\x1F\x8B")
)
var LogTag = []string{"[ERROR]", "[WARN ]", "[INFO ]", "[DEBUG]"}
Functions ¶
func DefaultClient ¶
DefaultClient returns a new http.Client with similar default values to http.Client, but with a non-shared Transport, idle connections disabled, and keepalives disabled.
func DefaultPooledClient ¶
DefaultPooledClient returns a new http.Client with similar default values to http.Client, but with a shared Transport. Do not use this function for transient clients as it can leak file descriptors over time. Only use this for clients that will be re-used for the same host(s).
func DefaultPooledTransport ¶
DefaultPooledTransport returns a new http.Transport with similar default values to http.DefaultTransport. Do not use this for transient transports as it can leak file descriptors over time. Only use this for transports that will be re-used for the same host(s).
func DefaultTransport ¶
DefaultTransport returns a new http.Transport with default value, but with idle connections and keepalives disabled.
func GetLocalIP ¶
func GetLocalIP() string
func IsGzipFile ¶
Types ¶
type Client ¶
type Client interface { Naming() NamingClient Config() ConfigClient Logger() Logger }
Client provides a client to the Nacos API
type Config ¶
type Config struct { Scheme string Hosts []string ContextPath string AppName string Namespace string Endpoint string Username string Password string AccessKey string SecretKey string Metadata map[string]string HttpClient *http.Client CacheDir string LogDir string LogLevel LogLevel }
Config is used to configure the creation of a client
type ConfigClient ¶
type ConfigClient interface { GetConfig(dataID, group string) string GetConfigAndSignListener(dataID, group string, listener EventListener) string AddListener(dataID, group string, listener EventListener) PublishConfig(dataID, group, content string) RemoveConfig(dataID, group string) RemoveListener(dataID, group string) GetServerStatus() string Shutdown() }
ConfigClient provides a client to the Nacos config API
type EventListener ¶
type EventListener interface {
OnEvent(*ServiceInfo)
}
type Instance ¶
type InstanceQueryOptions ¶
type Logger ¶
type Metadata ¶
func NewMetadata ¶
func (*Metadata) GetOrDefault ¶
func (*Metadata) GetWithDefault ¶
type NamingClient ¶
type NamingClient interface { SelectServices(ServiceQueryOptions) (*ServiceList, error) SelectService(ServiceQueryOptions) (*Service, error) CreateService(ServiceOptions) (*Response, error) DeleteService(ServiceOptions) (*Response, error) UpdateService(ServiceOptions) (*Response, error) RegisterInstance(*Instance) (*Response, error) DeRegisterInstance(serviceName, groupName, clusterName, ip string, port int, ephemeral bool) (*Response, error) SelectInstance(InstanceQueryOptions) []*Instance Subscribe(serviceName, groupName string, clusters []string, listener EventListener) Unsubscribe(serviceName, groupName string, clusters []string, listener EventListener) Shutdown() }
NamingClient provides a client to the Nacos naming API
type Response ¶
type Selector ¶
type Selector struct {
Type SelectorType `json:"type"`
}
type SelectorType ¶
type SelectorType string
type ServiceInfo ¶
type ServiceInfo struct { Name string GroupName string Clusters string JsonFromServer string CacheMillis int64 Hosts []*Instance LastRefTime int64 Checksum string AllIPs bool }
func NewServiceInfo ¶
func NewServiceInfo(name, groupName, clusters string) *ServiceInfo
func NewServiceInfoByKey ¶
func NewServiceInfoByKey(key string) *ServiceInfo
func (*ServiceInfo) GetKey ¶
func (s *ServiceInfo) GetKey() string
func (*ServiceInfo) Validate ¶
func (s *ServiceInfo) Validate() bool
type ServiceList ¶
type ServiceOptions ¶
type ServiceOptions struct { // name of service ServiceName string // group of service GroupName string // expression of selector Expression string // protectThreshold of service ProtectThreshold float64 // metadata of service Metadata *Metadata Selector *Selector }
ServiceOptions options