docstore

package
v4.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: AGPL-3.0 Imports: 22 Imported by: 0

README

DocStore Service

This service provides a simple, indexed key/value store for both JSON documents and Binaries. Documents are stored in a BoltDB database, and indexed (and thus searchable) using Bleve full-text search engine.

API

GRPC Handler provides the following service

service DocStore {
    rpc PutDocument (PutDocumentRequest) returns (PutDocumentResponse) {};
    rpc GetDocument (GetDocumentRequest) returns (GetDocumentResponse) {};
    rpc DeleteDocuments (DeleteDocumentsRequest) returns (DeleteDocumentsResponse) {};
    rpc CountDocuments(ListDocumentsRequest) returns (CountDocumentsResponse) {};
    rpc ListDocuments(ListDocumentsRequest) returns (stream ListDocumentsResponse) {};
}

Documents objects are use the following model:

message Document {
    string ID = 2;
    DocumentType Type = 3;
    string Owner = 4;
    bytes Data = 5;
    bytes IndexableMeta = 6;
}

Data can contain a JSON serialized string that will be actually stored, whereas IndexableMeta contains JSON that will be indexed by the search engine. This metadata can have many level depth, and keys can then be searched with Bleve query string like "Key1: value" or "+Key1.SubKey:value*"

Binaries

Binary documents are redirected at the gateway level to a dedicated S3 bucket defined in the configuration. Binary are then served directly via S3.

Documentation

Overview

Package docstore provides an indexed JSON document store.

It is used by various services to store their data instead of implementing yet-another persistence layer. It uses a combination of Bolt for storage and Bleve for indexation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Migrate

func Migrate(f dao.DAO, t dao.DAO, dryRun bool, status chan dao.MigratorStatus) (map[string]int, error)

func NewDAO

func NewDAO(ctx context.Context, o dao.DAO) (dao.DAO, error)

Types

type BleveServer

type BleveServer struct {
	boltdb2.DAO
	// Internal Bolt
	*BoltStore
	// Internal Bleve database
	Engine bleve.Index
	// For Testing purpose : delete file after closing
	DeleteOnClose bool
	// Path to the DB file
	IndexPath string
}

func NewBleveEngine

func NewBleveEngine(dao boltdb2.DAO, deleteOnClose ...bool) (*BleveServer, error)

func (*BleveServer) CloseConn added in v4.0.1

func (s *BleveServer) CloseConn(ctx context.Context) error

CloseConn overrides internal DAO.CloseConn method to close Bleve index at the same time

func (*BleveServer) CountDocuments

func (s *BleveServer) CountDocuments(storeId string, query *docstore.DocumentQuery) (int, error)

func (*BleveServer) DeleteDocument

func (s *BleveServer) DeleteDocument(storeID string, docID string) error

func (*BleveServer) DeleteDocuments

func (s *BleveServer) DeleteDocuments(storeID string, query *docstore.DocumentQuery) (int, error)

func (*BleveServer) PutDocument

func (s *BleveServer) PutDocument(storeID string, doc *docstore.Document) error

func (*BleveServer) QueryDocuments

func (s *BleveServer) QueryDocuments(storeID string, query *docstore.DocumentQuery) (chan *docstore.Document, error)

func (*BleveServer) Reset

func (s *BleveServer) Reset() error

type BoltStore

type BoltStore struct {

	// Path to the DB file
	DbPath string
	// contains filtered or unexported fields
}

func NewBoltStore

func NewBoltStore(fileName string) (*BoltStore, error)

func (*BoltStore) DeleteDocument

func (s *BoltStore) DeleteDocument(storeID string, docID string) error

func (*BoltStore) GetDocument

func (s *BoltStore) GetDocument(storeID string, docId string) (*docstore.Document, error)

func (*BoltStore) GetStore

func (s *BoltStore) GetStore(tx *bolt.Tx, storeID string, mode string) (*bolt.Bucket, error)

func (*BoltStore) ListDocuments

func (s *BoltStore) ListDocuments(storeID string, query *docstore.DocumentQuery) (chan *docstore.Document, error)

func (*BoltStore) ListStores

func (s *BoltStore) ListStores() ([]string, error)

ListStores list all buckets

func (*BoltStore) PutDocument

func (s *BoltStore) PutDocument(storeID string, doc *docstore.Document) error

type DAO

type DAO interface {
	dao.DAO
	PutDocument(storeID string, doc *docstore.Document) error
	GetDocument(storeID string, docId string) (*docstore.Document, error)
	DeleteDocument(storeID string, docID string) error
	DeleteDocuments(storeID string, query *docstore.DocumentQuery) (int, error)
	QueryDocuments(storeID string, query *docstore.DocumentQuery) (chan *docstore.Document, error)
	CountDocuments(storeID string, query *docstore.DocumentQuery) (int, error)
	ListStores() ([]string, error)
	Reset() error
}

Directories

Path Synopsis
Package grpc exposes the document store api in GRPC
Package grpc exposes the document store api in GRPC

Jump to

Keyboard shortcuts

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