eureka

package module
v2.0.0-...-f75bdc1 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: MIT Imports: 12 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

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

func NewAPI

func NewAPI(ctx context.Context, client *Client, refreshInterval time.Duration) *API

func (*API) Deregister

func (e *API) Deregister(ctx context.Context, endpoints []Endpoint) error

Deregister ctx is the same as register ctx

func (*API) GetService

func (e *API) GetService(ctx context.Context, serverName string) []Instance

func (*API) Register

func (e *API) Register(ctx context.Context, serviceName string, endpoints ...Endpoint) error

func (*API) Subscribe

func (e *API) Subscribe(serverName string, fn func()) error

func (*API) ToAppID

func (e *API) ToAppID(serverName string) string

func (*API) Unsubscribe

func (e *API) Unsubscribe(serverName string)

type APIInterface

type APIInterface interface {
	Register(ctx context.Context, ep Endpoint) error
	Deregister(ctx context.Context, appID, instanceID string) error
	Heartbeat(ep Endpoint)
	FetchApps(ctx context.Context) []Application
	FetchAllUpInstances(ctx context.Context) []Instance
	FetchAppInstances(ctx context.Context, appID string) (m Application, err error)
	FetchAppUpInstances(ctx context.Context, appID string) []Instance
	FetchAppInstance(ctx context.Context, appID string, instanceID string) (m Instance, err error)
	FetchInstance(ctx context.Context, instanceID string) (m Instance, err error)
	Out(ctx context.Context, appID, instanceID string) error
	Down(ctx context.Context, appID, instanceID string) error
}

type Application

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

type ApplicationsResponse

type ApplicationsResponse struct {
	Version      string        `json:"versions__delta"`
	AppsHashcode string        `json:"apps__hashcode"`
	Applications []Application `json:"application"`
}

type ApplicationsRootResponse

type ApplicationsRootResponse struct {
	ApplicationsResponse `json:"applications"`
}

ApplicationsRootResponse for /eureka/apps

type Client

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

func NewClient

func NewClient(urls []string, opts ...ClientOption) *Client

func (*Client) Deregister

func (e *Client) Deregister(ctx context.Context, appID, instanceID string) error

func (*Client) Down

func (e *Client) Down(ctx context.Context, appID, instanceID string) error

func (*Client) FetchAllUpInstances

func (e *Client) FetchAllUpInstances(ctx context.Context) []Instance

func (*Client) FetchAppInstance

func (e *Client) FetchAppInstance(ctx context.Context, appID string, instanceID string) (m Instance, err error)

func (*Client) FetchAppInstances

func (e *Client) FetchAppInstances(ctx context.Context, appID string) (m Application, err error)

func (*Client) FetchAppUpInstances

func (e *Client) FetchAppUpInstances(ctx context.Context, appID string) []Instance

func (*Client) FetchApps

func (e *Client) FetchApps(ctx context.Context) []Application

func (*Client) FetchInstance

func (e *Client) FetchInstance(ctx context.Context, instanceID string) (m Instance, err error)

func (*Client) Heartbeat

func (e *Client) Heartbeat(ep Endpoint)

func (*Client) Out

func (e *Client) Out(ctx context.Context, appID, instanceID string) error

func (*Client) Register

func (e *Client) Register(ctx context.Context, ep Endpoint) error

type ClientOption

type ClientOption func(e *Client)

func WithClientContext

func WithClientContext(ctx context.Context) ClientOption

func WithHeartbeatInterval

func WithHeartbeatInterval(interval time.Duration) ClientOption

func WithMaxRetry

func WithMaxRetry(maxRetry int) ClientOption

func WithNamespace

func WithNamespace(path string) ClientOption

type DataCenterInfo

type DataCenterInfo struct {
	Name  string `json:"name"`
	Class string `json:"@class"`
}

type Endpoint

type Endpoint struct {
	InstanceID     string
	IP             string
	AppID          string
	Port           int
	SecurePort     int
	HomePageURL    string
	StatusPageURL  string
	HealthCheckURL string
	MetaData       map[string]string
}

type Instance

type Instance struct {
	InstanceID     string            `json:"instanceId"`
	HostName       string            `json:"hostName"`
	Port           Port              `json:"port"`
	App            string            `json:"app"`
	IPAddr         string            `json:"ipAddr"`
	VipAddress     string            `json:"vipAddress"`
	Status         string            `json:"status"`
	SecurePort     Port              `json:"securePort"`
	HomePageURL    string            `json:"homePageUrl"`
	StatusPageURL  string            `json:"statusPageUrl"`
	HealthCheckURL string            `json:"healthCheckUrl"`
	DataCenterInfo DataCenterInfo    `json:"dataCenterInfo"`
	Metadata       map[string]string `json:"metadata"`
}

type Option

type Option func(o *Registry)

func WithContext

func WithContext(ctx context.Context) Option

WithContext with registry context.

func WithEurekaPath

func WithEurekaPath(path string) Option

func WithHeartbeat

func WithHeartbeat(interval time.Duration) Option

func WithRefresh

func WithRefresh(interval time.Duration) Option

type Port

type Port struct {
	Port    int    `json:"$"`
	Enabled string `json:"@enabled"`
}

type Registry

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

func New

func New(eurekaUrls []string, opts ...Option) (*Registry, error)

func (*Registry) Deregister

func (r *Registry) Deregister(ctx context.Context, service *registry.ServiceInstance) error

Deregister registry service to zookeeper.

func (*Registry) Endpoints

func (r *Registry) Endpoints(service *registry.ServiceInstance) []Endpoint

func (*Registry) GetService

func (r *Registry) GetService(ctx context.Context, serviceName string) ([]*registry.ServiceInstance, error)

GetService get services from zookeeper

func (*Registry) Register

func (r *Registry) Register(ctx context.Context, service *registry.ServiceInstance) error

Register 这里的Context是每个注册器独享的

func (*Registry) Watch

func (r *Registry) Watch(ctx context.Context, serviceName string) (registry.Watcher, error)

Watch 是独立的ctx

type RequestInstance

type RequestInstance struct {
	Instance Instance `json:"instance"`
}

Jump to

Keyboard shortcuts

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