archivingcache

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Overview

Package archivecache is a CoreDNS plugin that caches lookups and writes. 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

View Source
var (
	CacheSize = promauto.NewGaugeVec(prometheus.GaugeOpts{
		Namespace: plugin.Namespace,
		Subsystem: "cache",
		Name:      "size",
		Help:      "The number of elements in the cache.",
	}, []string{"server", "type"})

	CacheHits = promauto.NewCounterVec(prometheus.CounterOpts{
		Namespace: plugin.Namespace,
		Subsystem: "cache",
		Name:      "hits_total",
		Help:      "The count of cache hits.",
	}, []string{"server", "type"})

	CacheMisses = promauto.NewCounterVec(prometheus.CounterOpts{
		Namespace: plugin.Namespace,
		Subsystem: "cache",
		Name:      "misses_total",
		Help:      "The count of cache misses.",
	}, []string{"server"})
)

Functions

This section is empty.

Types

type ArchivingCache

type ArchivingCache struct {
	Next plugin.Handler

	singleflight.Group
	// contains filtered or unexported fields
}

ArchivingCache is a CoreDNS plugin.

func NewArchivingCache

func NewArchivingCache(cache *Cache, lw *LogWriterClient, cw *ContentWriterClient) *ArchivingCache

NewArchivingCache returns a new instance of ArchivingCache

func (*ArchivingCache) Name

func (a *ArchivingCache) Name() string

Name implements the Handler interface.

func (*ArchivingCache) OnShutdown

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

OnShutdown closes connections to content writer and log writer.

func (*ArchivingCache) OnStartup

func (a *ArchivingCache) OnStartup() error

OnStartup connects to content writer and log writer.

func (*ArchivingCache) Ready added in v0.2.8

func (a *ArchivingCache) Ready() bool

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 cache. It returns an EntryNotFoundError when no entry exists for the given key.

func (*Cache) Len added in v0.2.8

func (c *Cache) Len() int

func (*Cache) Reset added in v0.3.1

func (c *Cache) Reset() error

func (*Cache) Set added in v0.2.8

func (c *Cache) Set(key string, entry *CacheEntry) error

Set writes a DNS response to the cache

type CacheEntry

type CacheEntry struct {
	ProxyAddr     string
	CollectionIds []string
	Msg           *dns.Msg
}

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 ContentWriterClient added in v0.2.8

type ContentWriterClient struct {
	*serviceconnections.Connection
	contentwriterV1.ContentWriterClient
}

ContentWriterClient holds the connections for ContentWriterClient and Veidemann database

func NewContentWriterClient added in v0.2.8

func NewContentWriterClient(opts ...serviceconnections.ConnectionOption) *ContentWriterClient

NewContentWriterClient creates a new ContentWriterClient object

func (*ContentWriterClient) Connect added in v0.3.1

func (c *ContentWriterClient) Connect() error

Connect establishes connections

func (*ContentWriterClient) WriteRecord added in v0.3.1

func (c *ContentWriterClient) WriteRecord(payload []byte, fetchStart time.Time, requestedHost string, ipAddress string, executionId string, collectionId string) (*contentwriterV1.WriteReply, error)

WriteRecord writes a WARC record.

type LogWriterClient added in v0.3.1

type LogWriterClient struct {
	*serviceconnections.Connection
	*logservice.LogWriter
}

func NewLogWriterClient added in v0.3.1

func NewLogWriterClient(opts ...serviceconnections.ConnectionOption) *LogWriterClient

func (*LogWriterClient) Connect added in v0.3.1

func (l *LogWriterClient) Connect() error

func (*LogWriterClient) WriteCrawlLog added in v0.3.1

func (l *LogWriterClient) WriteCrawlLog(record *contentwriterV1.WriteResponseMeta_RecordMeta, size int, requestedHost string, fetchStart time.Time, fetchDurationMs int64, ipAddress string, executionId string) error

WriteCrawlLog stores a crawl log of a dns request/response.

type Recorder

type Recorder struct {
	dns.ResponseWriter
	Rcode int
	Msg   *dns.Msg
}

func NewRecorder

func NewRecorder(w dns.ResponseWriter) *Recorder

NewRecorder makes and returns a new Recorder.

func (*Recorder) WriteMsg

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

WriteMsg records the message and the response code, but doesn't write anything to the client.

Jump to

Keyboard shortcuts

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