service

package
v0.0.0-...-0c25fb7 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusUndefined = iota
	StatusPassing
	StatusWarning
	StatusCritical
)

Service statuses

Variables

This section is empty.

Functions

func WeightByTags

func WeightByTags(tags []string) int

WeightByTags by tags

Types

type CheckInfo

type CheckInfo struct {
	Interval string `json:"interval,omitempty"`
	Timeout  string `json:"timeout,omitempty"`
	HTTP     string `json:"http,omitempty"`
	TCP      string `json:"tcp,omitempty"`
}

CheckInfo of service state

type Discovery

type Discovery interface {
	// Register new service
	Register(options Options) error

	// Unregister servece by ID
	Unregister(id string) error

	// Lookup services by filter
	Lookup(filter *Filter) ([]*Service, error)
}

Discovery service

type Filter

type Filter struct {
	ID         string
	Status     int8
	Tags       []string
	Service    string
	Datacenter string
}

Filter for search service

type List

type List []*Service

List imprimentation of sort.Sorter interface

func (List) Len

func (a List) Len() int

func (List) Less

func (a List) Less(i, j int) bool

func (List) Sort

func (a List) Sort()

func (List) Swap

func (a List) Swap(i, j int)

type Options

type Options struct {
	ID      string    `json:"id"`
	Name    string    `json:"name"`
	Address string    `json:"address"`
	Tags    []string  `json:"tags,omitempty"`
	Check   CheckInfo `json:"check,omitempty"`
}

Options of service

func (*Options) AddTag

func (o *Options) AddTag(key, value string)

AddTag to options

func (*Options) Service

func (o *Options) Service() *Service

Service from options

type Service

type Service struct {
	ID         string
	Name       string
	Datacenter string
	Address    string
	Port       int
	Tags       []string
	Status     int8
	// contains filtered or unexported fields
}

Service info

func (*Service) Host

func (s *Service) Host() string

Host including port

func (*Service) SetWeight

func (s *Service) SetWeight(weight int)

SetWeight of service

func (*Service) Test

func (s *Service) Test(filter *Filter) bool

Test service in comparison with filter

func (*Service) Weight

func (s *Service) Weight() int

Weight of service

Jump to

Keyboard shortcuts

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