Documentation ¶
Index ¶
- func AutoIP4() (string, bool)
- type AppClient
- func (ac *AppClient) Delete(path string, headers http.Header) (*http.Response, error)
- func (ac *AppClient) Get(path string, headers http.Header) (*http.Response, error)
- func (ac *AppClient) GetURL() (url string, err error)
- func (ac *AppClient) Patch(path string, body io.Reader, headers http.Header) (*http.Response, error)
- func (ac *AppClient) Post(path string, body io.Reader, headers http.Header) (*http.Response, error)
- func (ac *AppClient) Put(path string, body io.Reader, headers http.Header) (*http.Response, error)
- func (ac *AppClient) RefreshInstance() error
- type Instance
- func (ins *Instance) GetAppClient(app string) *AppClient
- func (ins *Instance) GetAppClientWithTimeout(app string, timeout time.Duration) *AppClient
- func (ins *Instance) IsRunning() bool
- func (ins *Instance) Run() error
- func (ins *Instance) SetServiceUrls(serviceUrls ...string)
- func (ins *Instance) Stop() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AppClient ¶
type AppClient struct { App string // contains filtered or unexported fields }
AppClient defines http client to send request to specified app instance.
func NewAppClient ¶
NewAppClient returns a new AppClient.
func NewAppClientWithTimeout ¶
func NewAppClientWithTimeout(app string, timeout time.Duration, serviceUrls ...string) (*AppClient, error)
NewAppClientWithTimeout returns a new AppClient with timeout.
func (*AppClient) GetURL ¶
GetURL randomly choose one instance of the app and returns its url(format: http://ip:port/). The url is valid only when the err is nil. The err is not nil when there's no instance of the app.
func (*AppClient) Patch ¶
func (ac *AppClient) Patch(path string, body io.Reader, headers http.Header) (*http.Response, error)
Patch sends a Patch request.
func (*AppClient) RefreshInstance ¶
RefreshInstance refresh the instance list.
type Instance ¶
type Instance struct { HostName string App string IPAddr string Port int SecurePort int // Default 60s HeartBeatInterval time.Duration // contains filtered or unexported fields }
Instance defines a simple eureka instance.
func NewInstance ¶
NewInstance returns a new Instance with no port enabled.
func NewInstanceWithPort ¶
NewInstanceWithPort returns a new Instance with one port enabled.
func NewInstanceWithSecurePort ¶
func NewInstanceWithSecurePort(app string, securePort int, serviceUrls ...string) (*Instance, error)
NewInstanceWithSecurePort returns a new Instance with one secure port(HTTPS) enabled.
func (*Instance) GetAppClient ¶
GetAppClient returns a new AppClient by app name.
func (*Instance) GetAppClientWithTimeout ¶
GetAppClientWithTimeout returns a new AppClient with timeout by app name.
func (*Instance) Run ¶
Run make the instance register to the eureka server. Note that this method will not block.
Also it listens for SIGINT and SIGTERM signal. By Receiving them, it will deregister ths instance from the eureka server.
func (*Instance) SetServiceUrls ¶
SetServiceUrls sets the service urls of eureka server.