consyn

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package consyn implements E2's config handler and file store

Index

Constants

This section is empty.

Variables

View Source
var (
	DirPerms  = 0755
	FilePerms = 0644
)
View Source
var (
	ErrObjectAlreadyExists = errors.New("object already exists at given path")
	ErrObjectDoesNotExist  = errors.New("object with given path does not exist")
	ErrInvalidObjectType   = errors.New("object type is invalid")
	ErrObjectDeleted       = errors.New("object has been marked for deletion")
	ErrInvalidPath         = errors.New("object path is not valid")
)

Functions

This section is empty.

Types

type Object

type Object struct {
	Type ObjectType
	// contains filtered or unexported fields
}

func (*Object) AllowsType

func (object *Object) AllowsType(objectType ObjectType) bool

AllowsType returns true if object allows values with the given ObjectType to be stored.

func (*Object) Bool

func (object *Object) Bool() (bool, error)

Bool returns the object content as a bool.

func (*Object) Created

func (object *Object) Created() bool

Created returns true if object has recently been created, but has not yet been synced.

func (*Object) Delete

func (object *Object) Delete()

Delete marks an object for deletion on next sync and makes the contents inaccessible.

func (*Object) Deleted

func (object *Object) Deleted() bool

Deleted returns true if object has been marked for deletion on next sync.

func (*Object) Float

func (object *Object) Float() (float64, error)

Float returns the object content as a float64.

func (*Object) Int

func (object *Object) Int() (int, error)

Int returns the object content as an int.

func (*Object) Modified

func (object *Object) Modified() bool

Modified returns true if object has recently been modified, but has not yet been synced.

func (*Object) Raw

func (object *Object) Raw() ([]byte, error)

Raw returns the raw content of the object.

func (*Object) SetBool

func (object *Object) SetBool(b bool) error

SetBool sets the content of the object to the given bool.

func (*Object) SetFloat

func (object *Object) SetFloat(f float64) error

SetFloat sets the content of object to the given float64.

func (*Object) SetInt

func (object *Object) SetInt(i int) error

SetInt sets the content of the object to the given int.

func (*Object) SetRaw

func (object *Object) SetRaw(raw []byte) error

SetRaw sets the raw content of the object.

func (*Object) SetString

func (object *Object) SetString(s string) error

SetString sets the content of the object to the given string.

func (*Object) String

func (object *Object) String() (string, error)

Bool returns the object content as a string.

type ObjectType

type ObjectType uint
const (
	ObjectTypeString ObjectType = 1 << iota
	ObjectTypeBool
	ObjectTypeInt
	ObjectTypeFloat

	ObjectTypeAny = ^ObjectType(0)
)

type Store

type Store struct {
	IgnoreFSChanges bool
	// contains filtered or unexported fields
}

func NewStore

func NewStore(path string) (store *Store, err error)

NewStore creates a new consyn Store at the given path.

func NewTempStore

func NewTempStore(name string) (*Store, error)

NewTempStore created a new consyn Store in a temporary directory, with the given name as a prefix.

func (*Store) DeleteAndSync

func (store *Store) DeleteAndSync() error

DeleteAndSync deletes all the objects in the store and runs (*Store).Sync().

func (*Store) NewObject

func (store *Store) NewObject(path string, objectType ObjectType) (*Object, error)

NewObject creates a new Object in the current Store.

func (*Store) Object

func (store *Store) Object(path string) (*Object, error)

func (*Store) ReadZip

func (store *Store) ReadZip(zipPath string) error

func (*Store) Sync

func (store *Store) Sync() (err error)

Sync the changes of the current Store with the disk.

func (*Store) SyncObject

func (store *Store) SyncObject(path string) error

SyncObject syncs the Object at the specified path with the disk.

func (*Store) WriteZip

func (store *Store) WriteZip(zipPath string) error

Jump to

Keyboard shortcuts

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