archivingcache

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2019 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Overview

Package syncache is a CoreDNS plugin that caches lookups. If more than one request for the same resource is in flight, then they are queued to avoid redundant forwarding lookups

Index

Constants

View Source
const (
	// Success is the class for caching positive caching.
	Success = "success"
	// Denial is the class defined for negative caching.
	Denial = "denial"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ArchivingCache

type ArchivingCache struct {
	Next plugin.Handler

	UpstreamIP   string
	UpstreamPort string
	Connection   *Connection
	// contains filtered or unexported fields
}

Syncache is a cache plugin.

func NewArchivingCache

func NewArchivingCache(eviction time.Duration, maxSizeMb int, UpstreamIP string, UpstreamPort string, Connection *Connection) (*ArchivingCache, error)

NewArchivingCache returns a new instance of Syncache

func (*ArchivingCache) Close

func (a *ArchivingCache) Close()

Close is a synonym for OnShutdown().

func (*ArchivingCache) Name

func (a *ArchivingCache) Name() string

Name implements the Handler interface.

func (*ArchivingCache) OnShutdown

func (a *ArchivingCache) OnShutdown() error

OnShutdown stops all configured proxies.

func (*ArchivingCache) OnStartup

func (a *ArchivingCache) OnStartup() (err error)

OnStartup starts a goroutines for all proxies.

func (*ArchivingCache) ServeDNS

func (a *ArchivingCache) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error)

ServeDNS implements the plugin.Handler interface.

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache is a wrapper around *bigcache.BigCache which takes care of marshalling and unmarshalling of dns.Msg.

func NewCache

func NewCache(lifeWindow time.Duration, maxSizeMb int) (*Cache, error)

NewCache creates a new Cache

func (*Cache) Get

func (c *Cache) Get(key string) (*CacheEntry, error)

Get reads a DNS response from the cahce. It returns an EntryNotFoundError when no entry exists for the given key.

func (*Cache) Put

func (c *Cache) Put(key string, server string, cacheEntry *CacheEntry) error

Put writes a DNS response to the cache

type CacheEntry

type CacheEntry struct {
	// contains filtered or unexported fields
}

func (*CacheEntry) AddCollectionId

func (ce *CacheEntry) AddCollectionId(collectionId string) []string

func (*CacheEntry) HasCollectionId

func (ce *CacheEntry) HasCollectionId(collectionId string) bool

func (*CacheEntry) String

func (ce *CacheEntry) String() string

type Connection

type Connection struct {
	// contains filtered or unexported fields
}

Connection holds the connections for ContentWriter and Veidemann database

func NewConnection

func NewConnection(dbHost string, dbPort int, dbUser string, dbPassword string, dbName string, contentWriterHost string,
	contentWriterPort int) *Connection

NewConnection creates a new Connection object

type Recorder

type Recorder struct {
	Rcode int
	Err   error
	Msg   *dns.Msg

	FetchStart      time.Time
	FetchDurationMs int64
	RequestedHost   string
	UpstreamIP      string
	// contains filtered or unexported fields
}

Recorder is a type of ResponseWriter that captures the message written to it.

func NewRecorder

func NewRecorder(a *ArchivingCache, key string, server string, connection *Connection,
	requestedHost string, upstreamIP string, collectionRef *configV1.ConfigRef) *Recorder

NewRecorder makes and returns a new Recorder,

func (*Recorder) Close

func (rec *Recorder) Close() error

Close implement the dns.ResponseWriter interface from Go DNS.

func (*Recorder) Hijack

func (rec *Recorder) Hijack()

Hijack implement the dns.ResponseWriter interface from Go DNS.

func (*Recorder) LocalAddr

func (rec *Recorder) LocalAddr() net.Addr

LocalAddr implement the dns.ResponseWriter interface from Go DNS.

func (*Recorder) NextPlugin

func (rec *Recorder) NextPlugin(ctx context.Context, request *dns.Msg)

NextPlugin runs the next plugin and captures the result

func (*Recorder) RemoteAddr

func (rec *Recorder) RemoteAddr() net.Addr

RemoteAddr implement the dns.ResponseWriter interface from Go DNS.

func (*Recorder) SetMsg

func (rec *Recorder) SetMsg(res *dns.Msg) error

SetMsg records the messsage without adding it to the cache.

func (*Recorder) TsigStatus

func (rec *Recorder) TsigStatus() error

TsigStatus implement the dns.ResponseWriter interface from Go DNS.

func (*Recorder) TsigTimersOnly

func (rec *Recorder) TsigTimersOnly(b bool)

TsigTimersOnly implement the dns.ResponseWriter interface from Go DNS.

func (*Recorder) Write

func (rec *Recorder) Write(b []byte) (int, error)

Write is the hack that makes this work. It does not actually write the message but returns the bytes we need to to write in r. We can then pick this up in Query and write a proper protobuf back to the client. Write implements the dns.ResponseWriter interface.

func (*Recorder) WriteMsg

func (rec *Recorder) WriteMsg(res *dns.Msg) error

WriteMsg records the messsage. WriteMsg implements the dns.ResponseWriter interface.

func (*Recorder) WriteRecordedMessage

func (rec *Recorder) WriteRecordedMessage(rw dns.ResponseWriter, request *dns.Msg, shared bool) (int, error)

WriteRecordedMessage writes the message to the wrapped ResponseWriter

type Server

type Server struct {
	Header  *contentwriterV1.Data
	Payload *contentwriterV1.Data
	Meta    *contentwriterV1.WriteRequestMeta
	Cancel  string
	// contains filtered or unexported fields
}

Server is used to implement ContentWriterServer.

func NewCWServer

func NewCWServer(port int) *Server

NewCWServer creates a new ContentWriterServerMock

func (*Server) Close

func (s *Server) Close()

Close implements ContentWriterServer

func (*Server) Delete

func (s *Server) Delete(ctx context.Context, in *empty.Empty) (*empty.Empty, error)

Delete implements ContentWriterServer

func (*Server) Flush

func (s *Server) Flush(ctx context.Context, in *empty.Empty) (*empty.Empty, error)

Flush implements ContentWriterServer

func (*Server) Write

Write implements ContentWriterServer

Jump to

Keyboard shortcuts

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