-
Notifications
You must be signed in to change notification settings - Fork 9
/
in_memory_output_path_factory.go
60 lines (52 loc) · 2.12 KB
/
in_memory_output_path_factory.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package virtual
import (
"context"
"github.com/buildbarn/bb-remote-execution/pkg/filesystem"
"github.com/buildbarn/bb-remote-execution/pkg/filesystem/virtual"
"github.com/buildbarn/bb-storage/pkg/clock"
"github.com/buildbarn/bb-storage/pkg/digest"
"github.com/buildbarn/bb-storage/pkg/filesystem/path"
"github.com/buildbarn/bb-storage/pkg/util"
)
type inMemoryOutputPathFactory struct {
filePool filesystem.FilePool
symlinkFactory virtual.SymlinkFactory
handleAllocator virtual.StatefulHandleAllocator
initialContentsSorter virtual.Sorter
clock clock.Clock
}
// NewInMemoryOutputPathFactory creates an OutputPathFactory that simply
// creates output paths that store all of their data in memory.
func NewInMemoryOutputPathFactory(filePool filesystem.FilePool, symlinkFactory virtual.SymlinkFactory, handleAllocator virtual.StatefulHandleAllocator, initialContentsSorter virtual.Sorter, clock clock.Clock) OutputPathFactory {
return &inMemoryOutputPathFactory{
filePool: filePool,
symlinkFactory: symlinkFactory,
handleAllocator: handleAllocator,
initialContentsSorter: initialContentsSorter,
clock: clock,
}
}
func (opf *inMemoryOutputPathFactory) StartInitialBuild(outputBaseID path.Component, casFileFactory virtual.CASFileFactory, digestFunction digest.Function, errorLogger util.ErrorLogger) OutputPath {
return inMemoryOutputPath{
PrepopulatedDirectory: virtual.NewInMemoryPrepopulatedDirectory(
virtual.NewHandleAllocatingFileAllocator(
virtual.NewPoolBackedFileAllocator(
opf.filePool,
errorLogger),
opf.handleAllocator),
opf.symlinkFactory,
errorLogger,
opf.handleAllocator,
opf.initialContentsSorter,
/* hiddenFilesMatcher = */ func(string) bool { return false },
opf.clock),
}
}
func (opf *inMemoryOutputPathFactory) Clean(outputBaseID path.Component) error {
// No persistent state associated with in-memory output paths.
return nil
}
type inMemoryOutputPath struct {
virtual.PrepopulatedDirectory
}
func (op inMemoryOutputPath) FinalizeBuild(ctx context.Context, digestFunction digest.Function) {}