store

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2022 License: MIT Imports: 18 Imported by: 1

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 document databases or key/value stores such as leveldb or trtl. 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.

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 AnnouncementStore added in v1.5.2

type AnnouncementStore interface {
	RetrieveAnnouncementMonth(date string) (*bff.AnnouncementMonth, error)
	UpdateAnnouncementMonth(m *bff.AnnouncementMonth) error
	DeleteAnnouncementMonth(date string) error
}

AnnouncementStore describes how services interact with the Announcement records.

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 CertificateRequestStore

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

CertificateRequestStore describes how services interact with Certificate requests.

type CertificateStore

type CertificateStore interface {
	ListCerts() iterator.CertificateIterator
	CreateCert(c *models.Certificate) (string, error)
	RetrieveCert(id string) (*models.Certificate, error)
	UpdateCert(c *models.Certificate) error
	DeleteCert(id string) error
}

CertificateStore describes how services interact with Certificate records.

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 services interact 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 OrganizationStore added in v1.5.2

type OrganizationStore interface {
	CreateOrganization() (*bff.Organization, error)
	RetrieveOrganization(id uuid.UUID) (*bff.Organization, error)
	UpdateOrganization(o *bff.Organization) error
	DeleteOrganization(id uuid.UUID) error
}

OrganizationStore describes how services interact with the Organization records.

type Store

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.StoreConfig) (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