store

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoltDBStore

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

BoltDBStore implements the Store interface using a persistent BoltDB instance

func NewBoltDBStore

func NewBoltDBStore(logger *zap.SugaredLogger, dataDir string) (*BoltDBStore, error)

NewBoltDBStore creates a BoltDBStore persisting its state in the given directory

func (*BoltDBStore) CleanUp

func (store *BoltDBStore) CleanUp()

CleanUp ensures any pending writes are flushed to disk It should be called before closing the program to ensure there is no dataloss

func (*BoltDBStore) InsertMapping

func (store *BoltDBStore) InsertMapping(dnsMapping *types.DNSMapping, insertCB func(*types.DNSMapping) error) error

InsertMapping registers that the ContainerID of the DNSMapping supports an A record In case the A record is not present in the current state, the callback will be executed which should create it at the DNSProvider TODO: maybe pass a dns.Provider, rather than a generic callback

func (*BoltDBStore) RemoveMapping

func (store *BoltDBStore) RemoveMapping(dnsMapping *types.DNSMapping, removeCB func(*types.DNSMapping) error) error

RemoveMapping removes the ContainerID from the list backing the A record In case this was the last ContainerID in the list, the callback will be executed to remove the A record from the DNSProvider

func (*BoltDBStore) ReplaceMappings

func (store *BoltDBStore) ReplaceMappings(mappings []*types.DNSMapping, provider dns.Provider) error

ReplaceMappings will replace the current list of DNSMappings with the supplied list It will interact with the dns.Provider to ensure the remote state is in sync It will perform a diff with the current state to minimize the amount of API calls to the dns.Provider

type MemoryStore

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

MemoryStore implements the Store interface using an ephemeral in memory database

func NewMemoryStore

func NewMemoryStore(logger *zap.SugaredLogger) (*MemoryStore, error)

NewMemoryStore returns a new instance of a MemoryStore

func (*MemoryStore) CleanUp

func (*MemoryStore) CleanUp()

CleanUp is a no-op for the MemoryStore

func (*MemoryStore) InsertMapping

func (store *MemoryStore) InsertMapping(mapping *types.DNSMapping, cb func(*types.DNSMapping) error) error

InsertMapping registers that the ContainerID of the DNSMapping supports an A record In case the A record is not present in the current state, the callback will be executed which should create it at the DNSProvider TODO: maybe pass a dns.Provider, rather than a generic callback

func (*MemoryStore) RemoveMapping

func (store *MemoryStore) RemoveMapping(mapping *types.DNSMapping, cb func(*types.DNSMapping) error) error

RemoveMapping removes the ContainerID from the list backing the A record In case this was the last ContainerID in the list, the callback will be executed to remove the A record from the DNSProvider

func (*MemoryStore) ReplaceMappings

func (store *MemoryStore) ReplaceMappings(mappings []*types.DNSMapping, provider dns.Provider) error

ReplaceMappings will replace the current list of DNSMappings with the supplied list It will interact with the dns.Provider to ensure the remote state is in sync It will perform a diff with the current state to minimize the amount of API calls to the dns.Provider

type Store

type Store interface {
	// CleanUp ensures any pending operations on the store are executed before closing down
	CleanUp()
	// InsertMapping registers that the ContainerID of the DNSMapping supports an A record
	// In case the A record is not present in the current state, the callback will be executed
	// which should create it at the DNSProvider
	// TODO: maybe pass a dns.Provider, rather than a generic callback
	InsertMapping(mapping *types.DNSMapping, cb func(*types.DNSMapping) error) error
	// RemoveMapping removes the ContainerID from the list backing the A record
	// In case this was the last ContainerID in the list, the callback will be executed
	// to remove the A record from the DNSProvider
	RemoveMapping(mapping *types.DNSMapping, cb func(*types.DNSMapping) error) error
	// ReplaceMappings will replace the current list of DNSMappings with the supplied list
	// It will interact with the dns.Provider to ensure the remote state is in sync
	// It will perform a diff with the current state to minimize the amount of API calls to the dns.Provider
	ReplaceMappings(mappings []*types.DNSMapping, provider dns.Provider) error
}

Store provides methods to interact with the desired state that will be provisioned on the dns.Provider

Jump to

Keyboard shortcuts

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