Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

global storage interface refactor #112

Merged
merged 8 commits into from
Nov 7, 2016
Merged

global storage interface refactor #112

merged 8 commits into from
Nov 7, 2016

Conversation

mcuadros
Copy link
Contributor

@mcuadros mcuadros commented Nov 4, 2016

Renames:

  • core.ObjectStorage => core.ObjectStorer
  • core.ReferenceStorage => core.ReferenceStorer
  • config.ConfigStorage => core.ConfigStorer
  • config.Storage => core.Storer
  • core.ObjectStorageWriter => core.PackfileWriter

All the inner methods now are compatible between all the *Storer interfaces. The main git.Storage now is just a group of all the others *Storer interfaces.

A new core.ObjectStorerTxwas create with the goal of having optional transactions in the storers

The config.Storer was simplified to only two methods SetConfig and Config

}

func (d *Decoder) readObjects(count uint32) error {
for i := 0; i < int(count); i++ {
func (d *Decoder) readObjectsWithObjectStorer(count int) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the name should be readObjectsToObjectStorer, To instead of With.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's because you have another readObjects without a s.o set (the core.ObjectStorer), I think is clear enough being in the context (is a deep one)

@@ -11,41 +11,46 @@ var (
ErrNotImplemented = errors.New("method not-implemented")
)

// ObjectStorage generic storage of objects
type ObjectStorage interface {
// ObjectStorer generic storage of objects
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change the comment to include the word persist, as the other storers.

Copy link
Contributor Author

@mcuadros mcuadros Nov 7, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as we agreed, persistent is not a property intrinsic to a ObjectStorer

// Iter returns a custom ObjectIter over all the object on the storage.
// TreeObject and AnyObject. If AnyObject is given, the object must be
// looked up regardless of its type.
GetObject(ObjectType, Hash) (Object, error)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be called Object instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure


// ObjectStorerTx is a optional method for ObjectStorer, it enable transaction
// base write and read operations in the storage
type ObjectStorerTx interface {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are going too far with the naming of this types, I suggest naming this Tx and move it to an store/object package.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

having another package for a interface maybe is too much. Maybe just call the interface Transactional?

// ErrNotImplemented error.
// PackfileWriter is a optional method for ObjectStorer, it enable direct write
// of packfile to the storage
type PackfileWriter interface {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interface and method with the same name: we need to rethink how to organize or code.

Get(ObjectType, Hash) (Object, error)
// TxObjectStorer is an in-progress storage transaction. A transaction must end
// with a call to Commit or Rollback.
type TxObjectStorer interface {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have an ObjectStorerTx interface and a TxObjectStorer interface.

We must step back, think and organize the code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also we must split all this concepts in their own files.

@@ -2,19 +2,14 @@
package filesystem

import (
"gopkg.in/src-d/go-git.v4/config"
"gopkg.in/src-d/go-git.v4/core"
"gopkg.in/src-d/go-git.v4/storage/filesystem/internal/dotgit"
"gopkg.in/src-d/go-git.v4/utils/fs"
)

type Storage struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs comments, is this an implementation of Storer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, done

@@ -12,94 +12,46 @@ var ErrUnsupportedObjectType = fmt.Errorf("unsupported object type")

// Storage in memory storage system
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence doesn't have any verb.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


"gopkg.in/src-d/go-git.v4/config"
"gopkg.in/src-d/go-git.v4/core"

. "gopkg.in/check.v1"
)

type storer interface {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a comment. Why is this type needed, how it is different than Storer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is part of the public suite test. If we make reference here to Storer at the main package we will get a cyclic dependency

ConfigStorage() config.ConfigStorage
ObjectStorage() core.ObjectStorage
ReferenceStorage() core.ReferenceStorage
// Storer storage of objects, references and all the information that require
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence makes no sense, it has no verb.

Also, is this comment accurate?, does the memory implementation persist data?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@mcuadros mcuadros merged commit 5a72b12 into src-d:master Nov 7, 2016
@mcuadros mcuadros deleted the storer branch December 13, 2016 10:13
mcuadros added a commit that referenced this pull request Jan 31, 2017
* core: ObjectStorage, ReferenceStorage renamed to ObjectStorer and
ReferenceStorer

* rebase

* general, changes request by @alcortes

* general, changes request by @alcortes
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants