storage

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: May 20, 2022 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package storage provides a Bundle Storage based on BadgerHold, a frontend for the badger NoSQL store.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BundleItem

type BundleItem struct {
	Id  string `badgerhold:"key"`
	BId bpv7.BundleID

	Pending bool      `badgerholdIndex:"Pending"`
	Expires time.Time `badgerholdIndex:"Expires"`

	Fragmented bool
	Parts      []BundlePart

	Properties map[string]interface{}
}

BundleItem is a wrapper for meta data around a Bundle. The Store operates on BundleItems instead of Bundles.

func (BundleItem) IsComplete

func (bi BundleItem) IsComplete() bool

IsComplete determines if the BundleItem is complete and can be Load()ed.

func (BundleItem) Load

func (bi BundleItem) Load() (b bpv7.Bundle, err error)

Load the complete bpv7.Bundle for a BundleItem. If there are multiple fragments, a reassembly will be performed.

type BundlePart

type BundlePart struct {
	Filename string

	FragmentOffset  uint64
	TotalDataLength uint64
}

BundlePart links a BundleItem to a Bundle with possible information regarding fragmentation.

func (BundlePart) Load

func (bp BundlePart) Load() (b bpv7.Bundle, err error)

Load the Bundle struct from the disk.

type Store

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

Store implements a storage for Bundles together with meta data.

func NewStore

func NewStore(dir string) (s *Store, err error)

NewStore creates a new Store or opens an existing Store from the given path.

func (*Store) Close

func (s *Store) Close() error

Close the Store. It must not be used afterwards.

func (*Store) Delete

func (s *Store) Delete(bid bpv7.BundleID) error

Delete a BundleItem, represented by the "scrubbed" BundleID.

func (*Store) DeleteExpired

func (s *Store) DeleteExpired()

DeleteExpired removes all expired Bundles.

func (*Store) KnowsBundle

func (s *Store) KnowsBundle(bid bpv7.BundleID) bool

KnowsBundle checks if such a Bundle is known.

func (*Store) Push

func (s *Store) Push(b bpv7.Bundle) error

Push a new/received Bundle to the Store.

func (*Store) QueryId

func (s *Store) QueryId(bid bpv7.BundleID) (bi BundleItem, err error)

QueryId fetches the BundleItem for the requested BundleID.

func (*Store) QueryPending

func (s *Store) QueryPending() (bis []BundleItem, err error)

QueryPending fetches all pending Bundles.

func (*Store) Update

func (s *Store) Update(bi BundleItem) error

Update an existing BundleItem.

Jump to

Keyboard shortcuts

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