filedb

package
v2.2.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultPlugin = *NewPlugin()

DefaultPlugin is a default instance of Plugin.

Functions

This section is empty.

Types

type BrokerWatcher

type BrokerWatcher struct {
	*Client
	// contains filtered or unexported fields
}

BrokerWatcher implements CoreBrokerWatcher and provides broker/watcher constructors with client

func (*BrokerWatcher) Delete

func (pdb *BrokerWatcher) Delete(key string, opts ...datasync.DelOption) (existed bool, err error)

Delete calls client's 'Delete' method

func (*BrokerWatcher) GetValue

func (pdb *BrokerWatcher) GetValue(key string) (data []byte, found bool, revision int64, err error)

GetValue calls client's 'GetValue' method

func (*BrokerWatcher) ListKeys

func (pdb *BrokerWatcher) ListKeys(prefix string) (keyval.BytesKeyIterator, error)

ListKeys returns a list of all database keys for given prefix

func (*BrokerWatcher) ListValues

func (pdb *BrokerWatcher) ListValues(key string) (keyval.BytesKeyValIterator, error)

ListValues returns a list of all database values for given key

func (*BrokerWatcher) NewTxn

func (pdb *BrokerWatcher) NewTxn() keyval.BytesTxn

NewTxn calls client's 'NewTxn' method

func (*BrokerWatcher) Put

func (pdb *BrokerWatcher) Put(key string, data []byte, opts ...datasync.PutOption) error

Put calls client's 'Put' method

func (*BrokerWatcher) Watch

func (pdb *BrokerWatcher) Watch(resp func(keyval.BytesWatchResp), closeChan chan string, keys ...string) error

Watch augments watcher's response and removes prefix from it

type Client

type Client struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Client arranges communication between file system and internal database, and is also responsible for upstream events.

func NewClient

func NewClient(cfgPaths []string, statusPath string, dcs []decoder.API, fsh filesystem.API, log logging.Logger) (*Client, error)

NewClient initializes file watcher, database and registers paths provided via plugin configuration file

func (*Client) Close

func (c *Client) Close() error

Close closes all readers

func (*Client) Delete

func (c *Client) Delete(key string, opts ...datasync.DelOption) (existed bool, err error)

Delete is not allowed for fileDB, configuration file is read-only

func (*Client) GetDataForFile

func (c *Client) GetDataForFile(path string) []*decoder.FileDataEntry

GetDataForFile returns data gor given file

func (*Client) GetDataForKey

func (c *Client) GetDataForKey(key string) (*decoder.FileDataEntry, bool)

GetDataForKey returns data gor given file

func (*Client) GetPaths

func (c *Client) GetPaths() []string

GetPaths returns client file paths

func (*Client) GetValue

func (c *Client) GetValue(key string) (data []byte, found bool, revision int64, err error)

GetValue returns a value for given key

func (*Client) ListKeys

func (c *Client) ListKeys(prefix string) (keyval.BytesKeyIterator, error)

ListKeys returns a set of keys for given prefix

func (*Client) ListValues

func (c *Client) ListValues(prefix string) (keyval.BytesKeyValIterator, error)

ListValues returns a list of values for given prefix

func (*Client) NewBroker

func (c *Client) NewBroker(prefix string) keyval.BytesBroker

NewBroker provides BytesBroker object with client and given prefix

func (*Client) NewTxn

func (c *Client) NewTxn() keyval.BytesTxn

NewTxn is not supported, filesystem plugin does not allow to do changes to the configuration

func (*Client) NewWatcher

func (c *Client) NewWatcher(prefix string) keyval.BytesWatcher

NewWatcher provides BytesWatcher object with client and given prefix

func (*Client) Put

func (c *Client) Put(key string, data []byte, opts ...datasync.PutOption) error

Put reads status file, add data to it and performs write

func (*Client) Watch

func (c *Client) Watch(resp func(response keyval.BytesWatchResp), closeChan chan string, keys ...string) error

Watch starts single watcher for every key prefix. Every watcher listens on its own data channel.

type Config

type Config struct {
	ConfigPaths []string `json:"configuration-paths"`
	StatusPath  string   `json:"status-path"`
}

Config is fileDB configuration file structure

type Deps

type Deps struct {
	infra.PluginDeps
}

Deps are fileDB plugin dependencies

type Option

type Option func(*Plugin)

Option is a function that can be used in NewPlugin to customize Plugin.

func UseDeps

func UseDeps(cb func(*Deps)) Option

UseDeps returns Option that can inject custom dependencies.

type Plugin

type Plugin struct {
	Deps
	// contains filtered or unexported fields
}

Plugin filesystem uses host os file system as database to store configuration.

func NewPlugin

func NewPlugin(opts ...Option) *Plugin

NewPlugin creates a new Plugin with the provided Options.

func (*Plugin) AfterInit

func (p *Plugin) AfterInit() error

AfterInit starts file system event watcher

func (*Plugin) Close

func (p *Plugin) Close() error

Close client

func (*Plugin) Disabled

func (p *Plugin) Disabled() bool

Disabled returns flag whether plugin is disabled

func (*Plugin) Init

func (p *Plugin) Init() error

Init reads file config and creates new client to communicate with file system

func (*Plugin) NewBroker

func (p *Plugin) NewBroker(keyPrefix string) keyval.ProtoBroker

NewBroker returns new broker created by proto wrapper

func (*Plugin) NewWatcher

func (p *Plugin) NewWatcher(keyPrefix string) keyval.ProtoWatcher

NewWatcher returns new watcher created by proto wrapper

func (*Plugin) OnConnect

func (p *Plugin) OnConnect(callback func() error)

OnConnect executes datasync callback

func (*Plugin) String

func (p *Plugin) String() string

String returns string-representation of plugin name

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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