store

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2021 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Overview

Package store is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashContents added in v0.16.0

func HashContents(contents []byte) model.Hash

Types

type DocumentStore

type DocumentStore interface {
	// Get retrieves a document from the store given its hash. If it doesn't exist, nil is returned (no error).
	Get(hash model.Hash) (*model.DocumentDescriptor, error)
	// GetByConsistencyHash retrieves a document from the store given its consistency hash. If it doesn't exist, nil is returned (no error).
	GetByConsistencyHash(hash model.Hash) (*model.DocumentDescriptor, error)
	// FindByContentsHash searches for documents which contents match the given SHA-1 hash.
	FindByContentsHash(hash model.Hash) ([]model.DocumentDescriptor, error)
	// Add adds a document, returning the last consistency hash.
	Add(document model.Document) (model.Hash, error)
	// GetAll retrieves all documents.
	GetAll() ([]model.DocumentDescriptor, error)
	// WriteContents writes contents for the specified document, identified by the given hash.
	// If the document does not exist, an error is returned. If the document already has contents, it is overwritten.
	WriteContents(hash model.Hash, contents io.Reader) error
	// ReadContents reads the contents for the specified document, identified by the given hash. If the document doesn't exist, an error is returned.
	// If the document has no contents, nil is returned.
	ReadContents(hash model.Hash) (io.ReadCloser, error)
	// LastConsistencyHash retrieves the last consistency hash from the store (the consistency hash of the last document in the chain). If there are no documents in the store, an empty hash is returned.
	LastConsistencyHash() model.Hash
	// ContentsSize retrieves size of all stored contents in bytes.
	ContentsSize() int
	// Size retrieves the number of documents in the store.
	Size() int
}

DocumentStore is used to store and retrieve chained documents.

func CreateDocumentStore

func CreateDocumentStore(connectionString string) (DocumentStore, error)

CreateDocumentStore creates a new DocumentStore given the connection string. The conenction string should be understood by the underlying implementation (currently sqlite3).

type MockDocumentStore

type MockDocumentStore struct {
	// contains filtered or unexported fields
}

MockDocumentStore is a mock of DocumentStore interface

func NewMockDocumentStore

func NewMockDocumentStore(ctrl *gomock.Controller) *MockDocumentStore

NewMockDocumentStore creates a new mock instance

func (*MockDocumentStore) Add

func (m *MockDocumentStore) Add(document model.Document) (model.Hash, error)

Add mocks base method

func (*MockDocumentStore) ContentsSize

func (m *MockDocumentStore) ContentsSize() int

ContentsSize mocks base method

func (*MockDocumentStore) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockDocumentStore) FindByContentsHash added in v0.16.0

func (m *MockDocumentStore) FindByContentsHash(hash model.Hash) ([]model.DocumentDescriptor, error)

FindByContentsHash mocks base method

func (*MockDocumentStore) Get

Get mocks base method

func (*MockDocumentStore) GetAll

GetAll mocks base method

func (*MockDocumentStore) GetByConsistencyHash

func (m *MockDocumentStore) GetByConsistencyHash(hash model.Hash) (*model.DocumentDescriptor, error)

GetByConsistencyHash mocks base method

func (*MockDocumentStore) LastConsistencyHash

func (m *MockDocumentStore) LastConsistencyHash() model.Hash

LastConsistencyHash mocks base method

func (*MockDocumentStore) ReadContents

func (m *MockDocumentStore) ReadContents(hash model.Hash) (io.ReadCloser, error)

ReadContents mocks base method

func (*MockDocumentStore) Size

func (m *MockDocumentStore) Size() int

Size mocks base method

func (*MockDocumentStore) WriteContents

func (m *MockDocumentStore) WriteContents(hash model.Hash, contents io.Reader) error

WriteContents mocks base method

type MockDocumentStoreMockRecorder

type MockDocumentStoreMockRecorder struct {
	// contains filtered or unexported fields
}

MockDocumentStoreMockRecorder is the mock recorder for MockDocumentStore

func (*MockDocumentStoreMockRecorder) Add

func (mr *MockDocumentStoreMockRecorder) Add(document interface{}) *gomock.Call

Add indicates an expected call of Add

func (*MockDocumentStoreMockRecorder) ContentsSize

func (mr *MockDocumentStoreMockRecorder) ContentsSize() *gomock.Call

ContentsSize indicates an expected call of ContentsSize

func (*MockDocumentStoreMockRecorder) FindByContentsHash added in v0.16.0

func (mr *MockDocumentStoreMockRecorder) FindByContentsHash(hash interface{}) *gomock.Call

FindByContentsHash indicates an expected call of FindByContentsHash

func (*MockDocumentStoreMockRecorder) Get

func (mr *MockDocumentStoreMockRecorder) Get(hash interface{}) *gomock.Call

Get indicates an expected call of Get

func (*MockDocumentStoreMockRecorder) GetAll

GetAll indicates an expected call of GetAll

func (*MockDocumentStoreMockRecorder) GetByConsistencyHash

func (mr *MockDocumentStoreMockRecorder) GetByConsistencyHash(hash interface{}) *gomock.Call

GetByConsistencyHash indicates an expected call of GetByConsistencyHash

func (*MockDocumentStoreMockRecorder) LastConsistencyHash

func (mr *MockDocumentStoreMockRecorder) LastConsistencyHash() *gomock.Call

LastConsistencyHash indicates an expected call of LastConsistencyHash

func (*MockDocumentStoreMockRecorder) ReadContents

func (mr *MockDocumentStoreMockRecorder) ReadContents(hash interface{}) *gomock.Call

ReadContents indicates an expected call of ReadContents

func (*MockDocumentStoreMockRecorder) Size

Size indicates an expected call of Size

func (*MockDocumentStoreMockRecorder) WriteContents

func (mr *MockDocumentStoreMockRecorder) WriteContents(hash, contents interface{}) *gomock.Call

WriteContents indicates an expected call of WriteContents

type NoopCloser

type NoopCloser struct {
	io.Reader
	io.Closer
}

NoopCloser implements io.ReadCloser with a No-Operation, intended for returning byte slices.

func (NoopCloser) Close

func (NoopCloser) Close() error

Jump to

Keyboard shortcuts

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