eureka_client

package
v2.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: GPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Heartbeat

func Heartbeat(zone, app, instanceID string) error

Heartbeat 发送心跳 PUT /eureka/v2/apps/appID/instanceID

func Register

func Register(zone, app string, instance *Instance) error

Register 注册实例 POST /eureka/v2/apps/appID

func UnRegister

func UnRegister(zone, app, instanceID string) error

UnRegister 删除实例 DELETE /eureka/v2/apps/appID/instanceID

Types

type Application

type Application struct {
	Name      string     `xml:"name" json:"name"`
	Instances []Instance `xml:"instance" json:"instance"`
}

Application eureka服务端注册的app

type Applications

type Applications struct {
	VersionsDelta string        `xml:"versions__delta,omitempty" json:"versions__delta,omitempty"`
	AppsHashcode  string        `xml:"apps__hashcode,omitempty" json:"apps__hashcode,omitempty"`
	Applications  []Application `xml:"application,omitempty" json:"application,omitempty"`
}

Applications eureka服务端注册的apps

func Refresh

func Refresh(zone string) (*Applications, error)

Refresh 查询所有服务实例 GET /eureka/v2/apps

type Client

type Client struct {
	Running bool
	Config  *Config
	// eureka服务中注册的应用
	Applications *Applications
	// contains filtered or unexported fields
}

Client eureka客户端

func NewClient

func NewClient(config *Config) *Client

NewClient 创建客户端

func (*Client) Start

func (c *Client) Start() *Client

Start 启动时注册客户端,并后台刷新服务列表,以及心跳

type Config

type Config struct {
	// eureka服务端地址
	DefaultZone string
	// 心跳间隔,默认30s
	RenewalIntervalInSecs int
	// 获取服务列表间隔,默认15s
	RegistryFetchIntervalSeconds int
	// 过期间隔,默认90s
	DurationInSecs int
	// 应用名称
	App string
	// 端口
	Port     int
	Metadata map[string]interface{}
	// contains filtered or unexported fields
}

Config eureka客户端配置

type DataCenterInfo

type DataCenterInfo struct {
	Name     string              `xml:"name" json:"name"`
	Class    string              `xml:"class,attr" json:"@class"`
	Metadata *DataCenterMetadata `xml:"metadata,omitempty" json:"metadata,omitempty"`
}

DataCenterInfo 数据中心信息

type DataCenterMetadata

type DataCenterMetadata struct {
	AmiLaunchIndex   string `xml:"ami-launch-index,omitempty" json:"ami-launch-index,omitempty"`
	LocalHostname    string `xml:"local-hostname,omitempty" json:"local-hostname,omitempty"`
	AvailabilityZone string `xml:"availability-zone,omitempty" json:"availability-zone,omitempty"`
	InstanceID       string `xml:"instance-id,omitempty" json:"instance-id,omitempty"`
	PublicIpv4       string `xml:"public-ipv4,omitempty" json:"public-ipv4,omitempty"`
	PublicHostname   string `xml:"public-hostname,omitempty" json:"public-hostname,omitempty"`
	AmiManifestPath  string `xml:"ami-manifest-path,omitempty" json:"ami-manifest-path,omitempty"`
	LocalIpv4        string `xml:"local-ipv4,omitempty" json:"local-ipv4,omitempty"`
	Hostname         string `xml:"hostname,omitempty" json:"hostname,omitempty"`
	AmiID            string `xml:"ami-id,omitempty" json:"ami-id,omitempty"`
	InstanceType     string `xml:"instance-type,omitempty" json:"instance-type,omitempty"`
}

DataCenterMetadata 数据中心信息元数据

type Eureka

type Eureka struct {
	// contains filtered or unexported fields
}

func GetInstance

func GetInstance() *Eureka

func (*Eureka) GetEureka

func (c *Eureka) GetEureka() *Client

GetEureka 获取eureka

func (*Eureka) RunEureka

func (c *Eureka) RunEureka(defaultZone, app, version string, port int)

RunEureka 运行eureka

type Instance

type Instance struct {
	HostName                      string                 `xml:"hostName" json:"hostName"`
	HomePageURL                   string                 `xml:"homePageUrl,omitempty" json:"homePageUrl,omitempty"`
	StatusPageURL                 string                 `xml:"statusPageUrl" json:"statusPageUrl"`
	HealthCheckURL                string                 `xml:"healthCheckUrl,omitempty" json:"healthCheckUrl,omitempty"`
	App                           string                 `xml:"app" json:"app"`
	IPAddr                        string                 `xml:"ipAddr" json:"ipAddr"`
	VipAddress                    string                 `xml:"vipAddress" json:"vipAddress"`
	SecureVipAddress              string                 `xml:"secureVipAddress,omitempty" json:"secureVipAddress,omitempty"`
	Status                        string                 `xml:"status" json:"status"`
	Port                          *Port                  `xml:"port,omitempty" json:"port,omitempty"`
	SecurePort                    *Port                  `xml:"securePort,omitempty" json:"securePort,omitempty"`
	DataCenterInfo                *DataCenterInfo        `xml:"dataCenterInfo" json:"dataCenterInfo"`
	LeaseInfo                     *LeaseInfo             `xml:"leaseInfo,omitempty" json:"leaseInfo,omitempty"`
	Metadata                      map[string]interface{} `xml:"metadata,omitempty" json:"metadata,omitempty"`
	IsCoordinatingDiscoveryServer string                 `xml:"isCoordinatingDiscoveryServer,omitempty" json:"isCoordinatingDiscoveryServer,omitempty"`
	LastUpdatedTimestamp          string                 `xml:"lastUpdatedTimestamp,omitempty" json:"lastUpdatedTimestamp,omitempty"`
	LastDirtyTimestamp            string                 `xml:"lastDirtyTimestamp,omitempty" json:"lastDirtyTimestamp,omitempty"`
	ActionType                    string                 `xml:"actionType,omitempty" json:"actionType,omitempty"`
	OverriddenStatus              string                 `xml:"overriddenstatus,omitempty" json:"overriddenstatus,omitempty"`
	CountryID                     int                    `xml:"countryId,omitempty" json:"countryId,omitempty"`
	InstanceID                    string                 `xml:"instanceId,omitempty" json:"instanceId,omitempty"`
}

Instance 服务实例

func NewInstance

func NewInstance(ip string, config *Config) *Instance

NewInstance 创建服务实例

type LeaseInfo

type LeaseInfo struct {
	RenewalIntervalInSecs int `xml:"renewalIntervalInSecs,omitempty" json:"renewalIntervalInSecs,omitempty"`
	DurationInSecs        int `xml:"durationInSecs,omitempty" json:"durationInSecs,omitempty"`
}

LeaseInfo 续约信息

type Port

type Port struct {
	Port    int    `xml:",chardata" json:"$"`
	Enabled string `xml:"enabled,attr" json:"@enabled"`
}

Port 端口

type Url

type Url struct {
	Protocol   string
	ServerName string
	ServerPort int
	Path       string
	Param      string
}

Jump to

Keyboard shortcuts

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