Documentation ¶
Index ¶
- Constants
- Variables
- func CastNanInf(b bool)
- func ObjectToString(value interface{}) string
- func RateLimitResponse(rsp *restful.Response)
- type Application
- type ApplicationResponse
- type Applications
- type ApplicationsBuilder
- type ApplicationsRespCache
- type ApplicationsResponse
- type ApplicationsWorker
- func (a *ApplicationsWorker) GetCachedAppsWithLoad() *ApplicationsRespCache
- func (a *ApplicationsWorker) GetDeltaApps() *ApplicationsRespCache
- func (a *ApplicationsWorker) GetVipApps(key VipCacheKey) *ApplicationsRespCache
- func (a *ApplicationsWorker) IsStarted() bool
- func (a *ApplicationsWorker) StartWorker() context.Context
- func (a *ApplicationsWorker) Stop()
- type ApplicationsWorkers
- type DataCenterInfo
- type EurekaInstanceEventHandler
- type EurekaServer
- func (h *EurekaServer) BatchReplication(req *restful.Request, rsp *restful.Response)
- func (h *EurekaServer) CancelInstance(req *restful.Request, rsp *restful.Response)
- func (h *EurekaServer) DeleteStatus(req *restful.Request, rsp *restful.Response)
- func (h *EurekaServer) GetAllApplications(req *restful.Request, rsp *restful.Response)
- func (h *EurekaServer) GetAppInstance(req *restful.Request, rsp *restful.Response)
- func (h *EurekaServer) GetApplication(req *restful.Request, rsp *restful.Response)
- func (h *EurekaServer) GetDeltaApplications(req *restful.Request, rsp *restful.Response)
- func (h *EurekaServer) GetEurekaServer() *restful.WebService
- func (h *EurekaServer) GetEurekaV1Server() *restful.WebService
- func (h *EurekaServer) GetEurekaV2Server() *restful.WebService
- func (h *EurekaServer) GetInstance(req *restful.Request, rsp *restful.Response)
- func (h *EurekaServer) GetPort() uint32
- func (h *EurekaServer) GetProtocol() string
- func (h *EurekaServer) Initialize(ctx context.Context, option map[string]interface{}, ...) error
- func (h *EurekaServer) QueryBySVipAddress(req *restful.Request, rsp *restful.Response)
- func (h *EurekaServer) QueryByVipAddress(req *restful.Request, rsp *restful.Response)
- func (h *EurekaServer) RegisterApplication(req *restful.Request, rsp *restful.Response)
- func (h *EurekaServer) RenewInstance(req *restful.Request, rsp *restful.Response)
- func (h *EurekaServer) Restart(option map[string]interface{}, api map[string]apiserver.APIConfig, ...) error
- func (h *EurekaServer) Run(errCh chan error)
- func (h *EurekaServer) Stop()
- func (h *EurekaServer) UpdateMetadata(req *restful.Request, rsp *restful.Response)
- func (h *EurekaServer) UpdateStatus(req *restful.Request, rsp *restful.Response)
- type InstanceInfo
- type InstanceResponse
- type Lease
- type LeaseInfo
- type Metadata
- type PortWrapper
- type RegistrationRequest
- type ReplicateWorker
- type ReplicateWorkers
- type ReplicationInstance
- type ReplicationInstanceResponse
- type ReplicationList
- type ReplicationListResponse
- type StringMap
- type VipCacheKey
Constants ¶
const ( ParamAppId string = "appId" ParamInstId string = "instId" ParamValue string = "value" ParamVip string = "vipAddress" ParamSVip string = "svipAddress" HeaderNamespace string = "x-namespace" )
const ( DefaultNamespace = "default" DefaultRefreshInterval = 10 DefaultDetailExpireInterval = 60 // DefaultEnableSelfPreservation whether to enable preservation mechanism DefaultEnableSelfPreservation = true // DefaultSelfPreservationPercent instances unhealthy percent over 85% (around 15 min instances), // it will return all checked instances DefaultSelfPreservationPercent = 85 // DefaultSelfPreservationDuration instance unhealthy check point to preservation, // instances over 15 min won't get preservation DefaultSelfPreservationDuration = 15 * time.Minute DefaultListenIP = "0.0.0.0" DefaultListenPort = 8761 )
const ( SecureProtocol = "HTTPS" InsecureProtocol = "HTTP" MetadataRegisterFrom = "internal-register-from" MetadataAppGroupName = "internal-eureka-app-group" MetadataCountryId = "internal-eureka-country-id" MetadataDataCenterInfoClazz = "internal-eureka-dci-clazz" MetadataDataCenterInfoName = "internal-eureka-dci-name" MetadataHostName = "internal-eureka-hostname" MetadataRenewalInterval = "internal-eureka-renewal-interval" MetadataDuration = "internal-eureka-duration" MetadataHomePageUrl = "internal-eureka-home-url" MetadataStatusPageUrl = "internal-eureka-status-url" MetadataHealthCheckUrl = "internal-eureka-health-url" MetadataVipAddress = "internal-eureka-vip" MetadataSecureVipAddress = "internal-eureka-secure-vip" MetadataInsecurePort = "internal-eureka-insecure-port" MetadataInsecurePortEnabled = "internal-eureka-insecure-port-enabled" MetadataSecurePort = "internal-eureka-secure-port" MetadataSecurePortEnabled = "internal-eureka-secure-port-enabled" MetadataReplicate = "internal-eureka-replicate" MetadataInstanceId = "internal-eureka-instance-id" ServerEureka = "eureka" KeyRegion = "region" StatusOutOfService = "OUT_OF_SERVICE" StatusUp = "UP" StatusDown = "DOWN" StatusUnknown = "UNKNOWN" ActionAdded = "ADDED" ActionModified = "MODIFIED" ActionDeleted = "DELETED" DefaultCountryIdInt = 1 DefaultDciClazz = "com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo" DefaultDciName = "MyOwn" DefaultRenewInterval = 30 DefaultDuration = 90 DefaultUnhealthyExpireInterval = 180 DefaultOwner = "polaris" DefaultSSLPort = 443 DefaultInsecurePort = 8080 CustomKeyDciClass = "dataCenterInfoClass" CustomKeyDciName = "dataCenterInfoName" )
const (
MimeJsonWild = "application/*+json"
)
Variables ¶
var ( DefaultDataCenterInfo = &DataCenterInfo{ Clazz: DefaultDciClazz, Name: DefaultDciName, } DefaultCountryId = strconv.Itoa(DefaultCountryIdInt) CustomEurekaParameters = make(map[string]string) )
Functions ¶
func CastNanInf ¶
func CastNanInf(b bool)
Cast "Nan", "Inf", "-Inf" XML values to 'float64'. By default, these values will be decoded as 'string'.
func ObjectToString ¶
func ObjectToString(value interface{}) string
ObjectToString interface type to string
Types ¶
type Application ¶
type Application struct { XMLName struct{} `json:"-" xml:"application"` Name string `json:"name" xml:"name"` Instance []*InstanceInfo `json:"instance" xml:"instance"` InstanceMap map[string]*InstanceInfo `json:"-" xml:"-"` Revision string `json:"-" xml:"-"` StatusCounts map[string]int `json:"-" xml:"-"` }
Application 服务数据
func (*Application) GetInstance ¶
func (a *Application) GetInstance(instId string) *InstanceInfo
GetInstance 获取eureka实例
type ApplicationResponse ¶
type ApplicationResponse struct {
Application *Application `json:"application"`
}
ApplicationResponse 单个服务拉取响应
type Applications ¶
type Applications struct { XMLName struct{} `json:"-" xml:"applications"` VersionsDelta string `json:"versions__delta" xml:"versions__delta"` AppsHashCode string `json:"apps__hashcode" xml:"apps__hashcode"` Application []*Application `json:"application" xml:"application"` ApplicationMap map[string]*Application `json:"-" xml:"-"` }
Applications 服务列表
func (*Applications) GetApplication ¶
func (a *Applications) GetApplication(appId string) *Application
GetApplication 获取eureka应用
func (*Applications) GetInstance ¶
func (a *Applications) GetInstance(instId string) *InstanceInfo
GetInstance get instance by instanceId
type ApplicationsBuilder ¶
type ApplicationsBuilder struct { // autoincrement version VersionIncrement int64 // contains filtered or unexported fields }
ApplicationsBuilder builder to do application construct
func (*ApplicationsBuilder) BuildApplications ¶
func (a *ApplicationsBuilder) BuildApplications(oldAppsCache *ApplicationsRespCache) *ApplicationsRespCache
BuildApplications build applications cache with compare to the latest cache
type ApplicationsRespCache ¶
type ApplicationsRespCache struct { AppsResp *ApplicationsResponse Revision string JsonBytes []byte XmlBytes []byte // contains filtered or unexported fields }
ApplicationsRespCache 全量服务缓存
func BuildApplicationsForVip ¶
func BuildApplicationsForVip(key *VipCacheKey, appsCache *ApplicationsRespCache) *ApplicationsRespCache
BuildApplicationsForVip build applications with target vip
type ApplicationsResponse ¶
type ApplicationsResponse struct {
Applications *Applications `json:"applications"`
}
ApplicationsResponse 服务拉取应答
type ApplicationsWorker ¶
type ApplicationsWorker struct {
// contains filtered or unexported fields
}
ApplicationsWorker 应用缓存协程
func NewApplicationsWorker ¶
func NewApplicationsWorker(interval time.Duration, deltaExpireInterval time.Duration, enableSelfPreservation bool, namingServer service.DiscoverServer, healthCheckServer *healthcheck.Server, namespace string) *ApplicationsWorker
NewApplicationsWorker 构造函数
func (*ApplicationsWorker) GetCachedAppsWithLoad ¶
func (a *ApplicationsWorker) GetCachedAppsWithLoad() *ApplicationsRespCache
GetCachedAppsWithLoad 从缓存中获取全量服务信息,如果不存在就读取
func (*ApplicationsWorker) GetDeltaApps ¶
func (a *ApplicationsWorker) GetDeltaApps() *ApplicationsRespCache
GetDeltaApps 从缓存获取增量服务数据
func (*ApplicationsWorker) GetVipApps ¶
func (a *ApplicationsWorker) GetVipApps(key VipCacheKey) *ApplicationsRespCache
GetVipApps 从缓存中读取VIP资源
func (*ApplicationsWorker) IsStarted ¶
func (a *ApplicationsWorker) IsStarted() bool
IsStarted 是否已经启动
func (*ApplicationsWorker) StartWorker ¶
func (a *ApplicationsWorker) StartWorker() context.Context
StartWorker 启动缓存构建器
type ApplicationsWorkers ¶ added in v1.17.0
type ApplicationsWorkers struct {
// contains filtered or unexported fields
}
func NewApplicationsWorkers ¶ added in v1.17.0
func NewApplicationsWorkers(interval time.Duration, deltaExpireInterval time.Duration, enableSelfPreservation bool, namingServer service.DiscoverServer, healthCheckServer *healthcheck.Server, namespaces ...string) *ApplicationsWorkers
func (*ApplicationsWorkers) Get ¶ added in v1.17.0
func (a *ApplicationsWorkers) Get(namespace string) *ApplicationsWorker
func (*ApplicationsWorkers) Stop ¶ added in v1.17.0
func (a *ApplicationsWorkers) Stop()
type DataCenterInfo ¶
type DataCenterInfo struct { Clazz string `json:"@class" xml:"class,attr"` Name string `json:"name" xml:"name"` }
DataCenterInfo 数据中心信息
type EurekaInstanceEventHandler ¶ added in v1.15.0
type EurekaInstanceEventHandler struct { *service.BaseInstanceEventHandler // contains filtered or unexported fields }
type EurekaServer ¶
type EurekaServer struct {
// contains filtered or unexported fields
}
EurekaServer is the Eureka server
func (*EurekaServer) BatchReplication ¶
func (h *EurekaServer) BatchReplication(req *restful.Request, rsp *restful.Response)
BatchReplication do the server request replication
func (*EurekaServer) CancelInstance ¶
func (h *EurekaServer) CancelInstance(req *restful.Request, rsp *restful.Response)
CancelInstance 实例反注册
func (*EurekaServer) DeleteStatus ¶
func (h *EurekaServer) DeleteStatus(req *restful.Request, rsp *restful.Response)
DeleteStatus 关闭强制隔离
func (*EurekaServer) GetAllApplications ¶
func (h *EurekaServer) GetAllApplications(req *restful.Request, rsp *restful.Response)
GetAllApplications 全量拉取服务实例信息
func (*EurekaServer) GetAppInstance ¶
func (h *EurekaServer) GetAppInstance(req *restful.Request, rsp *restful.Response)
GetAppInstance 拉取应用下某个实例的信息
func (*EurekaServer) GetApplication ¶
func (h *EurekaServer) GetApplication(req *restful.Request, rsp *restful.Response)
GetApplication 拉取单个服务实例信息
func (*EurekaServer) GetDeltaApplications ¶
func (h *EurekaServer) GetDeltaApplications(req *restful.Request, rsp *restful.Response)
GetDeltaApplications 增量拉取服务实例信息
func (*EurekaServer) GetEurekaServer ¶
func (h *EurekaServer) GetEurekaServer() *restful.WebService
GetEurekaServer eureka web server
func (*EurekaServer) GetEurekaV1Server ¶
func (h *EurekaServer) GetEurekaV1Server() *restful.WebService
GetEurekaV1Server eureka v1 web server
func (*EurekaServer) GetEurekaV2Server ¶
func (h *EurekaServer) GetEurekaV2Server() *restful.WebService
GetEurekaV2Server eureka v2 web server
func (*EurekaServer) GetInstance ¶
func (h *EurekaServer) GetInstance(req *restful.Request, rsp *restful.Response)
GetInstance query instance by id
func (*EurekaServer) Initialize ¶
func (h *EurekaServer) Initialize(ctx context.Context, option map[string]interface{}, api map[string]apiserver.APIConfig) error
Initialize 初始化HTTP API服务器
func (*EurekaServer) QueryBySVipAddress ¶
func (h *EurekaServer) QueryBySVipAddress(req *restful.Request, rsp *restful.Response)
QueryBySVipAddress query for all instances under a particular secure vip address
func (*EurekaServer) QueryByVipAddress ¶
func (h *EurekaServer) QueryByVipAddress(req *restful.Request, rsp *restful.Response)
QueryByVipAddress query for all instances under a particular vip address
func (*EurekaServer) RegisterApplication ¶
func (h *EurekaServer) RegisterApplication(req *restful.Request, rsp *restful.Response)
RegisterApplication 服务注册
func (*EurekaServer) RenewInstance ¶
func (h *EurekaServer) RenewInstance(req *restful.Request, rsp *restful.Response)
RenewInstance 更新实例状态
func (*EurekaServer) Restart ¶
func (h *EurekaServer) Restart( option map[string]interface{}, api map[string]apiserver.APIConfig, errCh chan error) error
Restart 重启eurekaServer
func (*EurekaServer) UpdateMetadata ¶
func (h *EurekaServer) UpdateMetadata(req *restful.Request, rsp *restful.Response)
UpdateMetadata updateStatus instance metadata
func (*EurekaServer) UpdateStatus ¶
func (h *EurekaServer) UpdateStatus(req *restful.Request, rsp *restful.Response)
UpdateStatus 更新服务状态
type InstanceInfo ¶
type InstanceInfo struct { XMLName struct{} `json:"-" xml:"instance"` InstanceId string `json:"instanceId" xml:"instanceId"` AppName string `json:"app" xml:"app"` AppGroupName string `json:"appGroupName" xml:"appGroupName,omitempty"` IpAddr string `json:"ipAddr" xml:"ipAddr"` Sid string `json:"sid" xml:"sid,omitempty"` Port *PortWrapper `json:"port" xml:"port,omitempty"` SecurePort *PortWrapper `json:"securePort" xml:"securePort,omitempty"` HomePageUrl string `json:"homePageUrl" xml:"homePageUrl,omitempty"` StatusPageUrl string `json:"statusPageUrl" xml:"statusPageUrl,omitempty"` HealthCheckUrl string `json:"healthCheckUrl" xml:"healthCheckUrl,omitempty"` SecureHealthCheckUrl string `json:"secureHealthCheckUrl" xml:"secureHealthCheckUrl,omitempty"` VipAddress string `json:"vipAddress" xml:"vipAddress,omitempty"` SecureVipAddress string `json:"secureVipAddress" xml:"secureVipAddress,omitempty"` CountryId interface{} `json:"countryId" xml:"countryId,omitempty"` DataCenterInfo *DataCenterInfo `json:"dataCenterInfo" xml:"dataCenterInfo"` HostName string `json:"hostName" xml:"hostName,omitempty"` Status string `json:"status" xml:"status"` OverriddenStatus string `json:"overriddenStatus" xml:"overriddenStatus,omitempty"` LeaseInfo *LeaseInfo `json:"leaseInfo" xml:"leaseInfo,omitempty"` //nolint: lll IsCoordinatingDiscoveryServer interface{} `json:"isCoordinatingDiscoveryServer" xml:"isCoordinatingDiscoveryServer,omitempty"` Metadata *Metadata `json:"metadata" xml:"metadata"` LastUpdatedTimestamp interface{} `json:"lastUpdatedTimestamp" xml:"lastUpdatedTimestamp,omitempty"` LastDirtyTimestamp interface{} `json:"lastDirtyTimestamp" xml:"lastDirtyTimestamp,omitempty"` ActionType string `json:"actionType" xml:"actionType"` // 实际的北极星实例模型 RealInstance *apiservice.Instance `json:"-" xml:"-"` }
InstanceInfo 实例信息
func (*InstanceInfo) Clone ¶
func (i *InstanceInfo) Clone(actionType string) *InstanceInfo
Clone 对实例进行拷贝
func (*InstanceInfo) Equals ¶
func (i *InstanceInfo) Equals(another *InstanceInfo) bool
Equals 判断实例是否发生变更
type InstanceResponse ¶
type InstanceResponse struct {
InstanceInfo *InstanceInfo `json:"instance" xml:"instance"`
}
InstanceResponse 单个服务实例拉取响应
type LeaseInfo ¶
type LeaseInfo struct { // Client settings RenewalIntervalInSecs int `json:"renewalIntervalInSecs" xml:"renewalIntervalInSecs"` DurationInSecs int `json:"durationInSecs" xml:"durationInSecs"` // Server populated RegistrationTimestamp int `json:"registrationTimestamp" xml:"registrationTimestamp"` LastRenewalTimestamp int `json:"lastRenewalTimestamp" xml:"lastRenewalTimestamp"` EvictionTimestamp int `json:"evictionTimestamp" xml:"evictionTimestamp"` ServiceUpTimestamp int `json:"serviceUpTimestamp" xml:"serviceUpTimestamp"` }
LeaseInfo 租约信息
type Metadata ¶
Metadata 元数据信息,xml 格式无法直接反序列化成 map[string]string 类型。这里通过 []byte 类型的 Raw 接收,并反序列化到 Meta 中。 反序列化后,polaris 在业务中只使用 Meta 字段。
func (*Metadata) MarshalJSON ¶
MarshalJSON Metadata json 序列化方法
func (*Metadata) MarshalXML ¶
MarshalXML Metadata xml 序列化方法
func (*Metadata) UnmarshalJSON ¶
UnmarshalJSON Metadata json 反序列化方法
func (*Metadata) UnmarshalXML ¶
UnmarshalXML Metadata xml 反序列化方法
type PortWrapper ¶
type PortWrapper struct { Port interface{} `json:"$" xml:",chardata"` RealPort int `json:"-" xml:"-"` Enabled interface{} `json:"@enabled" xml:"enabled,attr"` RealEnable bool `json:"-" xml:"-"` }
PortWrapper 端口包装类
func (*PortWrapper) UnmarshalXML ¶
func (p *PortWrapper) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
UnmarshalXML PortWrapper xml 反序列化
type RegistrationRequest ¶
type RegistrationRequest struct {
Instance *InstanceInfo `json:"instance"`
}
RegistrationRequest 实例注册请求
type ReplicateWorker ¶
type ReplicateWorker struct {
// contains filtered or unexported fields
}
func NewReplicateWorker ¶
func NewReplicateWorker(ctx context.Context, namespace string, peers []string) *ReplicateWorker
func (*ReplicateWorker) AddReplicateTask ¶
func (r *ReplicateWorker) AddReplicateTask(task *ReplicationInstance)
type ReplicateWorkers ¶ added in v1.17.0
type ReplicateWorkers struct {
// contains filtered or unexported fields
}
func NewReplicateWorkers ¶ added in v1.17.0
func NewReplicateWorkers(ctx context.Context, namespacePeers map[string][]string) *ReplicateWorkers
func (*ReplicateWorkers) Get ¶ added in v1.17.0
func (r *ReplicateWorkers) Get(namespace string) (*ReplicateWorker, bool)
type ReplicationInstance ¶
type ReplicationInstance struct { AppName string `json:"appName"` Id string `json:"id"` LastDirtyTimestamp int64 `json:"lastDirtyTimestamp"` OverriddenStatus string `json:"overriddenStatus"` Status string `json:"status"` InstanceInfo *InstanceInfo `json:"instanceInfo"` Action string `json:"action"` }
ReplicationInstance request for instance replicate
type ReplicationInstanceResponse ¶
type ReplicationInstanceResponse struct { StatusCode int `json:"statusCode"` ResponseEntity *InstanceInfo `json:"responseEntity"` }
ReplicationInstanceResponse response for instance replicate process
type ReplicationList ¶
type ReplicationList struct {
ReplicationList []*ReplicationInstance `json:"replicationList"`
}
ReplicationList instances list to replicate
type ReplicationListResponse ¶
type ReplicationListResponse struct {
ResponseList []*ReplicationInstanceResponse `json:"responseList"`
}
ReplicationListResponse list for replicate instance response
type VipCacheKey ¶
type VipCacheKey struct {
// contains filtered or unexported fields
}
VipCacheKey key for reference the vip cache