eureka

package module
v0.0.0-...-40c3faa Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2016 License: Apache-2.0 Imports: 14 Imported by: 4

README

Build Status

go-eureka

Go client for Netflix Eureka.

WORK IN PROGRESS

Documentation

Index

Constants

View Source
const DefaultPollInterval = 30 * time.Second

DefaultPollInterval defines the default interval at which the watcher queries the registry.

Variables

View Source
var (
	// DefaultRetrySelector defines the default selector to be used when selecting
	// endpoints for request retries.
	DefaultRetrySelector retry.Selector = retry.RoundRobin

	// DefaultRetryLimit defines the default allowance for request retries.
	DefaultRetryLimit retry.Allow = retry.MaxRetries(3)

	// DefaultRetryDelay defines the default delay in-between request retries.
	DefaultRetryDelay retry.Delay = retry.ConstantDelay(1 * time.Second)

	// DefaultTransport defines the default roundtripper used by the internal http client.
	DefaultTransport = &http.Transport{
		Dial: (&net.Dialer{
			Timeout:   5 * time.Second,
			KeepAlive: 60 * time.Second,
		}).Dial,
		TLSHandshakeTimeout:   5 * time.Second,
		ResponseHeaderTimeout: 5 * time.Second,
		ExpectContinueTimeout: 1 * time.Second,
		MaxIdleConnsPerHost:   1,
	}

	// DefaultTimeout defines the default timeout used by the internal http client.
	DefaultTimeout = 10 * time.Second
)

Functions

This section is empty.

Types

type AmazonMetadata

type AmazonMetadata struct {
	HostName         string `xml:"hostname"`
	PublicHostName   string `xml:"public-hostname"`
	LocalHostName    string `xml:"local-hostname"`
	PublicIPV4       string `xml:"public-ipv4"`
	LocalIPV4        string `xml:"local-ipv4"`
	AvailabilityZone string `xml:"availability-zone"`
	InstanceID       string `xml:"instance-id"`
	InstanceType     string `xml:"instance-type"`
	AmiID            string `xml:"ami-id"`
	AmiLaunchIndex   string `xml:"ami-launch-index"`
	AmiManifestPath  string `xml:"ami-manifest-path"`
}

type App

type App struct {
	XMLName   xml.Name    `xml:"application"`
	Name      string      `xml:"name"`
	Instances []*Instance `xml:"instance"`
}

type AppsResponse

type AppsResponse struct {
	XMLName      xml.Name `xml:"applications"`
	VersionDelta int      `xml:"versions__delta"`
	Hashcode     string   `xml:"apps__hashcode"`
	Apps         []*App   `xml:"application"`
}

type Client

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

func NewClient

func NewClient(endpoints []string, options ...Option) *Client

func (*Client) App

func (c *Client) App(appName string) (*App, error)

func (*Client) AppInstance

func (c *Client) AppInstance(appName, instanceID string) (*Instance, error)

func (*Client) Apps

func (c *Client) Apps() ([]*App, error)

func (*Client) Deregister

func (c *Client) Deregister(instance *Instance) error

func (*Client) Heartbeat

func (c *Client) Heartbeat(instance *Instance) error

func (*Client) Instance

func (c *Client) Instance(instanceID string) (*Instance, error)

func (*Client) Register

func (c *Client) Register(instance *Instance) error

func (*Client) RemoveStatusOverride

func (c *Client) RemoveStatusOverride(instance *Instance, fallback Status) error

func (*Client) StatusOverride

func (c *Client) StatusOverride(instance *Instance, status Status) error

func (*Client) Watch

func (c *Client) Watch(pollInterval time.Duration) *Watcher

Watch returns a new watcher that keeps polling the registry at the defined interval and reports observed changes on its Events() channel.

type DataCenter

type DataCenter struct {
	Type     DataCenterType `xml:"name"`
	Metadata AmazonMetadata `xml:"metadata"`
}

type DataCenterType

type DataCenterType uint8
const (
	DataCenterTypePrivate DataCenterType = iota
	DataCenterTypeAmazon
)

func (DataCenterType) MarshalXML

func (dct DataCenterType) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*DataCenterType) UnmarshalXML

func (dct *DataCenterType) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type Duration

type Duration time.Duration

func (Duration) MarshalXML

func (d Duration) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*Duration) UnmarshalXML

func (d *Duration) UnmarshalXML(decoder *xml.Decoder, start xml.StartElement) error

type Event

type Event struct {
	Type     EventType
	Instance *Instance
}

Event holds information about the type and subject of an observation.

type EventType

type EventType uint8

EventType defines the type of an observed event.

const (
	// EventInstanceRegistered indicates that a newly registered instance has
	// been observed.
	EventInstanceRegistered EventType = iota

	// EventInstanceDeregistered indicates that a previously registered instance
	// is no longer registered.
	EventInstanceDeregistered

	// EventInstanceUpdated indicates that a previously registered instance has
	// changed in the registry, e.g. status or metadata changes have been observed.
	EventInstanceUpdated
)

type Instance

type Instance struct {
	XMLName        xml.Name   `xml:"instance"`
	ID             string     `xml:"instanceId"`
	HostName       string     `xml:"hostName"`
	AppName        string     `xml:"app"`
	IPAddr         string     `xml:"ipAddr"`
	VIPAddr        string     `xml:"vipAddress"`
	SecureVIPAddr  string     `xml:"secureVipAddress"`
	Status         Status     `xml:"status"`
	StatusOverride Status     `xml:"overriddenstatus"`
	Port           Port       `xml:"port"`
	SecurePort     Port       `xml:"securePort"`
	HomePageURL    string     `xml:"homePageUrl"`
	StatusPageURL  string     `xml:"statusPageUrl"`
	HealthCheckURL string     `xml:"healthCheckUrl"`
	DataCenterInfo DataCenter `xml:"dataCenterInfo"`
	LeaseInfo      Lease      `xml:"leaseInfo"`
	Metadata       Metadata   `xml:"metadata"`
}

func (*Instance) Equals

func (i *Instance) Equals(other *Instance) bool

Equals checks if two instances are the same. Does not compare LeaseInfo.

type Lease

type Lease struct {
	RenewalInterval  Duration `xml:"renewalIntervalInSecs"`
	Duration         Duration `xml:"durationInSecs"`
	RegistrationTime Time     `xml:"registrationTimestamp"`
	LastRenewalTime  Time     `xml:"lastRenewalTimestamp"`
	EvictionTime     Time     `xml:"evictionTimestamp"`
	ServiceUpTime    Time     `xml:"serviceUpTimestamp"`
}

type Metadata

type Metadata map[string]string

func (Metadata) Equals

func (m Metadata) Equals(other Metadata) bool

func (Metadata) MarshalXML

func (m Metadata) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*Metadata) UnmarshalXML

func (m *Metadata) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type Option

type Option func(*Client)

Option can be used to configure a Client.

func HTTPTimeout

func HTTPTimeout(t time.Duration) Option

HTTPTimeout sets the timeout for the internal HTTP client.

func HTTPTransport

func HTTPTransport(t *http.Transport) Option

HTTPTransport sets the transport for the internal HTTP client.

func Oauth2ClientCredentials

func Oauth2ClientCredentials(clientID, clientSecret, tokenURI string, scopes ...string) Option

Oauth2ClientCredentials instructs the internal http client to use the Oauth2 Client Credential flow to authenticate with the Eureka server.

func RetryDelay

func RetryDelay(delay retry.Delay) Option

RetryDelay sets the delau the client in-between request retries.

func RetryLimit

func RetryLimit(limit retry.Allow) Option

RetryLimit instructs the client to limit retries to a given allowance.

func RetrySelector

func RetrySelector(selector retry.Selector) Option

RetrySelector instructs the client to use a given selector to pick endpoints for retries.

func TLSConfig

func TLSConfig(config *tls.Config) Option

TLSConfig sets the TLS config for the internal HTTP client.

type Port

type Port uint16

func (Port) MarshalXML

func (p Port) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*Port) UnmarshalXML

func (p *Port) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type Registry

type Registry interface {
	Apps() ([]*App, error)
}

Registry is being used to poll for registered Apps.

type Status

type Status uint8
const (
	StatusUp Status = iota
	StatusDown
	StatusStarting
	StatusOutOfService
	StatusUnknown
)

func ParseStatus

func ParseStatus(name string) (status Status, err error)

func (Status) MarshalXML

func (s Status) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (Status) String

func (s Status) String() string

func (*Status) UnmarshalXML

func (s *Status) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type Time

type Time time.Time

func (Time) MarshalXML

func (t Time) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*Time) UnmarshalXML

func (t *Time) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type Watcher

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

Watcher can be used to observe the registry for changes with respect to the instances of particular app.

func (*Watcher) Events

func (w *Watcher) Events() <-chan Event

Events returns a channel that can be used to listen for changes to the app observed by this watcher.

func (*Watcher) Stop

func (w *Watcher) Stop()

Stop the watcher, i.e. the registry is no longer being polled.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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