Skip to content

Commit 70ad58e

Browse files
committed
fix(staging): revert to concrete return types, add interface conformance checks
1 parent f9108ee commit 70ad58e

4 files changed

Lines changed: 11 additions & 4 deletions

File tree

flow/connectors/utils/staging.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ import (
55
"io"
66
)
77

8+
var (
9+
_ StagingStore = (*S3StagingStore)(nil)
10+
_ StagingStore = (*GCSStagingStore)(nil)
11+
)
12+
813
// StagingStore abstracts cloud storage used by PeerDB's ClickHouse connector
914
// for staging Avro files. Files are written by PeerDB and read by ClickHouse
1015
// via table functions (s3(), url(), etc.).

flow/connectors/utils/staging_gcs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type GCSStagingStore struct {
2626
fullPath string
2727
}
2828

29-
func NewGCSStagingStore(ctx context.Context, bucketPath string) (StagingStore, error) {
29+
func NewGCSStagingStore(ctx context.Context, bucketPath string) (*GCSStagingStore, error) {
3030
// bucketPath is "gcs://bucket/prefix" or just "bucket/prefix"
3131
path := strings.TrimPrefix(bucketPath, "gcs://")
3232
path = strings.TrimPrefix(path, "gs://")

flow/connectors/utils/staging_s3.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type S3StagingStore struct {
2424
fullPath string // original "s3://bucket/prefix" for logging
2525
}
2626

27-
func NewS3StagingStore(bucketPath string, creds AWSCredentialsProvider) (StagingStore, error) {
27+
func NewS3StagingStore(bucketPath string, creds AWSCredentialsProvider) (*S3StagingStore, error) {
2828
s3o, err := NewS3BucketAndPrefix(bucketPath)
2929
if err != nil {
3030
return nil, fmt.Errorf("failed to parse S3 bucket path: %w", err)

flow/connectors/utils/staging_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ func TestNewS3StagingStore(t *testing.T) {
1919

2020
store, err := NewS3StagingStore("s3://my-bucket/some/prefix", creds)
2121
require.NoError(t, err)
22+
require.Equal(t, "my-bucket", store.Bucket())
23+
require.Equal(t, "some/prefix", store.Prefix())
2224
require.Equal(t, "some/prefix", store.KeyPrefix())
2325
require.Equal(t, "s3://my-bucket/some/prefix", store.BucketPath())
2426
}
@@ -92,6 +94,6 @@ func TestNewS3StagingStoreNoBucket(t *testing.T) {
9294

9395
store, err := NewS3StagingStore("s3://bucket-only", creds)
9496
require.NoError(t, err)
95-
require.Equal(t, "s3://bucket-only", store.BucketPath())
96-
require.Empty(t, store.KeyPrefix())
97+
require.Equal(t, "bucket-only", store.Bucket())
98+
require.Empty(t, store.Prefix())
9799
}

0 commit comments

Comments
 (0)