resolvcache

package
v0.0.0-...-770dba1 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2020 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache implements a resolv cache in memory

func NewCache

func NewCache(expires time.Duration, limits Limits) *Cache

NewCache creates a new Cache

func (*Cache) Clean

func (o *Cache) Clean()

Clean expired items from cache

func (*Cache) Cleaned

func (o *Cache) Cleaned() time.Time

Cleaned returns time from last clean

func (*Cache) Dump

func (o *Cache) Dump(out io.Writer)

Dump cache content to writer

func (*Cache) Expires

func (o *Cache) Expires() time.Duration

Expires returns expiration time

func (*Cache) Flush

func (o *Cache) Flush()

Flush cache

func (*Cache) Flushed

func (o *Cache) Flushed() time.Time

Flushed returns time from last flush

func (*Cache) Get

func (o *Cache) Get(client, resolved net.IP, name string) (bool, time.Time)

Get data

func (*Cache) Set

func (o *Cache) Set(ts time.Time, client net.IP, name string, resolved []net.IP) error

Set data

func (*Cache) Store

func (o *Cache) Store() time.Time

Store returns store time

type CollectLogger

type CollectLogger interface {
	Write(*peer.Peer, time.Time, net.IP, string, []net.IP) error
}

CollectLogger interface defines collection logger interface

type Limits

type Limits struct {
	BlockSize       int
	MaxBlocksClient int
	MaxNamesNode    int
}

Limits stores max values for cache

func DefaultLimits

func DefaultLimits() Limits

DefaultLimits returns limits

type Option

type Option func(*options)

Option is used for component configuration

func DumpCache

func DumpCache(d time.Duration, fname string) Option

DumpCache sets interval and filename for dump

func SetCollectLogger

func SetCollectLogger(l CollectLogger) Option

SetCollectLogger sets a collection logger

func SetLogger

func SetLogger(l yalogi.Logger) Option

SetLogger option allows set a custom logger

type Service

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

Service implements a dnsutil.ResolvCache service

func NewService

func NewService(c *Cache, opt ...Option) *Service

NewService creates a new Service

func (*Service) Check

func (s *Service) Check(ctx context.Context, client, resolved net.IP, name string) (dnsutil.ResolvResponse, error)

Check implements dnsutil.ResolvChecker

func (*Service) Collect

func (s *Service) Collect(ctx context.Context, client net.IP, name string, resolved []net.IP) error

Collect implements dnsutil.ResolvCollector

func (*Service) Shutdown

func (s *Service) Shutdown()

Shutdown service cache

func (*Service) Start

func (s *Service) Start() error

Start service cache

func (*Service) Uptime

func (s *Service) Uptime(ctx context.Context) (time.Time, time.Duration, error)

Uptime returns cache information

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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