varasto: github.com/function61/varasto/pkg/stoserver/stodb Index | Files

package stodb

import "github.com/function61/varasto/pkg/stoserver/stodb"

Encapsulates access to the metadata database

Index

Package Files

bootstrap.go configaccessor.go configkeys.go dbqueries.go repositories.go scheduledjobseeddata.go schemaversion.go

Constants

const (
    CurrentSchemaVersion = 6
)

Variables

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)
)
var (
    StartFromFirst = blorm.StartFromFirst
    StopIteration  = blorm.StopIteration
)

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

var BlobRepository = register("Blob", blorm.NewSimpleRepo(
    "blobs",
    func() interface{} { return &stotypes.Blob{} },
    func(record interface{}) []byte { return record.(*stotypes.Blob).Ref }))
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)))
    }
})
var ClientRepository = register("Client", blorm.NewSimpleRepo(
    "clients",
    func() interface{} { return &stotypes.Client{} },
    func(record interface{}) []byte { return []byte(record.(*stotypes.Client).ID) }))
var CollectionRepository = register("Collection", blorm.NewSimpleRepo(
    "collections",
    func() interface{} { return &stotypes.Collection{} },
    func(record interface{}) []byte { return []byte(record.(*stotypes.Collection).ID) }))
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))
    }
})
var CollectionsByDirectoryIndex = blorm.NewValueIndex("directory", CollectionRepository, func(record interface{}, index func(val []byte)) {
    coll := record.(*stotypes.Collection)

    index([]byte(coll.Directory))
})
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)
})
var DirectoryRepository = register("Directory", blorm.NewSimpleRepo(
    "directories",
    func() interface{} { return &stotypes.Directory{} },
    func(record interface{}) []byte { return []byte(record.(*stotypes.Directory).ID) }))
var IntegrityVerificationJobRepository = register("IntegrityVerificationJob", blorm.NewSimpleRepo(
    "ivjobs",
    func() interface{} { return &stotypes.IntegrityVerificationJob{} },
    func(record interface{}) []byte { return []byte(record.(*stotypes.IntegrityVerificationJob).ID) }))
var KeyEncryptionKeyRepository = register("KeyEncryptionKey", blorm.NewSimpleRepo(
    "keyencryptionkeys",
    func() interface{} { return &stotypes.KeyEncryptionKey{} },
    func(record interface{}) []byte { return []byte(record.(*stotypes.KeyEncryptionKey).ID) }))
var NodeRepository = register("Node", blorm.NewSimpleRepo(
    "nodes",
    func() interface{} { return &stotypes.Node{} },
    func(record interface{}) []byte { return []byte(record.(*stotypes.Node).ID) }))
var ReplicationPolicyRepository = register("ReplicationPolicy", blorm.NewSimpleRepo(
    "replicationpolicies",
    func() interface{} { return &stotypes.ReplicationPolicy{} },
    func(record interface{}) []byte { return []byte(record.(*stotypes.ReplicationPolicy).ID) }))
var RepoByRecordType = map[string]blorm.Repository{}

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

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

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

func Bootstrap Uses

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

func BootstrapRepos Uses

func BootstrapRepos(tx *bbolt.Tx) error

func ClientAppender Uses

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

func IntegrityVerificationJobAppender Uses

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

func KeyEncryptionKeyAppender Uses

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

func NodeAppender Uses

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

func Open Uses

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

opens BoltDB database

func Read Uses

func Read(tx *bbolt.Tx) *dbQueries

func ReadSchemaVersion Uses

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

returns blorm.ErrBucketNotFound if version not found

func ReplicationPolicyAppender Uses

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

func ScheduledJobAppender Uses

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

func ScheduledJobSeedVersionUpdateCheck Uses

func ScheduledJobSeedVersionUpdateCheck() *stotypes.ScheduledJob

func VolumeAppender Uses

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

func VolumeMountAppender Uses

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

func WriteSchemaVersion Uses

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

type ConfigAccessor Uses

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

func (*ConfigAccessor) GetOptional Uses

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

func (*ConfigAccessor) GetRequired Uses

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

returns descriptive error message if value not set

func (*ConfigAccessor) Set Uses

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

type ConfigRequiredError Uses

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

Package stodb imports 16 packages (graph) and is imported by 4 packages. Updated 2020-09-07. Refresh now. Tools for package owners.