Skip to content
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

Merged
merged 2 commits into from
Jul 3, 2019

Conversation

jfontan
Copy link
Contributor

@jfontan jfontan commented Jun 28, 2019

Supports reading siva files created with borges when using

--format siva --non-rooted
  • I updated the documentation explaining the new behavior if any.
  • I updated CHANGELOG.md file adding the new feature or bug fix.
  • I updated go-mysql-server using make upgrade command if applicable.
  • I added or updated examples if applicable.
  • I checked that changes on schema are reflected into the documentation, if applicable.

Supports reading siva files created with borges when using

    --format siva --non-rooted

Signed-off-by: Javi Fontan <jfontan@gmail.com>
@jfontan jfontan requested review from a team June 28, 2019 12:20
@@ -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)
Copy link
Contributor

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 this nil in params I wonder, shall I pass sth. Or what this nil really means (defaults, nothing, etc.)

I know it's not really a part of this PR, but can we make this interface sth. like:

libraries.New().WithOptions(...)

// and maybe handy helper:
libraries.WithOption(...)

it will feel more like context.WithCancel(context.Background())
WDYT?

Copy link
Contributor Author

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 in go-borges to propose changing it. Now is the right moment to do so as we are changing the 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 to think how to unify options in some way and we could address this also in that process.

We could add a WithOptions or SetOptions to the Library 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?

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)
Copy link
Contributor

Choose a reason for hiding this comment

The 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(...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right now there are 4 types of libraries:

  • plain: holds normal repositores
  • siva: repositories in siva files, the new format
  • oldsiva: sivas generated by borges, old format
  • libraries: a meta library that can hold any other library.

Here we are generating libraries of different types depending on the options we get and adding it to the "meta library" rootLibrary. We could have added an AddSiva or AddOldsiva to the libraries.Library structure but it's meant to hold any structure that implements the interface borges.Library. I don't think that coupling libraries.Library with the already implemented types of library adds anything.

Copy link
Contributor

Choose a reason for hiding this comment

The 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 WithOptions(...)
and in siva, plain, ... you have have certain type's options, so library would be top level, and all types would define specific options.

@@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

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

I would try to get rid of this mysterious nil
how about sth. like context interface:

lib := library.New().WithOption(...).WithSiva(...)
//or
lib = library.WithOption(library.New())
lib = library.WithSiva(lib, sivaOpts)

WDYT?

@ajnavarro ajnavarro merged commit 05d963e into src-d:master Jul 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants