Skip to content

Commit

Permalink
Add support in GCP
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCutter committed Aug 28, 2024
1 parent 5ee1fd6 commit 5bdbdf4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
20 changes: 11 additions & 9 deletions storage/gcp/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ type Storage struct {
projectID string
bucket string

newCP tessera.NewCPFunc
newCP tessera.NewCPFunc
entriesPath tessera.EntriesPathFunc

sequencer sequencer
objStore objStore
Expand Down Expand Up @@ -129,12 +130,13 @@ func New(ctx context.Context, cfg Config, opts ...func(*tessera.StorageOptions))
}

r := &Storage{
gcsClient: c,
projectID: cfg.ProjectID,
bucket: cfg.Bucket,
objStore: gcsStorage,
sequencer: seq,
newCP: opt.NewCP,
gcsClient: c,
projectID: cfg.ProjectID,
bucket: cfg.Bucket,
objStore: gcsStorage,
sequencer: seq,
newCP: opt.NewCP,
entriesPath: opt.EntriesPath,
}
r.queue = storage.NewQueue(ctx, opt.BatchMaxAge, opt.BatchMaxSize, r.sequencer.assignEntries)

Expand Down Expand Up @@ -229,7 +231,7 @@ func (s *Storage) getTiles(ctx context.Context, tileIDs []storage.TileID, logSiz
//
// Returns a wrapped os.ErrNotExist if the bundle does not exist.
func (s *Storage) getEntryBundle(ctx context.Context, bundleIndex uint64, logSize uint64) ([]byte, error) {
objName := layout.EntriesPath(bundleIndex, logSize)
objName := s.entriesPath(bundleIndex, logSize)
data, _, err := s.objStore.getObject(ctx, objName)
if err != nil {
if errors.Is(err, gcs.ErrObjectNotExist) {
Expand All @@ -245,7 +247,7 @@ func (s *Storage) getEntryBundle(ctx context.Context, bundleIndex uint64, logSiz

// setEntryBundle idempotently stores the serialised entry bundle at the location implied by the bundleIndex and treeSize.
func (s *Storage) setEntryBundle(ctx context.Context, bundleIndex uint64, logSize uint64, bundleRaw []byte) error {
objName := layout.EntriesPath(bundleIndex, logSize)
objName := s.entriesPath(bundleIndex, logSize)
// Note that setObject does an idempotent interpretation of DoesNotExist - it only
// returns an error if the named object exists _and_ contains different data to what's
// passed in here.
Expand Down
3 changes: 2 additions & 1 deletion storage/gcp/gcp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ func TestBundleRoundtrip(t *testing.T) {
ctx := context.Background()
m := newMemObjStore()
s := &Storage{
objStore: m,
objStore: m,
entriesPath: layout.EntriesPath,
}

for _, test := range []struct {
Expand Down

0 comments on commit 5bdbdf4

Please sign in to comment.