storage

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2016 License: Apache-2.0 Imports: 3 Imported by: 0

README

DynamoDB is the only intended storage solution for now. This directory/package exists mainly for file/code organization. It is a personal preference over having a ton of go files all in one directory. However, since it's being built with an interface, it does leave the door open for other storage options in the future.

Would that be so strange? DynamoDB was decided upon for a few reasons, but it may not work for all cases. A different solution may work better. This leaves the door open.

Also, configurations are meant to be shareable. If that's the case, then it's feasible that we would move a configuration from one storage solution to another.

Maybe we'll use other data stores like Cockroach DB in the future. Who knows. DynamoDB was just the obvious choice given the initial goals of the project (which included cost).

Or maybe it's just a local SQLite or file based storage. At that point it's not distributed... But maybe the tool can do a little more.

Documentation

Overview

Package storage contains the very important Shipper interface which is responsible for working with storage engines.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigState

func ConfigState(opts config.Options) (string, error)

ConfigState returns the config state (just a simple string message, could be "ACTIVE" for example)

func CreateConfig

func CreateConfig(opts config.Options, settings map[string]interface{}) (interface{}, error)

CreateConfig creates a new configuration returning success true/false along with any response and error.

func Delete

func Delete(opts config.Options) (config.Item, error)

Delete a key value in the configuration

func DeleteConfig

func DeleteConfig(opts config.Options) (interface{}, error)

DeleteConfig deletes an existing configuration

func Get

func Get(opts config.Options) (config.Item, error)

Get a key value in the configuration

func ListShippers

func ListShippers() map[string]Shipper

ListShippers returns the list of available shippers.

func Name

func Name(opts config.Options) string

Name returns the pretty display name for the shipper

func Options

func Options(opts config.Options) map[string]interface{}

Options returns various settings and options for the shipper

func RegisterShipper

func RegisterShipper(name string, shipper Shipper)

RegisterShipper allows anyone importing discfg into their own project to register new shippers or overwrite the defaults.

func Update

func Update(opts config.Options) (config.Item, error)

Update a key value in the configuration

func UpdateConfig

func UpdateConfig(opts config.Options, settings map[string]interface{}) (interface{}, error)

UpdateConfig updates the options/settings for a configuration (may not be implementd by each interface)

func UpdateConfigVersion

func UpdateConfigVersion(opts config.Options) error

UpdateConfigVersion updates the global discfg config version and modified timestamp (on the root key "/")

Types

type Shipper

type Shipper interface {
	CreateConfig(config.Options, map[string]interface{}) (interface{}, error)
	DeleteConfig(config.Options) (interface{}, error)
	UpdateConfig(config.Options, map[string]interface{}) (interface{}, error)
	ConfigState(config.Options) (string, error)
	Update(config.Options) (config.Item, error)
	Get(config.Options) (config.Item, error)
	Delete(config.Options) (config.Item, error)
	UpdateConfigVersion(config.Options) error
	Name(config.Options) string
	Options(config.Options) map[string]interface{}
}

Shipper can send information into a database or log etc. While DynamoDB is the planned data store, who knows what will happen in the future. A simple interface never hurts.

type ShipperResult

type ShipperResult struct {
	Interface string `json:"interface"`
	Error     error  `json:"error"`
}

ShipperResult contains errors and other information.

Directories

Path Synopsis
Package mock provides a mock storage Shipper interface for tests.
Package mock provides a mock storage Shipper interface for tests.

Jump to

Keyboard shortcuts

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