From 96317743391ac87aeb07d292469e212671628437 Mon Sep 17 00:00:00 2001 From: Máximo Cuadros Date: Sat, 2 Feb 2019 10:14:24 +0100 Subject: storage: transactional, package documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Máximo Cuadros --- storage/transactional/storage.go | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'storage/transactional/storage.go') diff --git a/storage/transactional/storage.go b/storage/transactional/storage.go index 6611a43..fbb3d35 100644 --- a/storage/transactional/storage.go +++ b/storage/transactional/storage.go @@ -4,9 +4,12 @@ import ( "gopkg.in/src-d/go-git.v4/storage" ) -// Storage is an implementation of git.Storer that stores data on disk in the -// standard git format (this is, the .git directory). Zero values of this type -// are not safe to use, see the NewStorage function below. +// Storage is a transactional implementation of git.Storer, it demux the write +// and read operation of two separate storers, allowing to merge content calling +// Storage.Commit. +// +// The API and functionality of this package are considered EXPERIMENTAL and is +// not considered stable nor production ready. type Storage struct { s, temporal storage.Storer @@ -17,19 +20,23 @@ type Storage struct { *ConfigStorage } -func NewStorage(s, temporal storage.Storer) *Storage { +// NewStorage returns a new Storage based on two repositories, base is the base +// repository where the read operations are read and temportal is were all +// the write operations are stored. +func NewStorage(base, temporal storage.Storer) *Storage { return &Storage{ - s: s, + s: base, temporal: temporal, - ObjectStorage: NewObjectStorage(s, temporal), - ReferenceStorage: NewReferenceStorage(s, temporal), - IndexStorage: NewIndexStorage(s, temporal), - ShallowStorage: NewShallowStorage(s, temporal), - ConfigStorage: NewConfigStorage(s, temporal), + ObjectStorage: NewObjectStorage(base, temporal), + ReferenceStorage: NewReferenceStorage(base, temporal), + IndexStorage: NewIndexStorage(base, temporal), + ShallowStorage: NewShallowStorage(base, temporal), + ConfigStorage: NewConfigStorage(base, temporal), } } +// Module it honors the storage.ModuleStorer interface. func (s *Storage) Module(name string) (storage.Storer, error) { base, err := s.s.Module(name) if err != nil { @@ -44,6 +51,7 @@ func (s *Storage) Module(name string) (storage.Storer, error) { return NewStorage(base, temporal), nil } +// Commit it copies the content of the temporal storage into the base storage. func (s *Storage) Commit() error { for _, c := range []interface{ Commit() error }{ s.ObjectStorage, -- cgit