dieci

package module
v0.0.0-...-7bfe347 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2023 License: MIT Imports: 13 Imported by: 0

README

Dieci

Build Status Go Report Card

Write-once data store.

Summary

This is an experimental immutable binary store with write-once policy infuenced by Plain 9 Venti storage system.

Name

Dieci is ten in Italian. The name somehow maybe related to venti which is twenty in Italian.

License

MIT

Documentation

Overview

Package dieci implements basic API for Dieci data store

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEncrypt is a shield error for any encyption failure
	ErrEncrypt = errors.New("encryption failed")
	// ErrDecrypt is a shield error for any decyption failure
	ErrDecrypt = errors.New("decryption failed")
)

Functions

func ValidateKey

func ValidateKey(data []byte) error

ValidateKey attempt to decode byte slice into sno ID to confirm that it's a valid key.

Types

type Backend

type Backend interface {
	Read([]byte) ([]byte, error)
	Exists([]byte) (bool, error)
	Write([]byte, []byte) error
}

Backend is an interface for Dieci backend implementation

func NewBadgerBackend

func NewBadgerBackend(txn *badger.Txn) Backend

NewBadgerBackend returns new instance of Badger backend for a given transaction

type BadgerBackend

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

BadgerBackend implements backedn with BadgerDB

func (*BadgerBackend) Exists

func (bb *BadgerBackend) Exists(k []byte) (bool, error)

Exists confirms if given key exists in Badger backend

func (*BadgerBackend) Read

func (bb *BadgerBackend) Read(k []byte) ([]byte, error)

Read reads value for a given key from Badger backend

func (*BadgerBackend) Write

func (bb *BadgerBackend) Write(k []byte, v []byte) error

Write creates and writes a new KV entry into Badger backend

type Datalog

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

Datalog represents a datastore's datalog

func NewDatalog

func NewDatalog(backend Backend) *Datalog

NewDatalog returns a new datalog for a given transaction

func (*Datalog) Read

func (dl *Datalog) Read(score Score) ([]byte, error)

Read is a read callback

func (*Datalog) Write

func (dl *Datalog) Write(data []byte) (Score, error)

Write is a write callback

type Index

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

Index represents an index of a datalog file

func NewIndex

func NewIndex(b Backend) *Index

NewIndex returns a new index

func (*Index) Read

func (idx *Index) Read(key Key) (Score, error)

Read is a read callback

func (*Index) Write

func (idx *Index) Write(score Score) (Key, error)

Write is a write callback

type Key

type Key []byte

Key is an alias for key representation

func NewKey

func NewKey() Key

NewKey generates and returns new key

func (Key) String

func (k Key) String() string

String returns a string representation for the key to comply with Stringer interface

type PKI

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

PKI represent an interface to PKI service (e.g Valut)

func NewPKI

func NewPKI(b Backend) *PKI

NewPKI returns an instance of PKI interface

func (*PKI) Decrypt

func (pki *PKI) Decrypt(data []byte) ([]byte, error)

Decrypt given ciphertext with PKI's encryption key

func (*PKI) Encrypt

func (pki *PKI) Encrypt(data []byte) ([]byte, error)

Encrypt given data with PKI's encryption key

func (*PKI) GenerateNonce

func (pki *PKI) GenerateNonce() (*[nonceSize]byte, error)

GenerateNonce creates a new random nonce

type Score

type Score []byte

Score is a type alias for score representation

func NewScore

func NewScore(data []byte) Score

NewScore returns a new score for a given data

func (Score) String

func (s Score) String() string

String added to comply with Stringer interface

type Store

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

Store represents a data store.

func Open

func Open(name string) (s *Store, err error)

Open opens provided storage

func (*Store) Close

func (s *Store) Close() error

Close provided storage

func (*Store) Read

func (s *Store) Read(key []byte) ([]byte, error)

Read a data for a given score

func (*Store) Write

func (s *Store) Write(data []byte) ([]byte, error)

Write given data and return it's score

Jump to

Keyboard shortcuts

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