Documentation ¶
Index ¶
- Constants
- Variables
- type ARecordValue
- type Conn
- func (conn *Conn) Close() error
- func (conn *Conn) DeleteARecord(ctx context.Context, url string) error
- func (conn *Conn) GetEtcdKeyNameFromURL(url string) (string, error)
- func (conn *Conn) GetEtcdValue(ip string, ttl int64) (string, error)
- func (conn *Conn) PutARecord(ctx context.Context, url, ip string, ttl int64) error
- func (conn *Conn) PutARecordAndKeepAlive(ctx context.Context, url, ip string, ttl int64) error
- func (conn *Conn) Resolve(ctx context.Context, url string) ([]string, error)
- func (conn *Conn) ResolveWithTTL(ctx context.Context, url string) ([]map[string]int64, error)
Constants ¶
const ( DefaultMutexPrefix = "/mutex/coredns" DefaultTimeFormat = "2020-08-20 11:55:00.000000" InfiniteTTLTime = 0 MinimumTTLTime = 1 MaximumTTLTime = 10 )
Variables ¶
var ErrInvalidTTL = errors.New( fmt.Sprintf("TTL must be larger then %d and smaller than %d.", MinimumTTLTime, MaximumTTLTime))
var ErrLockFailed = errors.New(fmt.Sprintf("lock mutex failed, please try again later."))
Functions ¶
This section is empty.
Types ¶
type ARecordValue ¶
ARecordValue saves the unmarshalled json data which presents A record value
func NewARecordValue ¶
func NewARecordValue(value []byte) (*ARecordValue, error)
NewARecordValue return *ARecordValue, it uses core dns A record value which is a json string as the input
type Conn ¶
func NewCoreDNSConn ¶
NewCoreDNSConn returns a coredns connection, coredns must use etcd as the backend
func (*Conn) DeleteARecord ¶
DeleteARecord delete the A record by deleting the concerned key in the etcd, it will lock mutex before really doing this, if lock failed, it will return an error
func (*Conn) GetEtcdKeyNameFromURL ¶
GetEtcdKeyNameFromURL transfers url string to backward and add coredns path as the prefix
func (*Conn) GetEtcdValue ¶
GetEtcdValue checks if ttl if valid and returns a json string with input ip and ttl
func (*Conn) PutARecord ¶
PutARecord used to add or modify the A record of coredns, it will lock mutex before really putting key into etcd, if lock mutex failed, it will return an error
func (*Conn) PutARecordAndKeepAlive ¶
PutARecordAndKeepAlive works like PutARecord, used to add or modify the A record of coredns, it will lock mutex before really putting key into etcd, if lock mutex failed, it will return an error, it also keep alive the key in etcd,