coredns

package
v0.3.19 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMutexPrefix = "/mutex/coredns"
	DefaultTimeFormat  = "2020-08-20 11:55:00.000000"
	InfiniteTTLTime    = 0
	MinimumTTLTime     = 1
	MaximumTTLTime     = 10
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ARecordValue

type ARecordValue struct {
	Host string `json:"host"`
	TTL  int64  `json:"ttl"`
}

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

type Conn struct {
	Endpoints []string
	Path      string
	EtcdConn  *etcd.Conn
}

func NewCoreDNSConn

func NewCoreDNSConn(endpoints []string, path string) (*Conn, error)

NewCoreDNSConn returns a coredns connection, coredns must use etcd as the backend

func (*Conn) Close

func (conn *Conn) Close() error

Close closes the connection with etcd

func (*Conn) DeleteARecord

func (conn *Conn) DeleteARecord(ctx context.Context, url string) error

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

func (conn *Conn) GetEtcdKeyNameFromURL(url string) (string, error)

GetEtcdKeyNameFromURL transfers url string to backward and add coredns path as the prefix

func (*Conn) GetEtcdValue

func (conn *Conn) GetEtcdValue(ip string, ttl int64) (string, error)

GetEtcdValue checks if ttl if valid and returns a json string with input ip and ttl

func (*Conn) PutARecord

func (conn *Conn) PutARecord(ctx context.Context, url, ip string, ttl int64) error

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

func (conn *Conn) PutARecordAndKeepAlive(ctx context.Context, url, ip string, ttl int64) error

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 keeps alive the key in etcd,

func (*Conn) Resolve

func (conn *Conn) Resolve(ctx context.Context, url string) ([]string, error)

Resolve returns host ip slice which is resolved as the given url

func (*Conn) ResolveWithTTL

func (conn *Conn) ResolveWithTTL(ctx context.Context, url string) ([]map[string]int64, error)

ResolveWithTTL works like Resolve, but it returns both host ip and ttl, the host ip is the key and ttl is the value in the map

Jump to

Keyboard shortcuts

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