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

Commit

Permalink
Merge pull request #1098 from jmank88/bolt_cache
Browse files Browse the repository at this point in the history
gps: source cache: add persistent BoltDB cache
  • Loading branch information
jmank88 authored Sep 5, 2017
2 parents 57e95cc + 6a529db commit d3e738d
Show file tree
Hide file tree
Showing 360 changed files with 168,780 additions and 82 deletions.
14 changes: 13 additions & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@
[[constraint]]
name = "github.com/pkg/errors"
version = "0.8.0"

[[constraint]]
name = "github.com/boltdb/bolt"
version = "1.0.0"
12 changes: 1 addition & 11 deletions internal/gps/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,7 @@ func newSourceCoordinator(superv *supervisor, deducer deducer, cachedir string,
}
}

func (sc *sourceCoordinator) close() {
for k, v := range sc.srcs {
if err := v.close(); err != nil {
sc.logger.Println(errors.Wrapf(err, "error closing source gateway for %q", k))
}
}
}
func (sc *sourceCoordinator) close() {}

func (sc *sourceCoordinator) getSourceGatewayFor(ctx context.Context, id ProjectIdentifier) (*sourceGateway, error) {
if sc.supervisor.getLifetimeContext().Err() != nil {
Expand Down Expand Up @@ -211,10 +205,6 @@ func newSourceGateway(maybe maybeSource, superv *supervisor, cachedir string) *s
return sg
}

func (sg *sourceGateway) close() error {
return errors.Wrap(sg.cache.close(), "error closing cache")
}

func (sg *sourceGateway) syncLocal(ctx context.Context) error {
sg.mu.Lock()
defer sg.mu.Unlock()
Expand Down
41 changes: 0 additions & 41 deletions internal/gps/source_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ type singleSourceCache interface {
// If the input is a revision and multiple UnpairedVersions are associated
// with it, whatever happens to be the first is returned.
toUnpaired(v Version) (UnpairedVersion, bool)

// close closes the cache and any backing resources.
close() error
}

type singleSourceCacheMemory struct {
Expand All @@ -80,8 +77,6 @@ func newMemoryCache() singleSourceCache {
}
}

func (*singleSourceCacheMemory) close() error { return nil }

type projectInfo struct {
Manifest
Lock
Expand Down Expand Up @@ -225,39 +220,3 @@ func (c *singleSourceCacheMemory) toUnpaired(v Version) (UnpairedVersion, bool)
panic(fmt.Sprintf("unknown version type %T", v))
}
}

// cachedManifest implements RootManifest and is populated from cached data.
type cachedManifest struct {
constraints, overrides ProjectConstraints
ignored, required map[string]bool
}

func (m *cachedManifest) DependencyConstraints() ProjectConstraints {
return m.constraints
}

func (m *cachedManifest) Overrides() ProjectConstraints {
return m.overrides
}

func (m *cachedManifest) IgnoredPackages() map[string]bool {
return m.ignored
}

func (m *cachedManifest) RequiredPackages() map[string]bool {
return m.required
}

// cachedManifest implements Lock and is populated from cached data.
type cachedLock struct {
inputHash []byte
projects []LockedProject
}

func (l *cachedLock) InputHash() []byte {
return l.inputHash
}

func (l *cachedLock) Projects() []LockedProject {
return l.projects
}
Loading

0 comments on commit d3e738d

Please sign in to comment.