From 0af572dd21c0aa79d13745b633ee24ba6c4d6cf1 Mon Sep 17 00:00:00 2001 From: "Santiago M. Mola" Date: Wed, 14 Dec 2016 23:12:44 +0100 Subject: move plumbing from top level package to plumbing (#183) * plumbing: rename Object -> EncodedObject. * plumbing/storer: rename ObjectStorer -> EncodedObjectStorer. * move difftree to plumbing/difftree. * move diff -> utils/diff * make Object/Tag/Blob/Tree/Commit/File depend on storer. * Object and its implementations now depend only on storer.EncodedObjectStorer, not git.Repository. * Tests are decoupled accordingly. * move Object/Commit/File/Tag/Tree to plumbing/object. * move Object/Commit/File/Tag/Tree to plumbing/object. * move checkClose to utils/ioutil. * move RevListObjects to plumbing/revlist.Objects. * move DiffTree to plumbing/difftree package. * rename files with plural nouns to singular * plumbing/object: add GetBlob/GetCommit/GetTag/GetTree. --- examples/storage/aerospike/storage.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'examples/storage') diff --git a/examples/storage/aerospike/storage.go b/examples/storage/aerospike/storage.go index a1d8c00..87d4a29 100644 --- a/examples/storage/aerospike/storage.go +++ b/examples/storage/aerospike/storage.go @@ -33,11 +33,11 @@ func NewStorage(client *driver.Client, ns, url string) (*Storage, error) { return &Storage{client: client, ns: ns, url: url}, nil } -func (s *Storage) NewObject() plumbing.Object { +func (s *Storage) NewEncodedObject() plumbing.EncodedObject { return &plumbing.MemoryObject{} } -func (s *Storage) SetObject(obj plumbing.Object) (plumbing.Hash, error) { +func (s *Storage) SetEncodedObject(obj plumbing.EncodedObject) (plumbing.Hash, error) { key, err := s.buildKey(obj.Hash(), obj.Type()) if err != nil { return obj.Hash(), err @@ -64,7 +64,7 @@ func (s *Storage) SetObject(obj plumbing.Object) (plumbing.Hash, error) { return obj.Hash(), err } -func (s *Storage) Object(t plumbing.ObjectType, h plumbing.Hash) (plumbing.Object, error) { +func (s *Storage) EncodedObject(t plumbing.ObjectType, h plumbing.Hash) (plumbing.EncodedObject, error) { key, err := s.buildKey(h, t) if err != nil { return nil, err @@ -82,7 +82,7 @@ func (s *Storage) Object(t plumbing.ObjectType, h plumbing.Hash) (plumbing.Objec return objectFromRecord(rec, t) } -func (s *Storage) IterObjects(t plumbing.ObjectType) (storer.ObjectIter, error) { +func (s *Storage) IterEncodedObjects(t plumbing.ObjectType) (storer.EncodedObjectIter, error) { stmnt := driver.NewStatement(s.ns, t.String()) err := stmnt.Addfilter(driver.NewEqualFilter(urlField, s.url)) @@ -91,19 +91,19 @@ func (s *Storage) IterObjects(t plumbing.ObjectType) (storer.ObjectIter, error) return nil, err } - return &ObjectIter{t, rs.Records}, nil + return &EncodedObjectIter{t, rs.Records}, nil } func (s *Storage) buildKey(h plumbing.Hash, t plumbing.ObjectType) (*driver.Key, error) { return driver.NewKey(s.ns, t.String(), fmt.Sprintf("%s|%s", s.url, h.String())) } -type ObjectIter struct { +type EncodedObjectIter struct { t plumbing.ObjectType ch chan *driver.Record } -func (i *ObjectIter) Next() (plumbing.Object, error) { +func (i *EncodedObjectIter) Next() (plumbing.EncodedObject, error) { r := <-i.ch if r == nil { return nil, io.EOF @@ -112,7 +112,7 @@ func (i *ObjectIter) Next() (plumbing.Object, error) { return objectFromRecord(r, i.t) } -func (i *ObjectIter) ForEach(cb func(obj plumbing.Object) error) error { +func (i *EncodedObjectIter) ForEach(cb func(obj plumbing.EncodedObject) error) error { for { obj, err := i.Next() if err != nil { @@ -133,9 +133,9 @@ func (i *ObjectIter) ForEach(cb func(obj plumbing.Object) error) error { } } -func (i *ObjectIter) Close() {} +func (i *EncodedObjectIter) Close() {} -func objectFromRecord(r *driver.Record, t plumbing.ObjectType) (plumbing.Object, error) { +func objectFromRecord(r *driver.Record, t plumbing.ObjectType) (plumbing.EncodedObject, error) { content := r.Bins["blob"].([]byte) o := &plumbing.MemoryObject{} -- cgit