Documentation ¶
Index ¶
- func New(encoderType, path string) store.Repository
- type FileStore
- func (f *FileStore) Create(ctx context.Context, rs ...*store.Record) error
- func (f *FileStore) DeleteByAddress(ctx context.Context, addr string) error
- func (f *FileStore) DeleteByDomain(ctx context.Context, name string) error
- func (f *FileStore) DeleteByTypeAndDomain(ctx context.Context, rtype, name string) error
- func (f *FileStore) FilterByDest(ctx context.Context, addr string) ([]*store.Record, error)
- func (f *FileStore) FilterByDomain(ctx context.Context, domain string) ([]*store.Record, error)
- func (f *FileStore) FindByTypeAndDomain(ctx context.Context, rtype, domain string) (*store.Record, error)
- func (f *FileStore) List(ctx context.Context) ([]*store.Record, error)
- func (f *FileStore) Update(ctx context.Context, domain string, r *store.Record) error
- type Record
- type Store
- type Type
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 ¶
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 ¶
DeleteByAddress removes all records with IP address `addr`
func (*FileStore) DeleteByDomain ¶
DeleteByDomain removes all records with domain name `name`
func (*FileStore) DeleteByTypeAndDomain ¶
DeleteByTypeAndDomain removes all records with record type `rtype` and domain name `name`
func (*FileStore) FilterByDest ¶
FilterByDest implements the store.Repository interface
It will call the in-memory store's method of the same signature
func (*FileStore) FilterByDomain ¶
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
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