registry

package
v0.0.0-...-2f00c41 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultURL = "http://localhost:9687"

DefaultURL is the default SgulREG service url.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is the SgulREG API client.

func NewClient

func NewClient(registryURL string) *Client

NewClient returns a new instance of the SgulREG API client.

func (*Client) DiscoverAll

func (c *Client) DiscoverAll() ([]ServiceInfoResponse, error)

DiscoverAll query the Service Registry to get all registered services information. TODO: add WatchDiscoverAll()

func (*Client) NewRequest

func (c *Client) NewRequest(r ServiceRegistrationRequest)

NewRequest set the request struct to register the service.

func (*Client) Register

func (c *Client) Register() (ServiceRegistrationResponse, error)

Register sends a service registration request to the SgulREG service. TODO: add a channel to return results to the WatchRegistry() func.

func (*Client) WatchDiscoverAll

func (c *Client) WatchDiscoverAll()

WatchDiscoverAll call registry for all service discovery at regular intervals. Makes this client local registry always fresh.

func (*Client) WatchRegistry

func (c *Client) WatchRegistry()

WatchRegistry start registration retries till the registration goes well.

type ServiceInfoResponse

type ServiceInfoResponse struct {
	Name      string                `json:"name"`
	Instances []ServiceInstanceInfo `json:"instances"`
}

ServiceInfoResponse defines the structure of the service instance response. This is the struct that clients receive to get service discovery info.

type ServiceInstanceInfo

type ServiceInstanceInfo struct {
	InstanceID            string    `json:"instanceId"`
	Host                  string    `json:"host"`
	Schema                string    `json:"schema"`
	InfoURL               string    `json:"infoUrl"`
	HealthCheckURL        string    `json:"healthCheckUrl"`
	RegistrationTimestamp time.Time `json:"registrationTimestamp"`
	LastRefreshTimestamp  time.Time `json:"lastRefreshTimestamp"`
}

ServiceInstanceInfo defines the struct for an instance of a specific service.

type ServiceRegistrationRequest

type ServiceRegistrationRequest struct {
	Name           string `json:"name"`
	Host           string `json:"host"`
	Schema         string `json:"schema"`
	InfoURL        string `json:"infoUrl"`
	HealthCheckURL string `json:"healthCheckUrl"`
}

ServiceRegistrationRequest defines the structure sent from service in order to be registered with th registry.

type ServiceRegistrationResponse

type ServiceRegistrationResponse struct {
	InstanceID            string    `json:"instanceId"`
	RegistrationTimestamp time.Time `json:"registrationTimestamp"`
}

ServiceRegistrationResponse defines the structure returned after a service instance registration.

Jump to

Keyboard shortcuts

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