Documentation ¶
Index ¶
- Constants
- type DirFileStore
- func (store *DirFileStore) AutoSaveLoop()
- func (store *DirFileStore) Close()
- func (store *DirFileStore) DeleteAll()
- func (store *DirFileStore) Get(thingID string) (interface{}, error)
- func (store *DirFileStore) List(offset int, limit int, aclFilter func(thingID string) bool) []interface{}
- func (store *DirFileStore) Open() error
- func (store *DirFileStore) Patch(id string, src map[string]interface{}) error
- func (store *DirFileStore) Query(jsonPath string, offset int, limit int, aclFilter func(thingID string) bool) ([]interface{}, error)
- func (store *DirFileStore) Remove(id string)
- func (store *DirFileStore) Replace(id string, document map[string]interface{}) error
- func (store *DirFileStore) Size() int
Constants ¶
const DefaultListLimit = 100
DefaultListLimit is the default max nr of items to return in list
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DirFileStore ¶
type DirFileStore struct {
// contains filtered or unexported fields
}
DirFileStore is a crude little file based Directory store Intended as a testing MVP for the directory service Implements the IDirStore interface
func NewDirFileStore ¶
func NewDirFileStore(jsonFilePath string) *DirFileStore
NewDirFileStore creates a new directory file store instance
filePath path to JSON store file
func (*DirFileStore) AutoSaveLoop ¶
func (store *DirFileStore) AutoSaveLoop()
AutoSaveLoop periodically saves changes to the directory
func (*DirFileStore) DeleteAll ¶
func (store *DirFileStore) DeleteAll()
DeleteAll empties the store. Intended for etsting.
func (*DirFileStore) Get ¶
func (store *DirFileStore) Get(thingID string) (interface{}, error)
Get a document by its ID
id of the thing to look up
Returns an error if it doesn't exist
func (*DirFileStore) List ¶
func (store *DirFileStore) List(offset int, limit int, aclFilter func(thingID string) bool) []interface{}
List returns a list of documents
offset is the offset in the document list that is sorted by document ID limit is the maximum nr of documents to return or 0 for the default aclFilter filters the things by ID. Use nil to ignore.
This returns an empty list if offset is equal or larger than the available nr of documents
func (*DirFileStore) Open ¶
func (store *DirFileStore) Open() error
Open the store Returns error if it can't be opened or already open
func (*DirFileStore) Patch ¶
func (store *DirFileStore) Patch(id string, src map[string]interface{}) error
Patch a document Returns an error if it doesn't exist
func (*DirFileStore) Query ¶
func (store *DirFileStore) Query(jsonPath string, offset int, limit int, aclFilter func(thingID string) bool) ([]interface{}, error)
Query for documents using JSONPATH Eg `$[? @.properties.deviceType=="sensor"]`
jsonPath contains the query offset contains the offset in the list of results, sorted by ID limit contains the maximum or of responses, 0 for the default 100
func (*DirFileStore) Remove ¶
func (store *DirFileStore) Remove(id string)
Remove a document from the store Also succeeds if the document doesn't exist
func (*DirFileStore) Replace ¶
func (store *DirFileStore) Replace(id string, document map[string]interface{}) error
Replace a document The document does not have to exist
func (*DirFileStore) Size ¶
func (store *DirFileStore) Size() int
Size returns the number of items in the store