stodb

package
v0.0.0-...-ea0be71 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Encapsulates access to the metadata database

Index

Constants

View Source
const (
	CurrentSchemaVersion = 6
)

Variables

View Source
var (
	CfgNodeId              = configAccessor("nodeId")
	CfgTheMovieDbApikey    = configAccessor(stoservertypes.CfgTheMovieDbApikey)
	CfgIgdbApikey          = configAccessor(stoservertypes.CfgIgdbApikey)
	CfgFuseServerBaseUrl   = configAccessor(stoservertypes.CfgFuseServerBaseUrl)
	CfgNetworkShareBaseUrl = configAccessor(stoservertypes.CfgNetworkShareBaseUrl)
	CfgUbackupConfig       = configAccessor(stoservertypes.CfgUbackupConfig)
	CfgUpdateStatusAt      = configAccessor(stoservertypes.CfgUpdateStatusAt)
	CfgNodeTlsCertKey      = configAccessor(stoservertypes.CfgNodeTlsCertKey)
	CfgGrafanaUrl          = configAccessor(stoservertypes.CfgGrafanaUrl)
	CfgMediascannerState   = configAccessor(stoservertypes.CfgMediascannerState)
)
View Source
var (
	StartFromFirst = blorm.StartFromFirst
	StopIteration  = blorm.StopIteration
)

re-export so not all stodb-importing packages have to import blorm

View Source
var BlobRepository = register("Blob", blorm.NewSimpleRepo(
	"blobs",
	func() interface{} { return &stotypes.Blob{} },
	func(record interface{}) []byte { return record.(*stotypes.Blob).Ref }))
View Source
var BlobsPendingReplicationByVolumeIndex = blorm.NewValueIndex("repl_pend", BlobRepository, func(record interface{}, index func(val []byte)) {
	blob := record.(*stotypes.Blob)

	for _, volId := range blob.VolumesPendingReplication {
		index([]byte(fmt.Sprintf("%d", volId)))
	}
})
View Source
var ClientRepository = register("Client", blorm.NewSimpleRepo(
	"clients",
	func() interface{} { return &stotypes.Client{} },
	func(record interface{}) []byte { return []byte(record.(*stotypes.Client).ID) }))
View Source
var CollectionRepository = register("Collection", blorm.NewSimpleRepo(
	"collections",
	func() interface{} { return &stotypes.Collection{} },
	func(record interface{}) []byte { return []byte(record.(*stotypes.Collection).ID) }))
View Source
var CollectionsByDataEncryptionKeyIndex = blorm.NewValueIndex("dek", CollectionRepository, func(record interface{}, index func(val []byte)) {
	coll := record.(*stotypes.Collection)

	for _, dekEnvelopes := range coll.EncryptionKeys {
		index([]byte(dekEnvelopes.KeyId))
	}
})
View Source
var CollectionsByDirectoryIndex = blorm.NewValueIndex("directory", CollectionRepository, func(record interface{}, index func(val []byte)) {
	coll := record.(*stotypes.Collection)

	index([]byte(coll.Directory))
})
View Source
var CollectionsGlobalVersionIndex = blorm.NewRangeIndex("globalversion", CollectionRepository, func(record interface{}, index func(sortKey []byte)) {
	coll := record.(*stotypes.Collection)

	globalVersion := make([]byte, 8)
	binary.BigEndian.PutUint64(globalVersion, coll.GlobalVersion)

	index(globalVersion)
})
View Source
var DirectoryRepository = register("Directory", blorm.NewSimpleRepo(
	"directories",
	func() interface{} { return &stotypes.Directory{} },
	func(record interface{}) []byte { return []byte(record.(*stotypes.Directory).ID) }))
View Source
var IntegrityVerificationJobRepository = register("IntegrityVerificationJob", blorm.NewSimpleRepo(
	"ivjobs",
	func() interface{} { return &stotypes.IntegrityVerificationJob{} },
	func(record interface{}) []byte { return []byte(record.(*stotypes.IntegrityVerificationJob).ID) }))
View Source
var KeyEncryptionKeyRepository = register("KeyEncryptionKey", blorm.NewSimpleRepo(
	"keyencryptionkeys",
	func() interface{} { return &stotypes.KeyEncryptionKey{} },
	func(record interface{}) []byte { return []byte(record.(*stotypes.KeyEncryptionKey).ID) }))
View Source
var NodeRepository = register("Node", blorm.NewSimpleRepo(
	"nodes",
	func() interface{} { return &stotypes.Node{} },
	func(record interface{}) []byte { return []byte(record.(*stotypes.Node).ID) }))
View Source
var ReplicationPolicyRepository = register("ReplicationPolicy", blorm.NewSimpleRepo(
	"replicationpolicies",
	func() interface{} { return &stotypes.ReplicationPolicy{} },
	func(record interface{}) []byte { return []byte(record.(*stotypes.ReplicationPolicy).ID) }))
View Source
var RepoByRecordType = map[string]blorm.Repository{}

key is heading in export file under which all JSON records are dumped

View Source
var ScheduledJobRepository = register("ScheduledJob", blorm.NewSimpleRepo(
	"scheduledjobs",
	func() interface{} { return &stotypes.ScheduledJob{} },
	func(record interface{}) []byte { return []byte(record.(*stotypes.ScheduledJob).ID) }))
View Source
var SubdirectoriesIndex = blorm.NewValueIndex("parent", DirectoryRepository, func(record interface{}, index func(val []byte)) {
	dir := record.(*stotypes.Directory)

	if dir.Parent != "" {
		index([]byte(dir.Parent))
	}
})
View Source
var VolumeMountRepository = register("VolumeMount", blorm.NewSimpleRepo(
	"volumemounts",
	func() interface{} { return &stotypes.VolumeMount{} },
	func(record interface{}) []byte { return []byte(record.(*stotypes.VolumeMount).ID) }))
View Source
var VolumeRepository = register("Volume", blorm.NewSimpleRepo(
	"volumes",
	func() interface{} { return &stotypes.Volume{} },
	func(record interface{}) []byte {
		return volumeIntIdToBytes(record.(*stotypes.Volume).ID)
	}))

Functions

func Bootstrap

func Bootstrap(db *bbolt.DB, logger *log.Logger) error

func BootstrapRepos

func BootstrapRepos(tx *bbolt.Tx) error

func ClientAppender

func ClientAppender(slice *[]stotypes.Client) func(record interface{}) error

func IntegrityVerificationJobAppender

func IntegrityVerificationJobAppender(slice *[]stotypes.IntegrityVerificationJob) func(record interface{}) error

func KeyEncryptionKeyAppender

func KeyEncryptionKeyAppender(slice *[]stotypes.KeyEncryptionKey) func(record interface{}) error

func NodeAppender

func NodeAppender(slice *[]stotypes.Node) func(record interface{}) error

func Open

func Open(dbLocation string) (*bbolt.DB, error)

opens BoltDB database

func Read

func Read(tx *bbolt.Tx) *dbQueries

func ReadSchemaVersion

func ReadSchemaVersion(tx *bbolt.Tx) (uint32, error)

returns blorm.ErrBucketNotFound if version not found

func ReplicationPolicyAppender

func ReplicationPolicyAppender(slice *[]stotypes.ReplicationPolicy) func(record interface{}) error

func ScheduledJobAppender

func ScheduledJobAppender(slice *[]stotypes.ScheduledJob) func(record interface{}) error

func ScheduledJobSeedVersionUpdateCheck

func ScheduledJobSeedVersionUpdateCheck() *stotypes.ScheduledJob

func VolumeAppender

func VolumeAppender(slice *[]stotypes.Volume) func(record interface{}) error

func VolumeMountAppender

func VolumeMountAppender(slice *[]stotypes.VolumeMount) func(record interface{}) error

func WriteSchemaVersion

func WriteSchemaVersion(version uint32, tx *bbolt.Tx) error

Types

type ConfigAccessor

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

func (*ConfigAccessor) GetOptional

func (c *ConfigAccessor) GetOptional(tx *bbolt.Tx) (string, error)

func (*ConfigAccessor) GetRequired

func (c *ConfigAccessor) GetRequired(tx *bbolt.Tx) (string, error)

returns descriptive error message if value not set

func (*ConfigAccessor) Set

func (c *ConfigAccessor) Set(value string, tx *bbolt.Tx) error

type ConfigRequiredError

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

Jump to

Keyboard shortcuts

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