storage

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package storage implements storage interfaces for Stee.

Index

Constants

This section is empty.

Variables

View Source
var ErrMissingFilepath error = errors.New("cannot find parameter \"path\"")

ErrMissingFilepath happens when the filepath parameter is not passed to Open()

Functions

func Register

func Register(name string, factory StoreFactory) error

Register will register a new store type with its associated factory function.

Types

type Store

type Store interface {
	// Open initialize the store. (Could be opening a file or initiating a connection to a remote database)
	Open() error
	// Close closes the store. (Could be closing a file or closing a remote connection.)
	Close() error
	// ReadRedirection takes a redirection key and returns the redirection's target.
	ReadRedirection(key string) (target string, err error)
	// WriteRedirection writes a redirection to the store. Parameters are the key and the target.
	WriteRedirection(key string, target string) error
	// DeleteRedirection deletes a redirection from the store. it Takes the key as argument.
	DeleteRedirection(key string) error
}

Store is an interface representing the possible interactions with a storage. When working with a Store, you should always open it before use and close it after use.

type StoreFactory

type StoreFactory func(v *viper.Viper) (Store, error)

StoreFactory if a factory function to create a new store.

func GetFactory

func GetFactory(name string) (StoreFactory, error)

GetFactory returns the factory function associated with a store type.

Jump to

Keyboard shortcuts

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