client

package module
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2023 License: MIT Imports: 7 Imported by: 1

README

nacos-client

A lightweight NACOS client.

Documentation

Index

Constants

View Source
const (
	Scheme     = "client"
	WebContext = "/"

	HttpClientTimeout  = 10
	AccessToken        = "accessToken"
	TokenTtl           = "tokenTtl"
	TokenRefreshWindow = "tokenRefreshWindow"

	PageNo   = "pageNo"
	PageSize = "pageSize"

	ServiceIP               = "ip"               // 服务IP, string
	ServicePort             = "port"             // 服务端口, int
	ServiceNamespaceId      = "namespaceId"      // 命名空间ID, string
	ServiceWeight           = "weight"           // 权重, double
	ServiceEnable           = "enable"           // 是否上线, bool
	ServiceHealthy          = "healthy"          // 是否只健康, bool
	ServiceMetadata         = "metadata"         // 元数据, string
	ServiceClusterName      = "clusterName"      // 集群名称, string
	ServiceName             = "serviceName"      // 服务名称, string
	ServiceGroupName        = "groupName"        // 分组名称, string
	ServiceEphemeral        = "ephemeral"        // 是否临时实例, bool
	ServiceClusters         = "clusters"         // 集群名称, string,多个集群用逗号分隔
	ServiceProtectThreshold = "protectThreshold" // 保护阈值, float64
	ServiceSelector         = "selector"         // 选择器, 服务访问策略

	OperatorEntry = "entry" // 开关名
	OperatorValue = "value" // 开关值
	OperatorDebug = "debug" // 开关值

	PermissionSuffix = ":*:*"
	Search           = "search"
	SearchType       = "accurate"
	Username         = "username"
	Password         = "password"
	NewPassword      = "newPassword"
	Role             = "role"
	NameSpace        = "namespace"
	Tenant           = "tenant"   // tenant	租户信息,对应 Nacos 的命名空间ID字段,命名空间ID字段与命名空间名保持一致
	Resource         = "resource" // 添加权限时资源字段,该值与命名空间名称保持一致

	ConfigDataId      = "dataId"  // Nacos 配置 ID
	ConfigGroup       = "group"   // Nacos 配置分组
	ConfigContent     = "content" // Nacos 配置内置
	ConfigContentType = "type"    // Nacos 配置类型
	ConfigNid         = "nid"     // Nacos 配置历史版本ID
	ConfigId          = "id"      // Nacos 配置历史版本ID

	PermissionAction            = "action"            // 添加权限,动作字段[r, w, rw]
	PermissionCustomNamespaceId = "customNamespaceId" // 命名空间ID,与命名空间名保持一致
	PermissionNamespaceName     = "namespaceName"     // 命名空间名
	PermissionNamespaceShowName = "namespaceShowName" // 命名空间名
	PermissionNamespaceDesc     = "namespaceDesc"     // 命名空间描述,与命名空间名保持一致
	PermissionNamespaceId       = "namespaceId"       //命名空间ID,删除命名空间时所需参数
	Env                         = "env"               //环境
	ServerAddr                  = "nacosUrl"          // nacos服务器地址,example: http://xxx.com:80

	DefaultGroup  = "DEFAULT_GROUP" // Nacos 默认 ConfigGroup
	DefaultTenant = "public"        // Nacos 默认 Tenant

	IPathAuth                  = "/nacos/v1/auth/login"                 // 鉴权
	IPathNamespaces            = "/nacos/v1/console/namespaces"         // 命名空间
	IPathUser                  = "/nacos/v1/auth/users"                 // 用户
	IPathRoles                 = "/nacos/v1/auth/roles"                 // 角色
	IPathPermission            = "/nacos/v1/auth/permissions"           // 权限
	IPathConfig                = "/nacos/v1/cs/configs"                 //获取配置 ,发布配置 ,删除配置
	IPathConfigListener        = "/nacos/v1/cs/configs/listener"        //监听配置
	IPathConfigHistory         = "/nacos/v1/cs/history?search=accurate" //查询历史配置
	IPathConfigHistoryDetail   = "/nacos/v1/cs/history"                 //查询历史版本详情
	IPathConfigHistoryPrevious = "/nacos/v1/cs/history/previous"        //查询配置上一版本信息

	IPathInstance        = "/nacos/v1/ns/instance"          //注册实例,查询实例详情,修改实例,注销实例
	IPathInstanceList    = "/nacos/v1/ns/instance/list"     //查询实例列表
	IPathInstanceBeat    = "/nacos/v1/ns/instance/beat"     //发送实例心跳
	IPathService         = "/nacos/v1/ns/service"           //创建服务,查询服务,修改服务,删除服务
	IPathServiceList     = "/nacos/v1/ns/service/list"      //查询服务列表
	IPathOperatorSwitch  = "/nacos/v1/ns/operator/switches" //查询系统开关,修改系统开关
	IPathOperatorMetrics = "/nacos/v1/ns/operator/metrics"  //查看系统当前数据指标
	IPathOperatorServers = "/nacos/v1/ns/operator/servers"  //查看集群server列表
	IPathOperatorLeader  = "/nacos/v1/ns/raft/leader"       //查看集群leader
	IPathInstanceHealth  = "/nacos/v1/ns/health/instance"   //更新实例健康状态
)

Variables

View Source
var BoolResult bool
View Source
var StringResult string

Functions

This section is empty.

Types

type Client

type Client struct {
	Config *Config
	// contains filtered or unexported fields
}

func New

func New(config *Config) *Client

func (*Client) CreateNamespace

func (c *Client) CreateNamespace(req *CreateNamespaceRequest) (bool, error)

CreateNamespace 创建命名空间

func (*Client) CreatePermission

func (c *Client) CreatePermission(req *CreatePermissionRequest) error

CreatePermission 创建权限

func (*Client) CreateRoles

func (c *Client) CreateRoles(req *CreateRoleRequest) error

func (*Client) CreateService

func (c *Client) CreateService(req *CreateServiceRequest) (bool, error)

CreateService 创建服务 //todo

func (*Client) CreateUser

func (c *Client) CreateUser(req *User) error

CreateUser 创建用户

func (*Client) DeleteConfig

func (c *Client) DeleteConfig(req *ConfigBase) error

DeleteConfig 删除配置

func (*Client) DeleteNamespace

func (c *Client) DeleteNamespace(req *DeleteNamespaceRequest) (bool, error)

DeleteNamespace 删除命名空间

func (*Client) DeletePermission

func (c *Client) DeletePermission(req *DeletePermissionRequest) error

func (*Client) DeleteRoles

func (c *Client) DeleteRoles(req *DeleteRoleRequest) error

func (*Client) DeleteService

func (c *Client) DeleteService(req *DeleteServiceRequest) (bool, error)

DeleteService 删除服务

func (*Client) DeleteUser

func (c *Client) DeleteUser(req *DeleteUserRequest) error

DeleteUser 删除用户

func (*Client) DeregisterInstance

func (c *Client) DeregisterInstance(req *DeregisterInstanceRequest) error

DeregisterInstance 注销实例

func (*Client) GetConfig

func (c *Client) GetConfig(req *ConfigBase) (string, error)

GetConfig 获取配置

func (*Client) GetConfigHistory

func (c *Client) GetConfigHistory(req *GetConfigHistoryRequest) (*GetConfigHistoryResponse, error)

GetConfigHistory 配置历史

func (*Client) GetConfigHistoryDetail

func (c *Client) GetConfigHistoryDetail(req *GetConfigHistoryDetailRequest) (*GetConfigHistoryDetailResponse, error)

GetConfigHistoryDetail 查询历史版本详情

func (*Client) GetConfigHistoryPrevious

func (c *Client) GetConfigHistoryPrevious(req *GetConfigHistoryPreviousRequest) (*GetConfigHistoryDetailResponse, error)

GetConfigHistoryPrevious 查询配置上一版本信息

func (*Client) GetInstance

func (c *Client) GetInstance(req *GetInstanceRequest) (*GetInstanceResponse, error)

GetInstance 查询实例详情

func (*Client) GetInstances

func (c *Client) GetInstances(req *GetInstancesRequest) (*GetInstancesResponse, error)

GetInstances 查询实例列表

func (*Client) GetNamespaces

func (c *Client) GetNamespaces() (*GetNamespacesResponse, error)

GetNamespaces 查询命名空间列表

func (*Client) GetOperatorLeader

func (c *Client) GetOperatorLeader() (*GetLeaderResponse, error)

GetOperatorLeader 查看当前集群leader

func (*Client) GetOperatorMetrics

func (c *Client) GetOperatorMetrics() (*GetMetricsResponse, error)

GetOperatorMetrics 查看系统当前数据指标

func (*Client) GetOperatorServerList

func (c *Client) GetOperatorServerList(req *GetServerListRequest) (*GetServerListResponse, error)

GetOperatorServerList 查看当前集群Server列表

func (*Client) GetOperatorSwitch

func (c *Client) GetOperatorSwitch() (*GetOperatorSwitchResponse, error)

GetOperatorSwitch 查询系统开关

func (*Client) GetPermissions

func (c *Client) GetPermissions(req *Page) (*GetPermissions, error)

GetPermissions 查询权限列表

func (*Client) GetRoles

func (c *Client) GetRoles(req *Page) (*GetRolesResponse, error)

func (*Client) GetService

func (c *Client) GetService(req *ServiceBase) (*ServiceBaseResponse, error)

GetService 查询服务详情

func (*Client) GetServiceList

func (c *Client) GetServiceList(req *GetServiceListRequest) (*GetServiceListResponse, error)

GetServiceList 查询服务列表

func (*Client) GetUsers

func (c *Client) GetUsers(req *Page) (*GetUsersResponse, error)

GetUsers 查询用户列表 //todo

func (*Client) Health

func (c *Client) Health() error

Health 检查服务是否健康

func (*Client) ListenConfig

func (c *Client) ListenConfig(req *ListeningConfigs) (string, error)

ListenConfig 监听配置 TODO: 未完成

func (*Client) Login

func (c *Client) Login() error

Login 登录

func (*Client) ModifyInstance

func (c *Client) ModifyInstance(req *ModifyInstanceRequest) error

ModifyInstance 修改实例

func (*Client) ModifyOperatorSwitch

func (c *Client) ModifyOperatorSwitch(req *ModifyOperatorSwitchRequest) (bool, error)

ModifyOperatorSwitch 修改系统开关

func (*Client) ModifyService

func (c *Client) ModifyService(req *ModifyServiceRequest) (bool, error)

ModifyService 修改服务 //todo

func (*Client) PublishConfig

func (c *Client) PublishConfig(req *PublishConfigRequest) error

PublishConfig 发布配置

func (*Client) PutNamespace

func (c *Client) PutNamespace(req *PutNamespaceRequest) (bool, error)

PutNamespace 修改命名空间

func (*Client) PutUser

func (c *Client) PutUser(req *User) error

PutUser 修改用户

func (*Client) RegisterInstance

func (c *Client) RegisterInstance(req *RegisterInstanceRequest) error

RegisterInstance 注册实例

func (*Client) SendHeartbeat

func (c *Client) SendHeartbeat(req *SendHeartbeatRequest) (bool, error)

SendHeartbeat 发送心跳

func (*Client) UpdateInstanceHealthStatus

func (c *Client) UpdateInstanceHealthStatus(req *UpdateInstanceHealthStatusRequest) (bool, error)

UpdateInstanceHealthStatus 更新实例的健康状态

type Config

type Config struct {
	Version  string `yaml:"version"`
	Addr     string `yaml:"addr"`
	Scheme   string `yaml:"scheme"`
	IP       string `yaml:"ip"`
	Port     string `yaml:"port"`
	Username string `yaml:"username"`
	Password string `yaml:"password"`
}

type ConfigBase

type ConfigBase struct {
	DataId string `json:"dataId" validate:"required"`
	Group  string `json:"group" validate:"required" default:"DEFAULT_GROUP"`
	Tenant string `json:"tenant" validate:"omitempty" default:"public"`
}

type CreateNamespaceRequest

type CreateNamespaceRequest struct {
	//customNamespaceId	字符串	是	命名空间ID
	//namespaceName	字符串	是	命名空间名
	//namespaceDesc	字符串	否	命名空间描述
	CustomNamespaceId string `json:"customNamespaceId" validate:"required"`
	NamespaceName     string `json:"namespaceName" validate:"required"`
	NamespaceDesc     string `json:"namespaceDesc" validate:"omitempty"`
}

type CreatePermissionRequest

type CreatePermissionRequest struct {
	Role        string `json:"role" validate:"required"`
	NamespaceId string `json:"namespaceId" validate:"required"`
	Action      string `json:"action" validate:"required,oneof=r w rw"`
}

type CreateRoleRequest

type CreateRoleRequest struct {
	Role     string `json:"role" validate:"required"`
	Username string `json:"username" validate:"required"`
}

type CreateServiceRequest

type CreateServiceRequest struct {
	ServiceBase
	ProtectThreshold float64               `json:"protectThreshold" validate:"omitempty,gte=0,lte=1" default:"0"` // 保护阈值,取值0到1,默认0
	Metadata         string                `json:"metadata" validate:"omitempty"`                                 // 元数据
	Selector         CreateServiceSelector `json:"selector" validate:"omitempty"`                                 // 访问策略
}

type CreateServiceSelector

type CreateServiceSelector struct {
	Default bool `json:"default"`
}

CreateServiceSelector 服务访问策略

type DeleteNamespaceRequest

type DeleteNamespaceRequest struct {
	NamespaceId string `json:"namespaceId" validate:"required"` // 命名空间 ID
}

type DeletePermissionRequest

type DeletePermissionRequest struct {
	Role     string `json:"role" validate:"required"`
	Resource string `json:"resource" validate:"required"`
	Action   string `json:"action" validate:"required,oneof=r w rw"`
}

type DeleteRoleRequest

type DeleteRoleRequest struct {
	Role     string `json:"role" validate:"required"`
	Username string `json:"username" validate:"required"`
}

type DeleteServiceRequest

type DeleteServiceRequest struct {
	ServiceBase
}

type DeleteUserRequest

type DeleteUserRequest struct {
	Username string `json:"username" validate:"required"`
}

type DeregisterInstanceRequest

type DeregisterInstanceRequest struct {
	IP          string `json:"ip" validate:"required"`
	Port        int    `json:"port" validate:"required"`
	NamespaceId string `json:"namespaceId" validate:"omitempty"`
	ClusterName string `json:"clusterName" validate:"omitempty"`
	ServiceName string `json:"serviceName" validate:"required"`
	GroupName   string `json:"groupName" validate:"omitempty"`
	Ephemeral   bool   `json:"ephemeral" validate:"omitempty"`
}

type DoParams

type DoParams struct {
	Method      string
	Req         interface{}
	Path        string
	Result      interface{}
	QueryParams map[string]string
}

type GetConfigHistoryDetailRequest

type GetConfigHistoryDetailRequest struct {
	Nid string `json:"nid" validate:"required"`
	ConfigBase
}

type GetConfigHistoryDetailResponse

type GetConfigHistoryDetailResponse struct {
	Id               string      `json:"id"`
	LastId           int         `json:"lastId"`
	DataId           string      `json:"dataId"`
	Group            string      `json:"group"`
	Tenant           string      `json:"tenant"`
	AppName          string      `json:"appName"`
	Md5              string      `json:"md5"`
	Content          string      `json:"content"`
	SrcIp            string      `json:"srcIp"`
	SrcUser          interface{} `json:"srcUser"`
	OpType           string      `json:"opType"`
	CreatedTime      string      `json:"createdTime"`
	LastModifiedTime string      `json:"lastModifiedTime"`
}

type GetConfigHistoryPreviousRequest

type GetConfigHistoryPreviousRequest struct {
	Id int `json:"id" validate:"required"` // 配置 ID
	ConfigBase
}

type GetConfigHistoryRequest

type GetConfigHistoryRequest struct {
	ConfigBase
	Page
}

type GetConfigHistoryResponse

type GetConfigHistoryResponse struct {
	TotalCount     int `json:"totalCount"`
	PageNumber     int `json:"pageNumber"`
	PagesAvailable int `json:"pagesAvailable"`
	PageItems      []struct {
		Id               string      `json:"id"`
		LastId           int         `json:"lastId"`
		DataId           string      `json:"dataId"`
		Group            string      `json:"group"`
		Tenant           string      `json:"tenant"`
		AppName          string      `json:"appName"`
		Md5              interface{} `json:"md5"` //
		Content          interface{} `json:"content"`
		SrcIp            string      `json:"srcIp"`
		SrcUser          string      `json:"srcUser"`
		OpType           string      `json:"opType"`
		CreatedTime      string      `json:"createdTime"`
		LastModifiedTime string      `json:"lastModifiedTime"`
	} `json:"pageItems"`
}

type GetInstanceRequest

type GetInstanceRequest struct {
	InstanceBase
	Healthy bool `json:"healthy" validate:"omitempty"`
}

type GetInstanceResponse

type GetInstanceResponse struct {
	Metadata struct {
	} `json:"metadata"`
	InstanceId  string  `json:"instanceId"`
	Port        int     `json:"port"`
	Service     string  `json:"service"`
	Healthy     bool    `json:"healthy"`
	Ip          string  `json:"ip"`
	ClusterName string  `json:"clusterName"`
	Weight      float64 `json:"weight"`
}

type GetInstancesRequest

type GetInstancesRequest struct {
	ServiceName string `json:"serviceName" validate:"required"`
	GroupName   string `json:"groupName" validate:"omitempty"`
	NamespaceId string `json:"namespaceId" validate:"omitempty"`
	Clusters    string `json:"clusters" validate:"omitempty"`
	HealthyOnly bool   `json:"healthyOnly" validate:"omitempty"`
}

type GetInstancesResponse

type GetInstancesResponse struct {
	Name        string `json:"name"`
	GroupName   string `json:"groupName"`
	Clusters    string `json:"clusters"`
	CacheMillis int    `json:"cacheMillis"`
	Hosts       []struct {
		InstanceId  string  `json:"instanceId"`
		Ip          string  `json:"ip"`
		Port        int     `json:"port"`
		Weight      float64 `json:"weight"`
		Healthy     bool    `json:"healthy"`
		Enabled     bool    `json:"enabled"`
		Ephemeral   bool    `json:"ephemeral"`
		ClusterName string  `json:"clusterName"`
		ServiceName string  `json:"serviceName"`
		Metadata    struct {
		} `json:"metadata"`
		InstanceHeartBeatInterval int    `json:"instanceHeartBeatInterval"`
		InstanceIdGenerator       string `json:"instanceIdGenerator"`
		InstanceHeartBeatTimeOut  int    `json:"instanceHeartBeatTimeOut"`
		IpDeleteTimeout           int    `json:"ipDeleteTimeout"`
	} `json:"hosts"`
	LastRefTime              int64  `json:"lastRefTime"`
	Checksum                 string `json:"checksum"`
	AllIPs                   bool   `json:"allIPs"`
	ReachProtectionThreshold bool   `json:"reachProtectionThreshold"`
	Valid                    bool   `json:"valid"`
}

type GetLeaderResponse

type GetLeaderResponse struct {
	Leader struct {
		HeartbeatDueMs int    `json:"heartbeatDueMs"`
		Ip             string `json:"ip"`
		LeaderDueMs    int    `json:"leaderDueMs"`
		State          string `json:"state"`
		Term           int    `json:"term"`
		VoteFor        string `json:"voteFor"`
	} `json:"leader"`
}

type GetMetricsResponse

type GetMetricsResponse struct {
	ServiceCount             int     `json:"serviceCount"`
	Load                     float64 `json:"load"`
	Mem                      float64 `json:"mem"`
	ResponsibleServiceCount  int     `json:"responsibleServiceCount"`
	InstanceCount            int     `json:"instanceCount"`
	Cpu                      float64 `json:"cpu"`
	Status                   string  `json:"status"`
	ResponsibleInstanceCount int     `json:"responsibleInstanceCount"`
}

type GetNamespacesResponse

type GetNamespacesResponse struct {
	Code    int         `json:"code"`
	Message interface{} `json:"message"`
	Data    []struct {
		Namespace         string `json:"namespace"`
		NamespaceShowName string `json:"namespaceShowName"`
		Quota             int    `json:"quota"`
		ConfigCount       int    `json:"configCount"`
		Type              int    `json:"type"`
	} `json:"data"`
}

type GetOperatorSwitchResponse

type GetOperatorSwitchResponse struct {
	Name        string      `json:"name"`
	Masters     interface{} `json:"masters"`
	AdWeightMap struct {
	} `json:"adWeightMap"`
	DefaultPushCacheMillis int     `json:"defaultPushCacheMillis"`
	ClientBeatInterval     int     `json:"clientBeatInterval"`
	DefaultCacheMillis     int     `json:"defaultCacheMillis"`
	DistroThreshold        float64 `json:"distroThreshold"`
	HealthCheckEnabled     bool    `json:"healthCheckEnabled"`
	DistroEnabled          bool    `json:"distroEnabled"`
	EnableStandalone       bool    `json:"enableStandalone"`
	PushEnabled            bool    `json:"pushEnabled"`
	CheckTimes             int     `json:"checkTimes"`
	HttpHealthParams       struct {
		Max    int     `json:"max"`
		Min    int     `json:"min"`
		Factor float64 `json:"factor"`
	} `json:"httpHealthParams"`
	TcpHealthParams struct {
		Max    int     `json:"max"`
		Min    int     `json:"min"`
		Factor float64 `json:"factor"`
	} `json:"tcpHealthParams"`
	MysqlHealthParams struct {
		Max    int     `json:"max"`
		Min    int     `json:"min"`
		Factor float64 `json:"factor"`
	} `json:"mysqlHealthParams"`
	IncrementalList                          []string `json:"incrementalList"`
	ServerStatusSynchronizationPeriodMillis  int      `json:"serverStatusSynchronizationPeriodMillis"`
	ServiceStatusSynchronizationPeriodMillis int      `json:"serviceStatusSynchronizationPeriodMillis"`
	DisableAddIP                             bool     `json:"disableAddIP"`
	SendBeatOnly                             bool     `json:"sendBeatOnly"`
	LimitedUrlMap                            struct {
	} `json:"limitedUrlMap"`
	DistroServerExpiredMillis int      `json:"distroServerExpiredMillis"`
	PushGoVersion             string   `json:"pushGoVersion"`
	PushJavaVersion           string   `json:"pushJavaVersion"`
	PushPythonVersion         string   `json:"pushPythonVersion"`
	PushCVersion              string   `json:"pushCVersion"`
	EnableAuthentication      bool     `json:"enableAuthentication"`
	OverriddenServerStatus    string   `json:"overriddenServerStatus"`
	DefaultInstanceEphemeral  bool     `json:"defaultInstanceEphemeral"`
	HealthCheckWhiteList      []string `json:"healthCheckWhiteList"`
	Checksum                  string   `json:"checksum"`
}

type GetPermissions

type GetPermissions struct {
	TotalCount     int `json:"totalCount"`
	PageNumber     int `json:"pageNumber"`
	PagesAvailable int `json:"pagesAvailable"`
	PageItems      []struct {
		Role     string `json:"role"`
		Resource string `json:"resource"`
		Action   string `json:"action"`
	} `json:"pageItems"`
}

type GetRolesResponse

type GetRolesResponse struct {
	TotalCount     int `json:"totalCount"`
	PageNumber     int `json:"pageNumber"`
	PagesAvailable int `json:"pagesAvailable"`
	PageItems      []struct {
		Role     string `json:"role"`
		Username string `json:"username"`
	} `json:"pageItems"`
}

type GetServerListRequest

type GetServerListRequest struct {
	Healthy bool `json:"healthy" validate:"omitempty"` // 是否只返回健康Server节点
}

type GetServerListResponse

type GetServerListResponse struct {
	Servers []struct {
		Ip             string `json:"ip"`
		ServePort      int    `json:"servePort"`
		Site           string `json:"site"`
		Weight         int    `json:"weight"`
		AdWeight       int    `json:"adWeight"`
		Alive          bool   `json:"alive"`
		LastRefTime    int    `json:"lastRefTime"`
		LastRefTimeStr string `json:"lastRefTimeStr"`
		Key            string `json:"key"`
	} `json:"servers"`
}

type GetServiceListRequest

type GetServiceListRequest struct {
	Page
	GroupName   string `json:"groupName" validate:"omitempty"`   // 分组名称
	NamespaceId string `json:"namespaceId" validate:"omitempty"` // 命名空间 ID
}

type GetServiceListResponse

type GetServiceListResponse struct {
	Count int      `json:"count"`
	Doms  []string `json:"doms"`
}

type GetUsersResponse

type GetUsersResponse struct {
	TotalCount     int `json:"totalCount"`
	PageNumber     int `json:"pageNumber"`
	PagesAvailable int `json:"pagesAvailable"`
	PageItems      []struct {
		Username string `json:"username"`
		Password string `json:"password"`
	} `json:"pageItems"`
}

type HeartBeat

type HeartBeat struct {
	Cluster  string `json:"cluster"`
	Ip       string `json:"ip"`
	Metadata struct {
	} `json:"metadata" validate:"omitempty"`
	Port        int    `json:"port"`
	Scheduled   bool   `json:"scheduled"`
	ServiceName string `json:"serviceName"`
	Weight      int    `json:"weight"`
}

type InstanceBase

type InstanceBase struct {
	IP          string `json:"ip" validate:"required"`           // 实例 IP
	Port        int    `json:"port" validate:"required"`         // 实例端口
	NamespaceId string `json:"namespaceId" validate:"omitempty"` // 命名空间 ID
	ClusterName string `json:"clusterName" validate:"omitempty"` // 集群名称
	ServiceName string `json:"serviceName" validate:"required"`  // 服务名称
	GroupName   string `json:"groupName" validate:"omitempty"`   // 分组名称
	Ephemeral   bool   `json:"ephemeral" validate:"omitempty"`   // 是否临时实例
}

type ListeningConfigs

type ListeningConfigs struct {
	ConfigBase
	ContentMD5 string `json:"contentMD5"  validate:"required"`
}

type LoginResponse

type LoginResponse struct {
	AccessToken string `json:"accessToken"`
	TokenTtl    int    `json:"tokenTtl"`
	GlobalAdmin bool   `json:"globalAdmin"`
	Username    string `json:"username"`
}

type ModifyInstanceRequest

type ModifyInstanceRequest struct {
	IP          string  `json:"ip" validate:"required"`
	Port        int     `json:"port" validate:"required"`
	NamespaceId string  `json:"namespaceId" validate:"omitempty"`
	Weight      float64 `json:"weight" validate:"omitempty"`
	Enable      bool    `json:"enable" validate:"omitempty"`
	Healthy     bool    `json:"healthy" validate:"omitempty"`
	Metadata    string  `json:"metadata" validate:"omitempty"`
	ClusterName string  `json:"clusterName" validate:"omitempty"`
	ServiceName string  `json:"serviceName" validate:"required"`
	GroupName   string  `json:"groupName" validate:"omitempty"`
	Ephemeral   bool    `json:"ephemeral" validate:"omitempty"`
}

type ModifyOperatorSwitchRequest

type ModifyOperatorSwitchRequest struct {
	Entry string `json:"entry" validate:"required"`  // 开关名
	Value string `json:"value" validate:"required"`  // 开关值
	Debug bool   `json:"debug" validate:"omitempty"` // 是否只在本机生效,true表示本机生效,false表示集群生效
}

type ModifyServiceRequest

type ModifyServiceRequest struct {
	ServiceBase
	ProtectThreshold float64               `json:"protectThreshold" validate:"omitempty,gte=0,lte=1" default:"0"` // 保护阈值,取值0到1,默认0
	Metadata         string                `json:"metadata" validate:"omitempty"`                                 // 元数据
	Selector         CreateServiceSelector `json:"selector" validate:"omitempty"`
}

type Page

type Page struct {
	PageNo   int `json:"pageNo" validate:"omitempty" default:"1"`
	PageSize int `json:"pageSize" validate:"omitempty,max=500" default:"500"`
}

type PublishConfigRequest

type PublishConfigRequest struct {
	ConfigBase
	Content     string `json:"content" validate:"required"`
	ContentType string `json:"contentType" validate:"omitempty"`
}

type PutNamespaceRequest

type PutNamespaceRequest struct {
	Namespace         string `json:"namespace" validate:"required"`         // 命名空间 ID
	NamespaceShowName string `json:"namespaceShowName" validate:"required"` // 命名空间展示名
	NamespaceDesc     string `json:"namespaceDesc" validate:"required"`
}

type RegisterInstanceRequest

type RegisterInstanceRequest struct {
	IP          string  `json:"ip" validate:"required"`
	Port        int     `json:"port" validate:"required"`
	NamespaceId string  `json:"namespaceId" validate:"omitempty"`
	Weight      float64 `json:"weight" validate:"omitempty"`
	Enable      bool    `json:"enable" validate:"omitempty"`
	Healthy     bool    `json:"healthy" validate:"omitempty"`
	Metadata    string  `json:"metadata" validate:"omitempty"`
	ClusterName string  `json:"clusterName" validate:"omitempty"`
	ServiceName string  `json:"serviceName" validate:"required"`
	GroupName   string  `json:"groupName" validate:"omitempty"`
	Ephemeral   bool    `json:"ephemeral" validate:"omitempty"`
}

type SendHeartbeatRequest

type SendHeartbeatRequest struct {
	InstanceBase
	HeartBeat HeartBeat `json:"beat" validate:"required"`
}

type ServiceBase

type ServiceBase struct {
	ServiceName string `json:"serviceName" validate:"required"`  // 服务名称
	GroupName   string `json:"groupName" validate:"omitempty"`   // 分组名称
	NamespaceId string `json:"namespaceId" validate:"omitempty"` // 命名空间 ID
}

type ServiceBaseResponse

type ServiceBaseResponse struct {
	Metadata struct {
	} `json:"metadata"`
	GroupName   string `json:"groupName"`
	NamespaceId string `json:"namespaceId"`
	Name        string `json:"name"`
	Selector    struct {
		Type string `json:"type"`
	} `json:"selector"`
	ProtectThreshold int `json:"protectThreshold"`
	Clusters         []struct {
		HealthChecker struct {
			Type string `json:"type"`
		} `json:"healthChecker"`
		Metadata struct {
		} `json:"metadata"`
		Name string `json:"name"`
	} `json:"clusters"`
}

type UpdateInstanceHealthStatusRequest

type UpdateInstanceHealthStatusRequest struct {
	IP          string `json:"ip" validate:"required"`           // 实例 IP
	Port        int    `json:"port" validate:"required"`         // 实例端口
	NamespaceId string `json:"namespaceId" validate:"omitempty"` // 命名空间 ID
	ClusterName string `json:"clusterName" validate:"omitempty"` // 集群名称
	ServiceName string `json:"serviceName" validate:"required"`  // 服务名称
	GroupName   string `json:"groupName" validate:"omitempty"`   // 分组名称
	Healthy     bool   `json:"healthy" validate:"required"`      // 是否健康
}

type User

type User struct {
	Username string `json:"username" validate:"required"`
	Password string `json:"password" validate:"required"`
}

Jump to

Keyboard shortcuts

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