boltdb

package
v0.0.0-...-0490640 Latest Latest
Warning

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

Go to latest
Published: May 16, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package boltdb provides an implementation of DeploymentStore that uses boltdb. It can deal with multiple versions of how deployments are serialized to disk. Only the lastest version needs to provide an interface to write a deployment.

Versions:

  • v0: This version used gob to serialize most of the deployment. The dex config was serialized using protobuf.
  • v1: The deployment and the config are serialized using protobuf. The deployment and config live under separate keys in the v1 bucket.

Some reasons why a new version might be created:

  • Assumptions have been made that api.AutomateConfig will move in a compatible way. This means you can add fields and deprecate fields, but can never change the type or reuse a deprecated field. If this is ever needed, all of api.AutomateConfig will need to be redefined under one of the versions and a new version will likely need to be created.
  • The deployment struct changes and the types no longer map well. A new version can be created to reduce some of the complexity with how things get serialized, however old versions will still need to be able to read and mapped in a sane way.

- The way the buckets and keys are organized needs to change

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CurrentVersion

type CurrentVersion interface {
	UpgradeableVersion
	Initialize(*bolt.Tx) error
	WriteDeployment(*bolt.Tx, *deployment.Deployment) error
}

CurrentVersion represents the things the current storage version must be able to do

type DeploymentStore

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

DeploymentStore is a deployment store backed by boltdb

func NewDeploymentStore

func NewDeploymentStore(db *bolt.DB) *DeploymentStore

NewDeploymentStore wraps boltdb to be able to read the deployment from boltdb. It is expected that all migrations have already run before trying to use

func (*DeploymentStore) GetDeployment

func (s *DeploymentStore) GetDeployment() (*deployment.Deployment, error)

GetDeployment gets the deployment for deploymentID

func (*DeploymentStore) Initialize

func (s *DeploymentStore) Initialize() error

Initialize prepares the deployment store to be used. It MUST be called after creation, otherwise all calls to UpdateDeployment and GetDeployment will fail.

func (*DeploymentStore) TryRead

TryRead attempts to read the deployment store given the currently known versions.

func (*DeploymentStore) UpdateDeployment

UpdateDeployment receives the current version of the deployment and expects the caller to update it through the callback. This updated version will be committed to the database.

func (*DeploymentStore) WriteTo

func (s *DeploymentStore) WriteTo(w io.Writer) error

WriteTo writes a backup to the given io.Writer. The backup is created inside a boltdb read transaction for data consistency.

type UpgradeableVersion

type UpgradeableVersion interface {
	Name() string
	ReadDeployment(tx *bolt.Tx) (*deployment.Deployment, error)
	Cleanup(*bolt.Tx) error
}

UpgradeableVersion is a version that can be upgraded to the latest. Old versions should implement the UpgradeableVersion interface.

Directories

Path Synopsis
internal
v1

Jump to

Keyboard shortcuts

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