service

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrReadService        = errors.New("because can't read service file")
	ErrRRtypeEmpty        = errors.New("because RRType is empty")
	ErrRRTypeNotSupported = errors.New("because RRType is not supported")
	ErrServiceEmpty       = errors.New("because service is empty")
)
View Source
var (
	ErrEndpointValueEmpty       = errors.New("Value is empty")
	ErrEndpointValueNotString   = errors.New("Value is not string")
	ErrEndpointValueFormatError = errors.New("Value format error")
)
View Source
var (
	ErrNextEmpty            = errors.New("Rule is empty")
	ErrLocatiosEmpty        = errors.New("Location is empty")
	ErrLocatiosCantUse      = errors.New("Location is can't use")
	ErrLocationsEmpty       = errors.New("Locations is empty")
	ErrGeoip2DBFileEmpty    = errors.New("Geoip2DBFile is empty")
	ErrGeoip2DBCantOpen     = errors.New("geodb can't open")
	ErrDefaultLocationEmpty = errors.New("DEFAULT location is not found")
)
View Source
var (
	ErrConfigParseError   = errors.New("Failed to parse service config.")
	ErrServiceNotFound    = errors.New("Service not found")
	ErrServiceExist       = errors.New("Service is already exist. ")
	ErrServiceStatusError = errors.New("Monitoring status is failed")
)
View Source
var (
	ErrSamePriority = errors.New("Can't set same priority.")
)
View Source
var (
	ErrZeroWeight = errors.New("Weight value is zero or empty")
)
View Source
var ServicePlugin = map[string]func(*Config, string, *viper.Viper) (Service, error){}

Functions

func AddServicePlugin

func AddServicePlugin(name string, newFunc func(config *Config, path string, v *viper.Viper) (Service, error)) error

Types

type City

type City struct {
	GeoNameID uint              `maxminddb:"geoname_id"`
	Names     map[string]string `maxminddb:"names"`
}

type Config

type Config struct {
	Name     string
	RRType   uint16
	Service  Service
	Monitors map[*Endpoint]string
	ModTime  time.Time
}

func LoadConfig

func LoadConfig(path string) (*Config, error)

func NewConfig

func NewConfig() *Config

func (*Config) Delete

func (c *Config) Delete()

func (*Config) Update

func (c *Config) Update(current *Config) error

type Continent

type Continent struct {
	Code      string            `maxminddb:"code"`
	GeoNameID uint              `maxminddb:"geoname_id"`
	Names     map[string]string `maxminddb:"names"`
}

type Country

type Country struct {
	GeoNameID uint              `maxminddb:"geoname_id"`
	IsoCode   string            `maxminddb:"iso_code"`
	Names     map[string]string `maxminddb:"names"`
}

type Endpoint

type Endpoint struct {
	Value  string
	RRType uint16
	RR     dns.RR

	StatusCh chan bool
	// contains filtered or unexported fields
}

func (*Endpoint) GetRR

func (e *Endpoint) GetRR(w dns.ResponseWriter, req *dns.Msg) ([]dns.RR, error)

func (*Endpoint) Path

func (e *Endpoint) Path() string

func (*Endpoint) StartStatusWatch

func (e *Endpoint) StartStatusWatch(ctx context.Context)

func (*Endpoint) UpdateStatus

func (e *Endpoint) UpdateStatus()

func (*Endpoint) Verify

func (e *Endpoint) Verify(syntaxError *config.SyntaxError)

type Failover

type Failover struct {
	Values []*FailoverValue
	Weight uint32
	// contains filtered or unexported fields
}

func (*Failover) CreateChild

func (f *Failover) CreateChild(config *Config, path string, v *viper.Viper) (*FailoverValue, error)

func (*Failover) GetRR

func (f *Failover) GetRR(w dns.ResponseWriter, req *dns.Msg) (rrs []dns.RR, err error)

func (*Failover) Path

func (f *Failover) Path() string

type FailoverValue

type FailoverValue struct {
	Priority uint8
	Next     Service
	// contains filtered or unexported fields
}

type Geolocation

type Geolocation struct {
	IPv4GeoDB *maxminddb.Reader
	IPv6GeoDB *maxminddb.Reader
	Locations map[string]Service
	// contains filtered or unexported fields
}

func (*Geolocation) GetRR

func (g *Geolocation) GetRR(w dns.ResponseWriter, req *dns.Msg) ([]dns.RR, error)

func (*Geolocation) Path

func (g *Geolocation) Path() string

type Multivalue

type Multivalue struct {
	Values map[string]Service
	// contains filtered or unexported fields
}

func (*Multivalue) GetRR

func (m *Multivalue) GetRR(w dns.ResponseWriter, req *dns.Msg) ([]dns.RR, error)

func (*Multivalue) Path

func (m *Multivalue) Path() string

type Records

type Records struct {
	City         City          `maxminddb:"city"`
	Continent    Continent     `maxminddb:"continent"`
	Country      Country       `maxminddb:"country"`
	Subdivisions []Subdivision `maxminddb:"subdivisions"`
}

type Service

type Service interface {
	GetRR(dns.ResponseWriter, *dns.Msg) ([]dns.RR, error)
	Path() string
}

func CreateService

func CreateService(config *Config, path string, v *viper.Viper) (Service, error)

func NewEndpoint

func NewEndpoint(config *Config, path string, v *viper.Viper) (Service, error)

func NewFailover

func NewFailover(config *Config, path string, v *viper.Viper) (Service, error)

func NewGeolocation

func NewGeolocation(config *Config, path string, v *viper.Viper) (Service, error)

func NewMultivalue

func NewMultivalue(config *Config, path string, v *viper.Viper) (Service, error)

func NewWeight

func NewWeight(config *Config, path string, v *viper.Viper) (Service, error)

type ServiceGenerator

type ServiceGenerator struct {
	ServiceType int
	NewFunc     func() Service
}

type Subdivision

type Subdivision struct {
	GeoNameID uint              `maxminddb:"geoname_id"`
	IsoCode   string            `maxminddb:"iso_code"`
	Names     map[string]string `maxminddb:"names"`
}

type Weight

type Weight struct {
	Values map[string]*WeightValue
	// contains filtered or unexported fields
}

func (*Weight) CreateChild

func (we *Weight) CreateChild(config *Config, path string, v *viper.Viper) (*WeightValue, error)

func (*Weight) GetRR

func (we *Weight) GetRR(w dns.ResponseWriter, req *dns.Msg) ([]dns.RR, error)

func (*Weight) Path

func (we *Weight) Path() string

type WeightValue

type WeightValue struct {
	Weight uint8
	Next   Service
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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