store

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2024 License: MIT Imports: 20 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
	Count() (uint64, error) 					   // Count the number of objects
}

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 ActivityStore added in v1.7.3

type ActivityStore interface {
	RetrieveActivityMonth(ctx context.Context, date string) (*bff.ActivityMonth, error)
	UpdateActivityMonth(ctx context.Context, m *bff.ActivityMonth) error
	DeleteActivityMonth(ctx context.Context, date string) error
	CountActivityMonth(context.Context) (uint64, error)
}

ActivityStore describes how services interact with the Activity records.

type AnnouncementStore added in v1.5.2

type AnnouncementStore interface {
	RetrieveAnnouncementMonth(ctx context.Context, date string) (*bff.AnnouncementMonth, error)
	UpdateAnnouncementMonth(ctx context.Context, m *bff.AnnouncementMonth) error
	DeleteAnnouncementMonth(ctx context.Context, date string) error
	CountAnnouncementMonths(context.Context) (uint64, 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(ctx context.Context) iterator.CertificateRequestIterator
	CreateCertReq(ctx context.Context, r *models.CertificateRequest) (string, error)
	RetrieveCertReq(ctx context.Context, id string) (*models.CertificateRequest, error)
	UpdateCertReq(ctx context.Context, r *models.CertificateRequest) error
	DeleteCertReq(ctx context.Context, id string) error
	CountCertReqs(context.Context) (uint64, error)
}

CertificateRequestStore describes how services interact with Certificate requests.

type CertificateStore

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

CertificateStore describes how services interact with Certificate records.

type ContactStore added in v1.7.0

type ContactStore interface {
	ListContacts(ctx context.Context) []*models.Contact
	CreateContact(ctx context.Context, c *models.Contact) (string, error)
	RetrieveContact(ctx context.Context, email string) (*models.Contact, error)
	UpdateContact(ctx context.Context, c *models.Contact) error
	DeleteContact(ctx context.Context, email string) error
	CountContacts(context.Context) (uint64, error)
}

ContactStore describes how services interact with the Contact 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(ctx context.Context) iterator.DirectoryIterator
	SearchVASPs(ctx context.Context, query map[string]interface{}) ([]*pb.VASP, error)
	CreateVASP(ctx context.Context, v *pb.VASP) (string, error)
	RetrieveVASP(ctx context.Context, id string) (*pb.VASP, error)
	UpdateVASP(ctx context.Context, v *pb.VASP) error
	DeleteVASP(ctx context.Context, id string) error
	CountVASPs(ctx context.Context) (uint64, 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 {
	ListOrganizations(ctx context.Context) iterator.OrganizationIterator
	CreateOrganization(ctx context.Context, o *bff.Organization) (string, error)
	RetrieveOrganization(ctx context.Context, id uuid.UUID) (*bff.Organization, error)
	UpdateOrganization(ctx context.Context, o *bff.Organization) error
	DeleteOrganization(ctx context.Context, id uuid.UUID) error
	CountOrganizations(context.Context) (uint64, 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