file

package
v0.0.0-...-d28c369 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(encoderType, path string) store.Repository

New returns a new JSON FileStore as a store.Repository

It takes in a path to a file which will be used for reads and writes, to back-up and sync the record store to disk.

This initialization function will try to open an existing file, or create it if it does not exist, and also read it if it has content. If any of the critical operations fail, the function will panic since the store will not be able to start.

TODO: decide if it's better to return a naked in-memory record store and log as critical

Types

type FileStore

type FileStore struct {
	Path string `json:"path,omitempty" yaml:"path,omitempty"`
	// contains filtered or unexported fields
}

FileStore is an in-memory implementation of a DNS record store wrapped with a syncer that will dump / retrieve DNS record data from a file in JSON format

The in-memory implementation used is store/memmap

func (*FileStore) Create

func (f *FileStore) Create(ctx context.Context, rs ...*store.Record) error

Create implements the store.Repository interface

It will call the in-memory store's method of the same signature, while deferring a `Sync()` call to ensure the records file is up-to-date

func (*FileStore) DeleteByAddress

func (f *FileStore) DeleteByAddress(ctx context.Context, addr string) error

DeleteByAddress removes all records with IP address `addr`

func (*FileStore) DeleteByDomain

func (f *FileStore) DeleteByDomain(ctx context.Context, name string) error

DeleteByDomain removes all records with domain name `name`

func (*FileStore) DeleteByTypeAndDomain

func (f *FileStore) DeleteByTypeAndDomain(ctx context.Context, rtype, name string) error

DeleteByTypeAndDomain removes all records with record type `rtype` and domain name `name`

func (*FileStore) FilterByDest

func (f *FileStore) FilterByDest(ctx context.Context, addr string) ([]*store.Record, error)

FilterByDest implements the store.Repository interface

It will call the in-memory store's method of the same signature

func (*FileStore) FilterByDomain

func (f *FileStore) FilterByDomain(ctx context.Context, domain string) ([]*store.Record, error)

FilterByDomain implements the store.Repository interface

It will call the in-memory store's method of the same signature

func (*FileStore) FindByTypeAndDomain

func (f *FileStore) FindByTypeAndDomain(ctx context.Context, rtype, domain string) (*store.Record, error)

FindByTypeAndDomain implements the store.Repository interface

It will call the in-memory store's method of the same signature

func (*FileStore) List

func (f *FileStore) List(ctx context.Context) ([]*store.Record, error)

List implements the store.Repository interface

It will call the in-memory store's method of the same signature

func (*FileStore) Update

func (f *FileStore) Update(ctx context.Context, domain string, r *store.Record) error

Update implements the store.Repository interface

It will call the in-memory store's method of the same signature, while deferring a `Sync()` call to ensure the records file is up-to-date

type Record

type Record struct {
	Address string   `json:"address,omitempty" yaml:"address,omitempty"`
	Domains []string `json:"domains,omitempty"   yaml:"domains,omitempty"`
}

Record is labeled by an IP address and contains a slice of (pointers to) Types

type Store

type Store struct {
	Types []*Type `json:"types,omitempty" yaml:"types,omitempty"`
}

Store holds a set of (DNS) Records

type Type

type Type struct {
	RType   string    `json:"type,omitempty"    yaml:"type,omitempty"`
	Records []*Record `json:"records,omitempty" yaml:"records,omitempty"`
}

Type is labeled by a DNS record type and contains a slice of Domains

Jump to

Keyboard shortcuts

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