-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gitbase: update go-borges and support old siva files #911
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ import ( | |
"github.com/sirupsen/logrus" | ||
"github.com/src-d/go-borges" | ||
"github.com/src-d/go-borges/libraries" | ||
"github.com/src-d/go-borges/oldsiva" | ||
"github.com/src-d/go-borges/plain" | ||
"github.com/src-d/go-borges/siva" | ||
sqle "github.com/src-d/go-mysql-server" | ||
|
@@ -227,7 +228,7 @@ func (c *Server) buildDatabase() error { | |
|
||
c.sharedCache = cache.NewObjectLRU(c.CacheSize * cache.MiByte) | ||
|
||
c.rootLibrary = libraries.New(libraries.Options{}) | ||
c.rootLibrary = libraries.New(nil) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would try to get rid of this mysterious lib := library.New().WithOption(...).WithSiva(...)
//or
lib = library.WithOption(library.New())
lib = library.WithSiva(lib, sivaOpts) WDYT? |
||
c.pool = gitbase.NewRepositoryPool(c.sharedCache, c.rootLibrary) | ||
|
||
if err := c.addDirectories(); err != nil { | ||
|
@@ -318,18 +319,34 @@ func (c *Server) addDirectories() error { | |
|
||
func (c *Server) addDirectory(d directory) error { | ||
if d.Format == "siva" { | ||
sivaOpts := siva.LibraryOptions{ | ||
Transactional: true, | ||
RootedRepo: d.Rooted, | ||
Cache: c.sharedCache, | ||
Bucket: d.Bucket, | ||
Performance: true, | ||
RegistryCache: 100000, | ||
} | ||
var lib borges.Library | ||
var err error | ||
|
||
if d.Rooted { | ||
sivaOpts := &siva.LibraryOptions{ | ||
Transactional: true, | ||
RootedRepo: d.Rooted, | ||
Cache: c.sharedCache, | ||
Bucket: d.Bucket, | ||
Performance: true, | ||
RegistryCache: 100000, | ||
} | ||
|
||
lib, err := siva.NewLibrary(d.Path, osfs.New(d.Path), sivaOpts) | ||
if err != nil { | ||
return err | ||
lib, err = siva.NewLibrary(d.Path, osfs.New(d.Path), sivaOpts) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so maybe we can combine these 2 libs, e.g.: lib := library.New()
//....
lib = library.WithSiva(lib, sivaOpts)
// or lib = lib.WithSiva(sivaOpts)
// or lib = lib.WithSiva(...).WithOldSiva(...) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right now there are 4 types of libraries:
Here we are generating libraries of different types depending on the options we get and adding it to the "meta library" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just my taste, so no worries. In this case I thought we may have |
||
if err != nil { | ||
return err | ||
} | ||
} else { | ||
sivaOpts := &oldsiva.LibraryOptions{ | ||
Cache: c.sharedCache, | ||
Bucket: d.Bucket, | ||
RegistryCache: 100000, | ||
} | ||
|
||
lib, err = oldsiva.NewLibrary(d.Path, osfs.New(d.Path), sivaOpts) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
|
||
err = c.rootLibrary.Add(lib) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This enigmatic
nil
looks so, so for me (and under the hood you check if it's a nil to create an empty option. Always when I see thisnil
in params I wonder, shall I pass sth. Or what thisnil
really means (defaults, nothing, etc.)I know it's not really a part of this PR, but can we make this interface sth. like:
it will feel more like
context.WithCancel(context.Background())
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original
plain
storage used this system so we changed the rest to be more homogeneous. We can open an issue ingo-borges
to propose changing it. Now is the right moment to do so as we are changing the interface.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have to think how to unify options in some way and we could address this also in that process.
We could add a
WithOptions
orSetOptions
to theLibrary
interface but I'm not sure if this is something that should belong to there.Personally, I don't like chain functions/methods calls. I'd rather add specific constructors
NewWithOptions
to add custom options if you need to work with no default options.@jfontan shall we open an issue to discuss it there?