Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultCheckRetry(cluster *Cluster, numReqs int, lastResp http.Response, err error) error
- func GetLogger() *log.Logger
- func SetLogger(loggerLog *log.Logger)
- type Application
- type Applications
- type Client
- func (c *Client) AddRootCA(caCert string) error
- func (c *Client) Delete(endpoint string) (*RawResponse, error)
- func (c *Client) Get(endpoint string) (*RawResponse, error)
- func (c *Client) GetApplication(appId string) (*Application, error)
- func (c *Client) GetApplications() (*Applications, error)
- func (c *Client) GetCluster() []string
- func (c *Client) GetInstance(appId, instanceId string) (*InstanceInfo, error)
- func (c *Client) GetSVIP(svipId string) (*Applications, error)
- func (c *Client) GetVIP(vipId string) (*Applications, error)
- func (c *Client) MarshalJSON() ([]byte, error)
- func (c *Client) Post(endpoint string, body []byte) (*RawResponse, error)
- func (c *Client) Put(endpoint string, body []byte) (*RawResponse, error)
- func (c *Client) RegisterInstance(appId string, instanceInfo *InstanceInfo) error
- func (c *Client) SendHeartbeat(appId, instanceId string) error
- func (c *Client) SendRequest(rr *RawRequest) (*RawResponse, error)
- func (c *Client) SetCluster(machines []string) bool
- func (c *Client) SetDialTimeout(d time.Duration)
- func (c *Client) SetTransport(tr *http.Transport)
- func (c *Client) SyncCluster() bool
- func (c *Client) UnmarshalJSON(b []byte) error
- func (c *Client) UnregisterInstance(appId, instanceId string) error
- type Cluster
- type Config
- type DataCenterInfo
- type DataCenterMetadata
- type EurekaError
- type Instance
- type InstanceInfo
- type LeaseInfo
- type MetaData
- type Port
- type RawRequest
- type RawResponse
- type Vraw
Constants ¶
const ( UP = "UP" DOWN = "DOWN" STARTING = "STARTING" )
const ( ErrCodeEurekaNotReachable = 501 ErrCodeInstanceNotFound = 502 )
Variables ¶
var (
ErrRequestCancelled = errors.New("sending request is cancelled")
)
Errors introduced by handling requests
Functions ¶
func DefaultCheckRetry ¶
DefaultCheckRetry defines the retrying behaviour for bad HTTP requests If we have retried 2 * machine number, stop retrying. If status code is InternalServerError, sleep for 200ms.
Types ¶
type Application ¶
type Application struct { Name string `xml:"name"` Instances []InstanceInfo `xml:"instance"` }
type Applications ¶
type Applications struct { VersionsDelta int `xml:"versions__delta"` AppsHashcode string `xml:"apps__hashcode"` Applications []Application `xml:"application,omitempty"` }
type Client ¶
type Client struct { Config Config `json:"config"` Cluster *Cluster `json:"cluster"` // CheckRetry can be used to control the policy for failed requests // and modify the cluster if needed. // The client calls it before sending requests again, and // stops retrying if CheckRetry returns some error. The cases that // this function needs to handle include no response and unexpected // http status code of response. // If CheckRetry is nil, client will call the default one // `DefaultCheckRetry`. // Argument cluster is the eureka.Cluster object that these requests have been made on. // Argument numReqs is the number of http.Requests that have been made so far. // Argument lastResp is the http.Responses from the last request. // Argument err is the reason of the failure. CheckRetry func(cluster *Cluster, numReqs int, lastResp http.Response, err error) error // contains filtered or unexported fields }
func NewClient ¶
NewClient create a basic client that is configured to be used with the given machine list.
func NewClientFromFile ¶
NewClientFromFile creates a client from a given file path. The given file is expected to use the JSON format.
func NewClientFromReader ¶
NewClientFromReader creates a Client configured from a given reader. The configuration is expected to use the JSON format.
func NewTLSClient ¶
NewTLSClient create a basic client with TLS configuration
func (*Client) Delete ¶
func (c *Client) Delete(endpoint string) (*RawResponse, error)
delete issues a DELETE request
func (*Client) Get ¶
func (c *Client) Get(endpoint string) (*RawResponse, error)
get issues a GET request
func (*Client) GetApplication ¶
func (c *Client) GetApplication(appId string) (*Application, error)
func (*Client) GetApplications ¶
func (c *Client) GetApplications() (*Applications, error)
func (*Client) GetCluster ¶
func (*Client) GetInstance ¶
func (c *Client) GetInstance(appId, instanceId string) (*InstanceInfo, error)
func (*Client) MarshalJSON ¶
MarshalJSON implements the Marshaller interface as defined by the standard JSON package.
func (*Client) Post ¶
func (c *Client) Post(endpoint string, body []byte) (*RawResponse, error)
post issues a POST request
func (*Client) Put ¶
func (c *Client) Put(endpoint string, body []byte) (*RawResponse, error)
put issues a PUT request
func (*Client) RegisterInstance ¶
func (c *Client) RegisterInstance(appId string, instanceInfo *InstanceInfo) error
func (*Client) SendHeartbeat ¶
func (*Client) SendRequest ¶
func (c *Client) SendRequest(rr *RawRequest) (*RawResponse, error)
func (*Client) SetCluster ¶
SetCluster updates cluster information using the given machine list.
func (*Client) SetDialTimeout ¶
Sets the DialTimeout value
func (*Client) SetTransport ¶
Override the Client's HTTP Transport object
func (*Client) SyncCluster ¶
SyncCluster updates the cluster information using the internal machine list.
func (*Client) UnmarshalJSON ¶
UnmarshalJSON implements the Unmarshaller interface as defined by the standard JSON package.
func (*Client) UnregisterInstance ¶
type Cluster ¶
func NewCluster ¶
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"` }
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"` }
type EurekaError ¶
type EurekaError struct { ErrorCode int `json:"errorCode"` Message string `json:"message"` Cause string `json:"cause,omitempty"` Index uint64 `json:"index"` }
func (EurekaError) Error ¶
func (e EurekaError) Error() string
type Instance ¶
type Instance struct {
Instance *InstanceInfo `xml:"instance" json:"instance"`
}
type InstanceInfo ¶
type InstanceInfo 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 *MetaData `xml:"metadata,omitempty" json:"metadata,omitempty"` IsCoordinatingDiscoveryServer bool `xml:"isCoordinatingDiscoveryServer,omitempty" json:"isCoordinatingDiscoveryServer,omitempty"` LastUpdatedTimestamp int `xml:"lastUpdatedTimestamp,omitempty" json:"lastUpdatedTimestamp,omitempty"` LastDirtyTimestamp int `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"` }
func NewInstanceInfo ¶
func NewInstanceInfo(hostName, app, ip string, port int, ttl uint, isSsl bool) *InstanceInfo
type LeaseInfo ¶
type LeaseInfo struct { EvictionDurationInSecs uint `xml:"evictionDurationInSecs,omitempty" json:"evictionDurationInSecs,omitempty"` RenewalIntervalInSecs int `xml:"renewalIntervalInSecs,omitempty" json:"renewalIntervalInSecs,omitempty"` DurationInSecs int `xml:"durationInSecs,omitempty" json:"durationInSecs,omitempty"` RegistrationTimestamp int `xml:"registrationTimestamp,omitempty" json:"registrationTimestamp,omitempty"` LastRenewalTimestamp int `xml:"lastRenewalTimestamp,omitempty" json:"lastRenewalTimestamp,omitempty"` EvictionTimestamp int `xml:"evictionTimestamp,omitempty" json:"evictionTimestamp,omitempty"` ServiceUpTimestamp int `xml:"serviceUpTimestamp,omitempty" json:"serviceUpTimestamp,omitempty"` }
type MetaData ¶
func (*MetaData) MarshalJSON ¶
func (*MetaData) MarshalXML ¶
func (*MetaData) UnmarshalJSON ¶
func (*MetaData) UnmarshalXML ¶
type RawRequest ¶
type RawRequest struct {
// contains filtered or unexported fields
}
func NewRawRequest ¶
func NewRawRequest(method, relativePath string, body []byte, cancel <-chan bool) *RawRequest