Documentation ¶
Overview ¶
Package log is an operation-based conflict-free replicated data type (CRDT) of append-only logs. A log is a sequence of operations attributed to a single author, designated by a private key. Each operation is a record of some action the author took. Applications iterate the sequence of operations to produce the current state. Logs can be arranged into hierarchies to form logical groupings. A book contains an author's logs, both logs they've written as well as logs replicated from other authors. Books are encrypted at rest using the author private key.
Index ¶
- type Book
- type Log
- func (lg *Log) AddChild(l *Log)
- func (lg *Log) Append(op Op)
- func (lg Log) Author() (name, identifier string)
- func (lg Log) Child(name string) *Log
- func (lg Log) Len() int
- func (lg Log) MarshalFlatbuffer(builder *flatbuffers.Builder) flatbuffers.UOffsetT
- func (lg Log) Model() uint32
- func (lg Log) Name() string
- func (lg Log) Ops() []Op
- func (lg *Log) Sign(pk crypto.PrivKey) (err error)
- func (lg Log) SignedFlatbufferBytes(pk crypto.PrivKey) ([]byte, error)
- func (lg Log) SigningBytes() []byte
- func (lg *Log) UnmarshalFlatbuffer(lfb *logfb.Log) (err error)
- func (lg Log) Verify(pub crypto.PubKey) error
- type Op
- type OpType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Book ¶
type Book struct {
// contains filtered or unexported fields
}
Book is a journal of operations organized into a collection of append-only logs. Each log is single-writer Books are connected to a single author, and represent their view of the global dataset graph. Any write operation performed on the logbook are attributed to a single author, denoted by a private key. Books can replicate logs from other authors, forming a conflict-free replicated data type (CRDT), and a basis for collaboration through knowledge of each other's operations
func (Book) AuthorName ¶
AuthorName gives the human-readable name of the author
func (Book) FlatbufferCipher ¶
FlatbufferCipher marshals book to a flatbuffer and encrypts the book using the book private key
type Log ¶
type Log struct {
// contains filtered or unexported fields
}
Log is a causally-ordered set of operations performed by a single author. log attribution is verified by an author's signature
func FromFlatbufferBytes ¶
FromFlatbufferBytes initializes a log from flatbuffer data
func (Log) MarshalFlatbuffer ¶
func (lg Log) MarshalFlatbuffer(builder *flatbuffers.Builder) flatbuffers.UOffsetT
MarshalFlatbuffer writes log to a flatbuffer, returning the ending byte offset
func (Log) Model ¶
Model gives the operation type for a log, based on the first operation written to the log. Logs can contain multiple models of operations, but the first operation written to a log determines the kind of log for catagorization purposes
func (Log) Name ¶
Name returns the human-readable name for this log, determined by the initialization event TODO (b5) - name must be made mutable by playing forward any name-changing operations and applying them to the log
func (*Log) Sign ¶
Sign assigns the log signature by signing the logging checksum with a given private key TODO (b5) - this is assuming the log is authored by this private key. as soon as we add collaborators, this won't be true
func (Log) SignedFlatbufferBytes ¶
SignedFlatbufferBytes signs a log then marshals it to a flatbuffer
func (Log) SigningBytes ¶
SigningBytes perpares a byte slice for signing from a log's operations
func (*Log) UnmarshalFlatbuffer ¶
UnmarshalFlatbuffer reads a Log from
type Op ¶
type Op struct { Type OpType // type of operation Model uint32 // data model to operate on Ref string // identifier of data this operation is documenting Prev string // previous reference in a causal history Relations []string // references this operation relates to. usage is operation type-dependant Name string // human-readable name for the reference AuthorID string // identifier for author Timestamp int64 // operation timestamp, for annotation purposes only Size uint64 // size of the referenced value in bytes Note string // operation annotation for users. eg: commit title }
Op is an operation, a single atomic unit in a log that describes a state change
func UnmarshalOpFlatbuffer ¶
UnmarshalOpFlatbuffer creates an op from a flatbuffer operation pointer
func (Op) MarshalFlatbuffer ¶
func (o Op) MarshalFlatbuffer(builder *flatbuffers.Builder) flatbuffers.UOffsetT
MarshalFlatbuffer writes this operation to a flatbuffer, returning the ending byte offset
type OpType ¶
type OpType byte
OpType is the set of all kinds of operations, they are two bytes in length OpType splits the provided byte in half, using the higher 4 bits for the "category" of operation, and the lower 4 bits for the type of operation within the category the second byte is reserved for future use