discovery

package
v5.7.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoCheckRegister

func DoCheckRegister(cr CheckRegister, addr string, c *Check) error

DoCheckRegister function to register a new check

func DoCheckUnregister

func DoCheckUnregister(cr CheckRegister, addr, checkID string) error

DoCheckUnregister function to unregister a check by ID

func DoServiceRegister

func DoServiceRegister(sr ServiceRegister, addr string, s *Service) error

DoServiceRegister function to register a new service

func DoServiceUnregister

func DoServiceUnregister(sr ServiceRegister, addr, serviceID string) error

DoServiceUnregister function to unregister a service by ID

func GetServiceTargets

func GetServiceTargets(addr, serviceID string) (targets []string, err error)

GetServiceTargets create a slice of addresses based on the services returned from CatalogService

func GetStatus

func GetStatus(l Leader, addr string) (string, error)

GetStatus function to get the status of consul leader node

Types

type Check

type Check struct {
	ID                             string `json:"ID,omitempty"`
	CheckID                        string `json:"CheckID,omitempty"`
	Name                           string `json:"Name"`
	Node                           string `json:"Node,omitempty"`
	Notes                          string `json:"Notes,omitempty"`
	DeregisterCriticalServiceAfter string `json:"DeregisterCriticalServiceAfter,omitempty"`
	Script                         string `json:"Script,omitempty"`
	DockerContainerID              string `json:"DockerContainerID,omitempty"`
	Shell                          string `json:"Shell,omitempty"`
	HTTP                           string `json:"HTTP,omitempty"`
	TCP                            string `json:"TCP,omitempty"`
	Interval                       string `json:"Interval,omitempty"`
	TTL                            string `json:"TTL,omitempty"`
	Timeout                        string `json:"Timeout,omitempty"`
	ServiceID                      string `json:"ServiceID,omitempty"`
	Status                         string `json:"Status,omitempty"`
}

Check struct

type CheckRegister

type CheckRegister interface {
	Register(addr, path string, c *Check) error
	Unregister(addr, path, checkID string) error
}

CheckRegister interface

type Checker

type Checker interface {
	GetChecks(addr, path string) (Checks, error)
}

Checker interface

type Checks

type Checks map[string]Check

Checks map of checks

func GetChecks

func GetChecks(c Checker, addr string) (Checks, error)

GetChecks function to get a map of checks

type Config

type Config struct {
	Addr string
	// Services []*Service
	Services Services
	// Checks   []*Check
	Checks Checks
}

Config pluto service config

func (*Config) URL

func (c *Config) URL() string

URL service discovery url

type ConfigFunc

type ConfigFunc func(*Config)

ConfigFunc registers the Config

func Addr

func Addr(a string) ConfigFunc

Addr service discovery addr

func ChecksCfg

func ChecksCfg(cc ...Check) ConfigFunc

ChecksCfg ..

func ServicesCfg

func ServicesCfg(ss ...Service) ConfigFunc

ServicesCfg ..

type DefaultCheckRegister

type DefaultCheckRegister struct{}

DefaultCheckRegister struct to implement CheckRegister default methods

func (*DefaultCheckRegister) Register

func (dr *DefaultCheckRegister) Register(addr, path string, c *Check) error

Register make PUT request on consul api

func (*DefaultCheckRegister) Unregister

func (dr *DefaultCheckRegister) Unregister(addr, path, checkID string) error

Unregister make PUT request on consul api

type DefaultChecker

type DefaultChecker struct{}

DefaultChecker struct to implement Checker default methods

func (*DefaultChecker) GetChecks

func (ds *DefaultChecker) GetChecks(addr, path string) (Checks, error)

GetChecks make GET request on consul api

type DefaultLeader

type DefaultLeader struct{}

DefaultLeader struct to append Status

func (*DefaultLeader) Status

func (dn *DefaultLeader) Status(addr, path string) (string, error)

Status make GET request on consul api

type DefaultNoder

type DefaultNoder struct{}

DefaultNoder struct to append GetNodes

func (*DefaultNoder) GetNodes

func (dn *DefaultNoder) GetNodes(addr, path string) (Nodes, error)

GetNodes make GET request on consul api

type DefaultServiceNoder

type DefaultServiceNoder struct{}

DefaultServiceNoder struct to append GetNodeServices

func (*DefaultServiceNoder) GetServiceNodes

func (dn *DefaultServiceNoder) GetServiceNodes(addr, path, serviceID string) (ServiceNodes, error)

GetServiceNodes make GET request on consul api

type DefaultServiceRegister

type DefaultServiceRegister struct{}

DefaultServiceRegister struct to implement Register default methods

func (*DefaultServiceRegister) Register

func (dr *DefaultServiceRegister) Register(addr, path string, s *Service) error

Register make PUT request on consul api

func (*DefaultServiceRegister) Unregister

func (dr *DefaultServiceRegister) Unregister(addr, path, serviceID string) error

Unregister make PUT request on consul api

type DefaultServicer

type DefaultServicer struct{}

DefaultServicer struct to implement Servicer default methods

func (*DefaultServicer) GetServices

func (ds *DefaultServicer) GetServices(addr, path string) (Services, error)

GetServices make GET request on consul api

type Discovery

type Discovery interface {
	IsAvailable() (bool, error)
	Service(string) ([]string, error)
	Register(...ConfigFunc) error
	Unregister() error
}

Discovery ...

func NewDiscovery

func NewDiscovery(cfgs ...ConfigFunc) Discovery

NewDiscovery ...

type Leader

type Leader interface {
	Status(addr, path string) (string, error)
}

Leader interface

type Node

type Node struct {
	Node            string            `json:"Node"`
	Address         string            `json:"Address"`
	TaggedAddresses map[string]string `json:"TaggedAddresses,omitempty"`
}

Node single consul node

type Noder

type Noder interface {
	GetNodes(addr, path string) (Nodes, error)
}

Noder interface

type Nodes

type Nodes []Node

Nodes slice of nodes

func GetNodes

func GetNodes(n Noder, addr string) (Nodes, error)

GetNodes function to get slice of nodes

type Service

type Service struct {
	ID      string   `json:"ID"`
	Service string   `json:"Service"`
	Name    string   `json:"Name"`
	Tags    []string `json:"Tags,omitempty"`
	Address string   `json:"Address,omitempty"`
	Port    int      `json:"Port"`
}

Service single consul service

type ServiceNode

type ServiceNode struct {
	Node           string   `json:"Node"`
	Address        string   `json:"Address"`
	ServiceID      string   `json:"ServiceID"`
	ServiceName    string   `json:"ServiceName"`
	ServiceTags    []string `json:"ServiceTags,omitempty"`
	ServiceAddress string   `json:"ServiceAddress"`
	ServicePort    int      `json:"ServicePort"`
}

ServiceNode single consul service-node

type ServiceNoder

type ServiceNoder interface {
	GetServiceNodes(addr, path string, serviceID string) (ServiceNodes, error)
}

ServiceNoder interface

type ServiceNodes

type ServiceNodes []ServiceNode

ServiceNodes slice of service-nodes

func GetServiceNodes

func GetServiceNodes(s ServiceNoder, addr, serviceID string) (ServiceNodes, error)

GetServiceNodes function to get slice of service-nodes

type ServiceRegister

type ServiceRegister interface {
	Register(addr, path string, s *Service) error
	Unregister(addr, path, serviceID string) error
}

ServiceRegister interface

type Servicer

type Servicer interface {
	GetServices(addr, path string) (Services, error)
}

Servicer interface

type Services

type Services map[string]Service

Services map of services

func GetServices

func GetServices(s Servicer, addr string) (Services, error)

GetServices function to get a map of services

Jump to

Keyboard shortcuts

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