api

package
v0.0.0-...-8efdbaf Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	NumberWorkers int
	ClientOptions *immuclient.Options
}

Config represents the required API options.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig defines a configuration with stock options.

func (*Config) WithClientOptions

func (c *Config) WithClientOptions(options *immuclient.Options) *Config

WithClientOptions set the client options used to initialize the ImmuDB client.

func (*Config) WithNumberWorkers

func (c *Config) WithNumberWorkers(numWorkers int) *Config

WithNumberWorkers set the number of workers used on Store actions.

type GetDocumentResult

type GetDocumentResult struct {
	ID      string
	Index   uint64
	Payload []byte
	Hash    string
}

GetDocumentResult represents the result of fetching a document.

type Manager

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

Manager represents the object required to use the API.

func New

func New(c *Config) (*Manager, error)

New creates a new API manager object.

func (*Manager) GetDocument

func (m *Manager) GetDocument(ctx context.Context, docId string) (*GetDocumentResult, error)

GetDocument allows the extraction of a document provided its global ID.

func (*Manager) StoreDocument

func (m *Manager) StoreDocument(ctx context.Context, docID string, r io.Reader) (*StoreDocumentResult, error)

StoreDocument saves a JSON document in the database, marshaling its structure into key-value properties, representing the transversal property paths of the original object.

func (*Manager) UpdateDocument

func (m *Manager) UpdateDocument(ctx context.Context, docID string, key string, value []byte) (*GetDocumentResult, error)

UpdateDocument allows the update of a given property of a document. Here the underlying assumption for the implementation is that updates are fairly rare and limited in scope.

func (*Manager) VerifyDocument

func (m *Manager) VerifyDocument(ctx context.Context, docID, globalHash string) (bool, error)

VerifyDocument ensures that the stored document hash matches a known global hash, returning True if the integrity of the document is ensured, and False otherwise.

type ObjectManifest

type ObjectManifest struct {
	ObjectID string   `json:"id"`
	Indexes  []uint64 `json:"indexes"`
	Hash     string   `json:"hash"`
}

ObjectManifest defines the top level object that describes a document in the Database, including the object ID of said document, the indexes of each of its properties and the global hash of the document (comprised by the hash of hashes, sorted according to the associated property index).

type StoreDocumentResult

type StoreDocumentResult struct {
	Index uint64
	Hash  string
}

StoreDocumentResult represents the insertion result of a document.

Jump to

Keyboard shortcuts

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