database

package
v0.0.0-...-c1dc28d Latest Latest
Warning

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

Go to latest
Published: May 28, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SharedKeyType is a plain uint32 representation of the document.SharedKey
	// constant.
	SharedKeyType = uint32(document.SharedKey)

	// UniqueKeyType is a plain uint32 representation of the document.UniqueKey
	// constant.
	UniqueKeyType = uint32(document.UniqueKey)
)

Variables

This section is empty.

Functions

func DeleteStore

func DeleteStore(tx *bolt.Tx, ns string) error

DeleteStore deletes the store for a given namespace. It is not an error to delete a non-existent store.

Types

type Content

type Content struct {
	// headers is an arbitrary set of key/value pairs that is persisted along
	// with the document content.
	Headers map[string]string `` /* 155-byte string literal not displayed */
	// content is the application-defined document content.
	Content              *any.Any `protobuf:"bytes,4,opt,name=content,proto3" json:"content,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

Content is container for a document's content.

func (*Content) Descriptor

func (*Content) Descriptor() ([]byte, []int)

func (*Content) GetContent

func (m *Content) GetContent() *any.Any

func (*Content) GetHeaders

func (m *Content) GetHeaders() map[string]string

func (*Content) ProtoMessage

func (*Content) ProtoMessage()

func (*Content) Reset

func (m *Content) Reset()

func (*Content) String

func (m *Content) String() string

func (*Content) XXX_DiscardUnknown

func (m *Content) XXX_DiscardUnknown()

func (*Content) XXX_Marshal

func (m *Content) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Content) XXX_Merge

func (dst *Content) XXX_Merge(src proto.Message)

func (*Content) XXX_Size

func (m *Content) XXX_Size() int

func (*Content) XXX_Unmarshal

func (m *Content) XXX_Unmarshal(b []byte) error

type Key

type Key struct {
	Type                 uint32          `protobuf:"varint,1,opt,name=type,proto3" json:"type,omitempty"`
	Documents            map[string]bool `` /* 160-byte string literal not displayed */
	XXX_NoUnkeyedLiteral struct{}        `json:"-"`
	XXX_unrecognized     []byte          `json:"-"`
	XXX_sizecache        int32           `json:"-"`
}

Key is an instance of a named key.

func (*Key) Descriptor

func (*Key) Descriptor() ([]byte, []int)

func (*Key) GetDocuments

func (m *Key) GetDocuments() map[string]bool

func (*Key) GetType

func (m *Key) GetType() uint32

func (*Key) GetUniqueDocumentID

func (k *Key) GetUniqueDocumentID() (string, bool)

GetUniqueDocumentID returns the document ID that this unique key refers to. It returns false if k is not a unique key, or it is empty.

func (*Key) ProtoMessage

func (*Key) ProtoMessage()

func (*Key) Reset

func (m *Key) Reset()

func (*Key) String

func (m *Key) String() string

func (*Key) XXX_DiscardUnknown

func (m *Key) XXX_DiscardUnknown()

func (*Key) XXX_Marshal

func (m *Key) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Key) XXX_Merge

func (dst *Key) XXX_Merge(src proto.Message)

func (*Key) XXX_Size

func (m *Key) XXX_Size() int

func (*Key) XXX_Unmarshal

func (m *Key) XXX_Unmarshal(b []byte) error

type Record

type Record struct {
	// revision is a 1-based document version number used to implement
	// optimistic concurrency control.
	Revision uint64 `protobuf:"varint,1,opt,name=revision,proto3" json:"revision,omitempty"`
	// keys is the set of indexing keys applied to the document. keys are used
	// to quickly find a document or set of documents based on identifieres
	// other than the document ID.
	Keys map[string]uint32 `` /* 150-byte string literal not displayed */
	// created_at is the time at which the document was created. The value is
	// set automatically when the document is saved.
	CreatedAt *timestamp.Timestamp `protobuf:"bytes,3,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`
	// updated_at is the time at which the document was last modified. The value
	// is set automatically when the document is saved.
	UpdatedAt            *timestamp.Timestamp `protobuf:"bytes,4,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"`
	XXX_NoUnkeyedLiteral struct{}             `json:"-"`
	XXX_unrecognized     []byte               `json:"-"`
	XXX_sizecache        int32                `json:"-"`
}

Record is the definitive record of a document's existence.

func UnmarshalRecord

func UnmarshalRecord(buf []byte) (*Record, error)

UnmarshalRecord unmarshals document record.

func (*Record) Descriptor

func (*Record) Descriptor() ([]byte, []int)

func (*Record) GetCreatedAt

func (m *Record) GetCreatedAt() *timestamp.Timestamp

func (*Record) GetKeys

func (m *Record) GetKeys() map[string]uint32

func (*Record) GetRevision

func (m *Record) GetRevision() uint64

func (*Record) GetUpdatedAt

func (m *Record) GetUpdatedAt() *timestamp.Timestamp

func (*Record) ProtoMessage

func (*Record) ProtoMessage()

func (*Record) Reset

func (m *Record) Reset()

func (*Record) String

func (m *Record) String() string

func (*Record) XXX_DiscardUnknown

func (m *Record) XXX_DiscardUnknown()

func (*Record) XXX_Marshal

func (m *Record) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Record) XXX_Merge

func (dst *Record) XXX_Merge(src proto.Message)

func (*Record) XXX_Size

func (m *Record) XXX_Size() int

func (*Record) XXX_Unmarshal

func (m *Record) XXX_Unmarshal(b []byte) error

type Store

type Store struct {
	Records *bolt.Bucket
	Content *bolt.Bucket
	Keys    *bolt.Bucket
}

Store is the data store for a single namespace.

func CreateStore

func CreateStore(tx *bolt.Tx, ns string) (*Store, error)

CreateStore returns the store for a single namespace, creating it if it does not exist.

func OpenStore

func OpenStore(tx *bolt.Tx, ns string) (*Store, bool, error)

OpenStore returns the store for the given namespace.

It returns false if the store does not exist.

func (*Store) DeleteContent

func (s *Store) DeleteContent(id string) error

DeleteContent deletes the content for the document with the given ID.

func (*Store) DeleteRecord

func (s *Store) DeleteRecord(id string) error

DeleteRecord deletes a document record.

func (*Store) GetContent

func (s *Store) GetContent(id string) (*Content, error)

GetContent gets the content of the document with the given ID.

func (*Store) GetKey

func (s *Store) GetKey(key string) (*Key, error)

GetKey loads a key by its name. If the key does not exist, a pointer to a zero-value Key is returned.

func (*Store) GetRecord

func (s *Store) GetRecord(id string) (*Record, error)

GetRecord loads the record for the document with the gien ID.

It is intended for use when the document is known to exist. It returns an error if the document is not in the store.

func (*Store) PutContent

func (s *Store) PutContent(id string, c *Content) error

PutContent saves the content for a document.

func (*Store) PutRecord

func (s *Store) PutRecord(id string, rec *Record) error

PutRecord creates or updates a document record.

func (*Store) TryGetRecord

func (s *Store) TryGetRecord(id string) (*Record, bool, error)

TryGetRecord loads the record for the document with the given ID.

The presence of the record is the authoratative indicator of a document's existence. It returns false if the document is not in the store.

func (*Store) UpdateKeys

func (s *Store) UpdateKeys(
	id string,
	before, after map[string]uint32,
) error

UpdateKeys updates the unique keys for a specific document.

Jump to

Keyboard shortcuts

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