Documentation
¶
Overview ¶
Package filesystem implements a key/value store on top of a generic filesystem. This is the direct successor to the protodb and is compatible with its storage format. It is not compatible with some of the features of the protodb, most notably noticing changes to the filesystem outside of NetAuth. It was incredibly hard to make this work reliably in protodb, and if you look too closely you'll realize that it doesn't satisfy a lot of integrity constraints and probably could be used to corrupt data if you were really clever. Additionally, the filesystem key/value store does not use the .dat extension on data files as it is wholely unnecessary. This needs to be done during migration. The recommended way to migrate from one to another is to use a shell fragment that can talk to both.
Index ¶
- Variables
- type Filesystem
- func (fs *Filesystem) Capabilities() []db.KVCapability
- func (fs *Filesystem) Close() error
- func (fs *Filesystem) Del(_ context.Context, k string) error
- func (fs *Filesystem) Get(_ context.Context, k string) ([]byte, error)
- func (fs *Filesystem) Keys(_ context.Context, f string) ([]string, error)
- func (fs *Filesystem) Put(_ context.Context, k string, v []byte) error
- func (fs *Filesystem) SetEventFunc(ef func(db.Event))
Constants ¶
This section is empty.
Variables ¶
var ( // ErrPathEscape is returned if a key tries to climb up and // out of a directory. ErrPathEscape = errors.New("attempted path escape") )
Functions ¶
This section is empty.
Types ¶
type Filesystem ¶
type Filesystem struct {
// contains filtered or unexported fields
}
Filesystem anchors all the methods in the filesystem key/value store.
func (*Filesystem) Capabilities ¶
func (fs *Filesystem) Capabilities() []db.KVCapability
Capabilities returns the capabilities that this implementation is able to satisfy. Capabilities checks for a .writeable flag to tell it that the local copy is intentionally mutable. Calls to Put may succeed even if this flag is missing, but higher level constructs can use this to check of this instance is in read-only mode.
func (*Filesystem) Close ¶
func (fs *Filesystem) Close() error
Close is required by the interface, but all operations on the filesystem are atomic, so no close is required.
func (*Filesystem) Del ¶
func (fs *Filesystem) Del(_ context.Context, k string) error
Del removes a file from disk that is inside the base path.
func (*Filesystem) Get ¶
Get returns a series of bytes from the filesystem, checking to make sure that the bytes come from inside the base path.
func (*Filesystem) Keys ¶
Keys is a way to enumerate the keys in the key/value store and to optionally filter them based on a globbing expression. This cheats and uses superior knowledge that NetAuth uses only a single key namespace with a single layer of keys below it. Its technically possible to do something dumb with an entity or group name that includes a path seperator, but this should be filtered out at a higher level.
func (*Filesystem) Put ¶
Put stores a series of bytes on the filesystem, checking to make sure that the path is inside of the basePath
func (*Filesystem) SetEventFunc ¶
func (fs *Filesystem) SetEventFunc(ef func(db.Event))
SetEventFunc sets up a function to call to fire events to subscribers.