filestore

package module
v0.0.0-...-1c28ed9 Latest Latest
Warning

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

Go to latest
Published: May 18, 2023 License: MIT Imports: 12 Imported by: 2

README

REST Layer File backend

A fork of rs/rest-layer-mem that uses a file storage.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileStoreHandler

type FileStoreHandler struct {
	sync.RWMutex
	// If latency is set, the handler will introduce an artificial latency on
	// all operations
	Latency time.Duration

	UniqueFields []string
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(directory string, collection string, uniqueFields []string) *FileStoreHandler

NewHandler creates an empty memory handler

func NewSlowHandler

func NewSlowHandler(latency time.Duration) *FileStoreHandler

NewSlowHandler creates an empty memory handler with specified latency

func (*FileStoreHandler) Clear

func (self *FileStoreHandler) Clear(ctx context.Context, lookup *resource.Lookup) (total int, err error)

Clear clears all items from the memory store matching the lookup

func (*FileStoreHandler) Delete

func (self *FileStoreHandler) Delete(ctx context.Context, item *resource.Item) (err error)

Delete deletes an item from memory

func (*FileStoreHandler) Find

func (self *FileStoreHandler) Find(ctx context.Context, lookup *resource.Lookup, page, perPage int) (list *resource.ItemList, err error)

Find items from memory matching the provided lookup

func (*FileStoreHandler) Insert

func (self *FileStoreHandler) Insert(ctx context.Context, items []*resource.Item) (err error)

Insert inserts new items in memory

func (*FileStoreHandler) Update

func (self *FileStoreHandler) Update(ctx context.Context, item *resource.Item, original *resource.Item) (err error)

Update replace an item by a new one in memory

Jump to

Keyboard shortcuts

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