From 4de510778b6e55a2238374834d00b03726da76d4 Mon Sep 17 00:00:00 2001 From: Laria Carolin Chabowski Date: Tue, 3 Oct 2017 14:59:45 +0200 Subject: Documentation --- storage/cloud/swift.go | 2 ++ storage/filter/filter.go | 15 +++++++++++++++ storage/local/local.go | 7 +++++++ storage/memory/memory.go | 3 +++ 4 files changed, 27 insertions(+) (limited to 'storage') diff --git a/storage/cloud/swift.go b/storage/cloud/swift.go index a721f67..f08b1cc 100644 --- a/storage/cloud/swift.go +++ b/storage/cloud/swift.go @@ -35,6 +35,8 @@ type SwiftConfig struct { Timeout string `toml:"timeout,omitempty"` } +// SwiftStorageCreator creates an object storage that saves the objects to an openstack swift storage. +// Use the method "openstack-swift" in your config and refer to the `SwiftConfig` structure for additional config keys. func SwiftStorageCreator() storage.CreateStorageFromConfig { return cloudStorageCreator(func(conf config.Config, name string) (CloudStorage, error) { var storage_conf SwiftConfig diff --git a/storage/filter/filter.go b/storage/filter/filter.go index 52ecbfd..1628c1e 100644 --- a/storage/filter/filter.go +++ b/storage/filter/filter.go @@ -34,6 +34,21 @@ func (pf PipeFilter) Transform(b []byte) ([]byte, error) { return buf.Bytes(), nil } +// FilterSorage is a storage implementation wrapping around another storage, sending each raw object through an extrenal +// binary for custom de/encoding (think encryption, compression, ...). +// +// It is used in a configuration by using the method "filter". It needs the config key "base" referencing the name of +// another configured storage. Also needed are the string lists "decode" and "encode", describing which binary to call +// with which parameters. +// +// For example, here is a configuration for a filter storage wrapping a storage "foo", +// encrypting the content with gpg for the key "foobar" +// +// [storage.foo_encrypted] +// method="filter" +// base="foo" +// encode=["gpg", "--encrypt", "--recipient", "foobar"] +// decode=["gpg", "--decrypt"] type FilterStorage struct { Base storage.Storage Decode, Encode Filter diff --git a/storage/local/local.go b/storage/local/local.go index 7dc59cb..ae39eb5 100644 --- a/storage/local/local.go +++ b/storage/local/local.go @@ -20,6 +20,13 @@ func objectDir(id objects.ObjectId) string { return joinPath(string(id.Algo), hex.EncodeToString(id.Sum[0:1])) } +// LocalStorage is a storage implementation that saves your objects on your local filesystem. +// +// Example config: +// +// [storage.local_test] +// method="local" +// path="~/.local/share/petrific" # Save the objects here type LocalStorage struct { Path string index storage.Index diff --git a/storage/memory/memory.go b/storage/memory/memory.go index e73c51a..dc72f70 100644 --- a/storage/memory/memory.go +++ b/storage/memory/memory.go @@ -6,6 +6,9 @@ import ( "code.laria.me/petrific/storage" ) +// Memory storage is an in-memory storage. It is rather useless when using petrific, it is mostly used for internal testing. +// But if you want to use the memory storage anyway, you can do that by putting a storage section with the method +// "memory" in your config file type MemoryStorage struct { objects map[string][]byte bytype map[objects.ObjectType][]objects.ObjectId -- cgit v1.2.3-70-g09d2