Documentation
¶
Overview ¶
Package discovery contains domain logic for service discovery.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 FilterFunc ¶ added in v0.5.0
FilterFunc is a function to filter services. If function returns true service is selected else omitted.
func ServiceByEndpoint ¶
func ServiceByEndpoint(r *regexp.Regexp) FilterFunc
ServiceByEndpoint filters Services by Endpoint.
func ServiceByName ¶
func ServiceByName(r *regexp.Regexp) FilterFunc
ServiceByName filters Services by Name.
func ServiceBySelector ¶
func ServiceBySelector(selector labels.Selector) FilterFunc
ServiceBySelector filters Services by Selector.
func ServiceByServer ¶ added in v0.5.0
func ServiceByServer(r *regexp.Regexp) FilterFunc
ServiceByServer filters Services by Server.
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.
func (Servers) SortByDate ¶
func (s Servers) SortByDate()
SortByDate sorts servers by modification date.
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.
type Services ¶
type Services []Service
Services is a slice of Services
func (Services) Filter ¶
func (s Services) Filter(filters ...FilterFunc) Services
Filter filters Services with FilterFunc.
func (Services) SortByDate ¶ added in v0.5.0
func (s Services) SortByDate()
SortByDate sorts servers by modification date.
func (Services) SortByEndpoint ¶ added in v0.5.0
func (s Services) SortByEndpoint()
SortByEndpoint sorts services by endpoint.
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/postfinance/discovery/v1
Package discoveryv1 is a reverse proxy.
|
Package discoveryv1 is a reverse proxy. |