Documentation ¶
Index ¶
- Constants
- Variables
- type BackingStore
- func (s *BackingStore) Close() error
- func (s *BackingStore) Connect() error
- func (s *BackingStore) Delete(itemType string, name string) error
- func (s *BackingStore) List(itemType string) ([]string, error)
- func (s *BackingStore) Read(itemType string, name string) ([]byte, error)
- func (s *BackingStore) ReadAll(itemType string) ([][]byte, error)
- func (s *BackingStore) Save(itemType string, name string, data []byte) error
- type HasClose
- type HasConnect
- type MockStore
- func (s *MockStore) Close() error
- func (s *MockStore) Connect() error
- func (s *MockStore) Delete(itemType string, name string) error
- func (s *MockStore) GetCloseCount() (int, error)
- func (s *MockStore) GetConnectCount() (int, error)
- func (s *MockStore) List(itemType string) ([]string, error)
- func (s *MockStore) Read(itemType string, name string) ([]byte, error)
- func (s *MockStore) Save(itemType string, name string, data []byte) error
- type Store
Constants ¶
const MongoCollectionPrefix = "cnab_"
MongoCollectionPrefix is applied to every collection.
Variables ¶
var ErrRecordDoesNotExist = errors.New("File does not exist")
ErrRecordDoesNotExist represents when file path is not found on file system
Functions ¶
This section is empty.
Types ¶
type BackingStore ¶
type BackingStore struct { AutoClose bool // contains filtered or unexported fields }
BackingStore wraps another store that may have Connect/Close methods that need to be called. - Connect is called before a method when the connection is closed. - Close is called after each method when AutoClose is true (default).
func NewBackingStore ¶
func NewBackingStore(store Store) *BackingStore
func (*BackingStore) Close ¶
func (s *BackingStore) Close() error
func (*BackingStore) Connect ¶
func (s *BackingStore) Connect() error
func (*BackingStore) Read ¶
func (s *BackingStore) Read(itemType string, name string) ([]byte, error)
type HasClose ¶
type HasClose interface {
Close() error
}
HasClose indicates that a struct must be cleaned up using the Close method before the interface's methods are called.
type HasConnect ¶
type HasConnect interface {
Connect() error
}
HasConnect indicates that a struct must be initialized using the Connect method before the interface's methods are called.
type MockStore ¶
type MockStore struct { // DeleteMock replaces the default Delete implementation with the specified function. // This allows for simulating failures. DeleteMock func(itemType string, name string) error // ListMock replaces the default List implementation with the specified function. // This allows for simulating failures. ListMock func(itemType string) ([]string, error) // ReadMock replaces the default Read implementation with the specified function. // This allows for simulating failures. ReadMock func(itemType string, name string) ([]byte, error) // SaveMock replaces the default Save implementation with the specified function. // This allows for simulating failures. SaveMock func(itemType string, name string, data []byte) error // contains filtered or unexported fields }
MockStore is an in-memory store with optional mocked functionality that is intended for use with unit testing.
func NewMockStore ¶
func NewMockStore() *MockStore
func (*MockStore) GetCloseCount ¶
GetCloseCount is for tests to safely read the Close call count without accidentally triggering it by using Read.
func (*MockStore) GetConnectCount ¶
GetConnectCount is for tests to safely read the Connect call count without accidentally triggering it by using Read.
type Store ¶
type Store interface { List(itemType string) ([]string, error) Save(itemType string, name string, data []byte) error Read(itemType string, name string) ([]byte, error) Delete(itemType string, name string) error }
Store is a simplified interface to a key-blob store supporting CRUD operations.
func NewFileSystemStore ¶
NewFileSystemStore creates a Store backed by a file system directory. Each key is represented by a file in that directory.
func NewMongoDBStore ¶
NewMongoDBStore creates a new storage engine that uses MongoDB
The URL provided must point to a MongoDB server and database.