Documentation
¶
Overview ¶
Package discovery contains domain logic for service discovery.
Index ¶
- func ServersBySelector(selector labels.Selector) func(Server) bool
- func ServiceByEndpoint(e fmt.Stringer) func(Service) bool
- func ServiceByName(name string) func(Service) bool
- func ServiceBySelector(selector labels.Selector) func(Service) bool
- type ExportConfig
- type Labels
- type Namespace
- type Namespaces
- type Server
- type ServerState
- type Servers
- type Service
- type Services
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ServersBySelector ¶
ServersBySelector filters Servers by Selector.
func ServiceByEndpoint ¶
ServiceByEndpoint filters Services by Endpoint.
func ServiceByName ¶
ServiceByName filters Services by Name.
Types ¶
type ExportConfig ¶
type ExportConfig int
ExportConfig defines how services in a namespaces are exported for file-based discovery.
const ( Disabled ExportConfig = iota // disabled Standard // standard Blackbox // blackbox )
All possible export configurations:
Standard: standard configuration Blackbox: for blackbox configurations Disabled: no export
func (ExportConfig) String ¶
func (i ExportConfig) String() string
type Namespace ¶
type Namespace struct { Name string `json:"name"` Export ExportConfig `json:"export"` Modified time.Time `json:"modified,omitempty"` }
Namespace represents a namespace.
func DefaultNamespace ¶
func DefaultNamespace() *Namespace
DefaultNamespace is used when no namespace is given.
type Namespaces ¶
type Namespaces []Namespace
Namespaces is a list of namespaces.
func (Namespaces) Index ¶
func (n Namespaces) Index(name string) int
Index returns the index of a namespace with name. If not found -1 is returned.
func (Namespaces) Names ¶
func (n Namespaces) Names() []string
Names returns the server names as slice of strings.
func (Namespaces) SortByDate ¶
func (n Namespaces) SortByDate()
SortByDate sorts servers by registerdate.
type Server ¶
type Server struct { Name string `json:"name"` Labels Labels `json:"labels"` State ServerState `json:"state"` Modified time.Time `json:"modified,omitempty"` }
Server represents a registered server.
With kubernetes selectors it is possible to select a server by labels. If IsActive is false, no services are distributed to this server.
type ServerState ¶
type ServerState int
ServerState describes the server state.
const ( Leaving ServerState = iota // leaving Joining // joining Active // active )
All possible export states:
Leaving: server was unregistered and is leaving Joining: server was registered and is ready for services Active: server already has services configured
func (ServerState) String ¶
func (i ServerState) String() string
type Servers ¶
type Servers []Server
Servers is a list of servers.
type Service ¶
type Service struct { ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` Namespace string `json:"namespace,omitempty"` Endpoint *url.URL `json:"endpoint,omitempty"` Selector string `json:"selector,omitempty"` Servers []string `json:"servers,omitempty"` Labels Labels `json:"labels,omitempty"` Description string `json:"description,omitempty"` Modified time.Time `json:"modified,omitempty"` }
Service contains all information for service discovery.
func MustNewService ¶
MustNewService panics if endpoint or name is not valid.
func NewService ¶
NewService creates a new service with ID and timestamp.
func (Service) KeyVals ¶
func (s Service) KeyVals() []interface{}
KeyVals represents the service as slice of interface.
func (Service) MarshalJSON ¶
MarshalJSON is a custom JSON marshaler.
func (*Service) UnmarshalJSON ¶
UnmarshalJSON is a custom json unmarshaller.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
internal
|
|
auth
Package auth handles openid connect and jwt (for access tokens) authentication and authorization.
|
Package auth handles openid connect and jwt (for access tokens) authentication and authorization. |
cmd/client
Package client represents the discovery client command.
|
Package client represents the discovery client command. |
cmd/server
Package server represents the discovery server command.
|
Package server represents the discovery server command. |
exporter
Package exporter exports services to filesystem for prometheus file discovery.
|
Package exporter exports services to filesystem for prometheus file discovery. |
hash
Package hash implements a consistent hasher described as described in http://arxiv.org/pdf/1406.2294v1.pdf
|
Package hash implements a consistent hasher described as described in http://arxiv.org/pdf/1406.2294v1.pdf |
registry
Package registry is responsible for registering and unregistering services and servers.
|
Package registry is responsible for registering and unregistering services and servers. |
repo
Package repo is responsilbe to store services and servers in a (etcd) repository.
|
Package repo is responsilbe to store services and servers in a (etcd) repository. |
server
Package server is responsible for starting the grpc and http server.
|
Package server is responsible for starting the grpc and http server. |
server/convert
Package convert converts proto types to domain types and vice versa.
|
Package convert converts proto types to domain types and vice versa. |
pkg
|
|
discoverypb
Package discoveryv1 is a reverse proxy.
|
Package discoveryv1 is a reverse proxy. |