bolt

package
v0.0.0-...-a4d05e0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// MetaBucket Keys
	VersionKey     = []byte("version")
	CurrentVersion = []byte{0x1, 0x0} // 1.0

	// Top Level Buckets, besides individual topic buckets
	MetaBucket = []byte("META")

	ErrVersionMismatch = errors.New("unexpected DB version")
)
View Source
var (
	// Topic Level Buckets
	EventsBucket = []byte("EVENTS")
	HeadsBucket  = []byte("HEADS")
	ByCIDBucket  = []byte("BY_CID")

	ErrByCIDCorrupted = errors.New("by CID index references unknown event time key")
)

Functions

func NewDB

func NewDB(opts *Options) (*bolt.DB, error)

Types

type NodeStore

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

NodeStore using embedded BoltDB.

func NewNodeStore

func NewNodeStore(ctx context.Context, db *bolt.DB, opts *Options) (*NodeStore, error)

func (*NodeStore) Close

func (s *NodeStore) Close() error

func (*NodeStore) DeleteTopic

func (s *NodeStore) DeleteTopic(topic string) error

func (*NodeStore) NewTopic

func (s *NodeStore) NewTopic(name string) (crdt.Store, error)

NewTopic returns a store for a pre-existing topic or creates a new one.

func (*NodeStore) Topics

func (s *NodeStore) Topics() (topics []string, err error)

Topics lists all topics in the store.

type Options

type Options struct {
	DataPath string `long:"data-path" env:"BOLT_DATA_PATH" description:"Path to the bolt DB file" default:""`
}

type Store

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

Store is a topic focused adaptor on top of Store

func New

func New(ctx context.Context, db *bolt.DB, topic string) *Store

func (*Store) AppendEvent

func (s *Store) AppendEvent(ctx context.Context, env *messagev1.Envelope) (ev *types.Event, err error)

func (*Store) Events

func (s *Store) Events(ctx context.Context) (evs []*types.Event, err error)
func (s *Store) FindMissingLinks(ctx context.Context) (links []multihash.Multihash, err error)

func (*Store) GetEvents

func (s *Store) GetEvents(ctx context.Context, cids ...multihash.Multihash) (evs []*types.Event, err error)

func (*Store) Heads

func (s *Store) Heads(ctx context.Context) (cids []multihash.Multihash, err error)

func (*Store) InsertEvent

func (s *Store) InsertEvent(ctx context.Context, ev *types.Event) (added bool, err error)

func (*Store) InsertHead

func (s *Store) InsertHead(ctx context.Context, ev *types.Event) (added bool, err error)

func (*Store) InsertNewEvents

func (s *Store) InsertNewEvents(ctx context.Context, evs []*types.Event) error

func (*Store) Query

func (s *Store) Query(ctx context.Context, req *messagev1.QueryRequest) (resp *messagev1.QueryResponse, err error)

func (*Store) RemoveHead

func (s *Store) RemoveHead(ctx context.Context, cid multihash.Multihash) (have bool, err error)

Jump to

Keyboard shortcuts

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