store

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package store provides an interface to multiple types of embedded storage across multiple objects. Unlike a SQL interface, the TRISA directory service relies on embedded databases (e.g. like LevelDB) and replication using anti-entropy. It also manages multiple namespaces (object types) - VASP records, CertificateRequests, Peers, etc. In general an object store interface provides accesses to the objects, with one interface per namespace as follows:

type ObjectStore interface {
	List() *Iterator                               // Iterate over all objects
	Search(query map[string]interface{}) *Iterator // Create a query to list filtered objects
	Create(o *Object) (id string, err error)       // Make the object
	Retrieve(id string) (o *Object, err error)     // Fetch an object by ID or by key
	Update(o *Object) error                        // Make changes to an object
	Delete(id string) error                        // Delete an object
}

Ideally there would be a store per namespace, but in order to generalize the store to multiple embedded databases, the store interface affixes the object store methods with the namespace. E.g. ListVASPs, CreateCertReq, etc.

For Replication, the replica needs special access to the store to list all objects including tombstones and to place objects without updating their metadata. For a namespace that can be replicated the interface is:

type ReplicatedObjectStore interface {
	Scan(ns string) *Iterator          // Lists all objects including tombstones in the namespace
	Place(ns string, o *Object) error  // Puts an object into the namespace without metadata changes
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load(db Store, path string) (err error)

Load the database from a CSV fixture specified on disk by the path. TODO: this method needs to be updated for the new data structure.

Types

type Backup

type Backup interface {
	Backup(string) error
}

Backup means that the Store can be backed up to a compressed location on disk, optionally with encryption if its required.

type CertificateStore

type CertificateStore interface {
	ListCertReqs() iterator.CertificateIterator
	CreateCertReq(r *models.CertificateRequest) (string, error)
	RetrieveCertReq(id string) (*models.CertificateRequest, error)
	UpdateCertReq(r *models.CertificateRequest) error
	DeleteCertReq(id string) error
}

CertificateStore describes how the service interacts with Certificate requests.

type DSN

type DSN struct {
	Scheme string
	Path   string
}

DSN represents the parsed components of an embedded database service.

func ParseDSN

func ParseDSN(uri string) (_ *DSN, err error)

DSN Parsing and Handling

type DirectoryStore

type DirectoryStore interface {
	ListVASPs() iterator.DirectoryIterator
	SearchVASPs(query map[string]interface{}) ([]*pb.VASP, error)
	CreateVASP(v *pb.VASP) (string, error)
	RetrieveVASP(id string) (*pb.VASP, error)
	UpdateVASP(v *pb.VASP) error
	DeleteVASP(id string) error
}

DirectoryStore describes how the service interacts with VASP identity records.

type Indexer

type Indexer interface {
	Reindex() error
}

Indexer allows external methods to access the index function of the store if it has them. E.g. a leveldb embedded database or other store that uses an in-memory index needs to be an Indexer but not a SQL database.

type Store

type Store interface {
	Close() error
	DirectoryStore
	CertificateStore
}

Store provides an interface for directory storage services to abstract the underlying database provider. The storage methods correspond to directory service requests, which are currently implemented with a simple CRUD and search interface for VASP records and certificate requests. The underlying database can be a simple embedded store or a distributed SQL server, so long as it can interact with identity records.

func Open

func Open(conf config.DatabaseConfig) (s Store, err error)

Open a directory storage provider with the specified URI. Database URLs should either specify protocol+transport://user:pass@host/dbname?opt1=a&opt2=b for servers or protocol:///relative/path/to/file for embedded databases (for absolute paths, specify protocol:////absolute/path/to/file).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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