backend

package
v0.0.0-...-6d444a5 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2018 License: ISC Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrRecordNotFound is emitted when a record could not be found
	ErrRecordNotFound = errors.New("record not found")

	// ErrFileNotFound is emitted when a file inside a record could not be
	// found
	ErrFileNotFound = errors.New("file not found")

	// ErrShutdown is emitted when the backend is shutting down.
	ErrShutdown = errors.New("backend is shutting down")

	// ErrShutdown is emitted when the backend is shutting down.
	ErrNoChanges = errors.New("no changes to record")

	// ErrRecordLocked is returned when an updated was attempted on a
	// locked record.
	ErrRecordLocked = errors.New("record is locked")

	// Plugin names must be all lowercase letters and have a length of <20
	PluginRE = regexp.MustCompile(`^[a-z]{1,20}$`)
)
View Source
var (
	// MDStatus converts a status code to a human readable error.
	MDStatus = map[MDStatusT]string{
		MDStatusInvalid:           "invalid",
		MDStatusUnvetted:          "unvetted",
		MDStatusVetted:            "vetted",
		MDStatusCensored:          "censored",
		MDStatusIterationUnvetted: "iteration unvetted",
		MDStatusLocked:            "locked",
	}
)

Functions

This section is empty.

Types

type Backend

type Backend interface {
	// Create new record
	New([]MetadataStream, []File) (*RecordMetadata, error)

	// Update unvetted record (token, mdAppend, mdOverwrite, fAdd, fDelete)
	UpdateUnvettedRecord([]byte, []MetadataStream, []MetadataStream, []File,
		[]string) (*RecordMetadata, error)

	// Update vetted metadata (token, mdAppend, mdOverwrite)
	UpdateVettedMetadata([]byte, []MetadataStream,
		[]MetadataStream) error

	// Get unvetted record
	GetUnvetted([]byte) (*Record, error)

	// Get vetted record
	GetVetted([]byte) (*Record, error)

	// Set unvetted record status
	SetUnvettedStatus([]byte, MDStatusT, []MetadataStream,
		[]MetadataStream) (*Record, error)

	// Inventory retrieves various record records.
	Inventory(uint, uint, bool) ([]Record, []Record, error)

	// Obtain plugin settings
	GetPlugins() ([]Plugin, error)

	// Plugin pass-through command
	Plugin(string, string) (string, string, error) // command type, payload, errror

	// Close performs cleanup of the backend.
	Close()
}

type ContentVerificationError

type ContentVerificationError struct {
	ErrorCode    v1.ErrorStatusT
	ErrorContext []string
}

ContentVerificationError is returned when a submitted record contains unacceptable file formats or corrupt data.

func (ContentVerificationError) Error

func (c ContentVerificationError) Error() string

type File

type File struct {
	Name    string // Basename of the file
	MIME    string // MIME type
	Digest  string // SHA256 of decoded Payload
	Payload string // base64 encoded file
}

type MDStatusT

type MDStatusT int
const (
	// All possible MD status codes
	MDStatusInvalid           MDStatusT = 0 // Invalid status, this is a bug
	MDStatusUnvetted          MDStatusT = 1 // Unvetted record
	MDStatusVetted            MDStatusT = 2 // Vetted record
	MDStatusCensored          MDStatusT = 3 // Censored record
	MDStatusIterationUnvetted MDStatusT = 4 // Changes are unvetted
	MDStatusLocked            MDStatusT = 5 // Record is locked, only vetted->locked allowed
)

type MetadataStream

type MetadataStream struct {
	ID      uint64 // Stream identity
	Payload string // String encoded metadata
}

MetadataStream describes a single metada stream. The ID determines how and where it is stored.

type Plugin

type Plugin struct {
	ID       string          // Identifier
	Version  string          // Version
	Settings []PluginSetting // Settings
}

Plugin describes a plugin and its settings.

type PluginSetting

type PluginSetting struct {
	Key   string // Name of setting
	Value string // Value of setting
}

PluginSettings

type Record

type Record struct {
	RecordMetadata RecordMetadata   // Internal metadata
	Metadata       []MetadataStream // User provided metadata
	Files          []File           // User provided files
}

Record is a permanent that includes the submitted files, metadata and internal metadata.

type RecordMetadata

type RecordMetadata struct {
	Version   uint              // Iteration count of record
	Status    MDStatusT         // Current status of the record
	Merkle    [sha256.Size]byte // Merkle root of all files in record
	Timestamp int64             // Last updated
	Token     []byte            // Record authentication token
}

RecordMetadata is the metadata of a record.

type StateTransitionError

type StateTransitionError struct {
	From MDStatusT
	To   MDStatusT
}

StateTransitionError indicates an invalid record status transition.

func (StateTransitionError) Error

func (s StateTransitionError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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