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

gps: source cache: add persistent BoltDB cache #1098

Merged
merged 6 commits into from
Sep 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
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