notes

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package notes provides types and functions for interacting with a note maps data storage system.

Package notes provides types and functions for interacting with a note maps data storage system.

Package notes provides types and functions for interacting with a note maps data storage system.

Package notes provides types and functions for interacting with a note maps data storage system.

Index

Constants

View Source
const EmptyId uint64 = 0

EmptyId is the zero or nil value for note identifiers, and never identifies a valid note.

EmptyId exists only to make code that specifies the zero value for Note identifiers a bit more readable.

View Source
const (
	// EmptyLoader implements the Loader interface for a note map that is
	// always empty.
	EmptyLoader emptyLoader = 0
)

Variables

This section is empty.

Functions

func DebugDiff

func DebugDiff(a, b Note) (string, interface{}, interface{}, error)

func Equal

func Equal(a, b Note) (bool, error)

Types

type EmptyNote

type EmptyNote uint64

EmptyNote is simply an empty Note with nothing more than an Id.

func (EmptyNote) GetContents

func (x EmptyNote) GetContents() ([]Note, error)

func (EmptyNote) GetId

func (x EmptyNote) GetId() uint64

func (EmptyNote) GetSupertypes

func (x EmptyNote) GetSupertypes() ([]Note, error)

func (EmptyNote) GetTypes

func (x EmptyNote) GetTypes() ([]Note, error)

func (EmptyNote) GetValue

func (x EmptyNote) GetValue() (string, Note, error)

type Error

type Error int
const (
	InvalidId Error = iota
)

func (Error) Error

func (e Error) Error() string

type Finder

type Finder interface {
	Find(*Query) ([]Note, error)
}

Finder can be implemented to support finding notes in a note map according to a query.

type Loader

type Loader interface {
	// Load returns a slice of all found notes.
	//
	// If the error is NotFound, the returned notes includes all found
	// notes and NotFound.Ids holds the ids of notes that were not found.
	Load(ids []uint64) ([]Note, error)
}

Loader can be implemented to support loading notes by id.

type Note

type Note interface {
	GetId() uint64
	GetTypes() ([]Note, error)
	GetSupertypes() ([]Note, error)
	GetValue() (string, Note, error)
	GetContents() ([]Note, error)
}

Note is a graph-like interface to a note in a note map.

Since traversing from note to note in a note map may require fragile operations like loading query results from a storage backend, most methods can return an error instead of the requested data.

func LoadOne

func LoadOne(l Loader, id uint64) (Note, error)

LoadOne is a convenience function for loading just one note.

type NoteMap

type NoteMap interface {
	Finder
	Loader
	Patcher
	io.Closer
}

NoteMap can be implemented to support finding and patching notes in a note map.

An instance of DB should be closed when it is no longer needed.

type Patcher

type Patcher interface {
	Patch(ops []change.Operation) error
}

Patcher can be implemented to support making changes to notes in a note map by applying a set of differences to them.

type Query

type Query struct {
}

Query limits the notes that will be found when loading information from a graph.

The default query matches all notes.

type Stage

type Stage struct {
	Ops  []change.Operation
	Base Loader
}

Stage describes a set of changes that might be made to a note map.

The default stage describes an empty set of changes to be made to an empty note map.

A default Stage{} is an empty set of changes made to an empty note map.

func (*Stage) Add

func (x *Stage) Add(o change.Operation) *Stage

Add simply appends o to the set of operations described by x.

func (*Stage) GetBase

func (x *Stage) GetBase(defaultEmpty bool) Loader

GetBase returns a non-nil Loader derived from x.Base.

func (*Stage) Note

func (x *Stage) Note(id uint64) *StageNote

Note returns a note-specific StageNote focused on note with id.

type StageNote

type StageNote struct {
	Stage *Stage
	Id    uint64
}

StageNote supports updating the content of a note within a batch, and also implements the Note interface to read the hypothetical state of a note with the batch applied.

func (*StageNote) AddContent

func (x *StageNote) AddContent(id uint64) *StageNote

AddContent expands the staged operations to add content to this note.

func (*StageNote) GetContents

func (x *StageNote) GetContents() ([]Note, error)

func (*StageNote) GetId

func (x *StageNote) GetId() uint64

func (*StageNote) GetSupertypes

func (x *StageNote) GetSupertypes() ([]Note, error)

func (*StageNote) GetTypes

func (x *StageNote) GetTypes() ([]Note, error)

func (*StageNote) GetValue

func (x *StageNote) GetValue() (string, Note, error)

func (*StageNote) SetValue

func (x *StageNote) SetValue(lexical string, datatype uint64)

SetValue expands the staged operations to update the value of this note.

Directories

Path Synopsis
Package genji implements notes/pbdb interfaces to store Note Maps in a Genji database.
Package genji implements notes/pbdb interfaces to store Note Maps in a Genji database.
Package pbdb provides types and functions for storing note maps using a small number of protocol buffer message types.
Package pbdb provides types and functions for storing note maps using a small number of protocol buffer message types.
pb
Package notespb defines protocol buffer message types intended for use in note maps data storage APIs.
Package notespb defines protocol buffer message types intended for use in note maps data storage APIs.

Jump to

Keyboard shortcuts

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