Skip to content

Commit

Permalink
Add support in POSIX
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCutter committed Aug 28, 2024
1 parent 5bdbdf4 commit 48de773
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions storage/posix/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ type Storage struct {

curSize uint64
newCP tessera.NewCPFunc

entriesPath tessera.EntriesPathFunc
}

// NewTreeFunc is the signature of a function which receives information about newly integrated trees.
Expand All @@ -66,10 +68,11 @@ func New(ctx context.Context, path string, curTree func() (uint64, []byte, error
opt := tessera.ResolveStorageOptions(nil, opts...)

r := &Storage{
path: path,
curSize: curSize,
curTree: curTree,
newCP: opt.NewCP,
path: path,
curSize: curSize,
curTree: curTree,
newCP: opt.NewCP,
entriesPath: opt.EntriesPath,
}
r.queue = storage.NewQueue(ctx, opt.BatchMaxAge, opt.BatchMaxSize, r.sequenceBatch)

Expand Down Expand Up @@ -124,7 +127,7 @@ func (s *Storage) Add(ctx context.Context, e *tessera.Entry) (uint64, error) {

// GetEntryBundle retrieves the Nth entries bundle for a log of the given size.
func (s *Storage) GetEntryBundle(ctx context.Context, index, logSize uint64) ([]byte, error) {
return os.ReadFile(filepath.Join(s.path, layout.EntriesPath(index, logSize)))
return os.ReadFile(filepath.Join(s.path, s.entriesPath(index, logSize)))
}

// sequenceBatch writes the entries from the provided batch into the entry bundle files of the log.
Expand Down Expand Up @@ -173,7 +176,7 @@ func (s *Storage) sequenceBatch(ctx context.Context, entries []*tessera.Entry) e
}
}
writeBundle := func(bundleIndex uint64) error {
bf := filepath.Join(s.path, layout.EntriesPath(bundleIndex, newSize))
bf := filepath.Join(s.path, s.entriesPath(bundleIndex, newSize))
if err := os.MkdirAll(filepath.Dir(bf), dirPerm); err != nil {
return fmt.Errorf("failed to make entries directory structure: %w", err)
}
Expand Down

0 comments on commit 48de773

Please sign in to comment.