Skip to content

Commit

Permalink
refactor(asset): remove legacy GCS repository implementation
Browse files Browse the repository at this point in the history
- Deleted the old GCS repository code to streamline asset management.
- Updated the new repository implementation to align with the latest domain structure.
- Ensured compatibility with the new repository interface for improved modularity and maintainability.
  • Loading branch information
kasugamirai committed Dec 27, 2024
1 parent 6dbcc3a commit 7bacd36
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 176 deletions.
31 changes: 31 additions & 0 deletions asset/domain/repository/repository.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package repository

import (
"context"
"io"

"github.com/reearth/reearthx/asset/domain"
)

type Reader interface {
Read(ctx context.Context, id domain.ID) (*domain.Asset, error)
List(ctx context.Context) ([]*domain.Asset, error)
}

type Writer interface {
Create(ctx context.Context, asset *domain.Asset) error
Update(ctx context.Context, asset *domain.Asset) error
Delete(ctx context.Context, id domain.ID) error
}

type FileOperator interface {
Upload(ctx context.Context, id domain.ID, content io.Reader) error
Download(ctx context.Context, id domain.ID) (io.ReadCloser, error)
GetUploadURL(ctx context.Context, id domain.ID) (string, error)
}

type Repository interface {
Reader
Writer
FileOperator
}
175 changes: 0 additions & 175 deletions asset/gcs/repository.go

This file was deleted.

3 changes: 2 additions & 1 deletion asset/infrastructure/gcs/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"cloud.google.com/go/storage"
"github.com/reearth/reearthx/asset/domain"
"github.com/reearth/reearthx/asset/domain/repository"
"google.golang.org/api/iterator"
)

Expand All @@ -18,7 +19,7 @@ type Repository struct {
basePath string
}

var _ domain.Repository = (*Repository)(nil)
var _ repository.Repository = (*Repository)(nil)

func NewRepository(ctx context.Context, bucketName string) (*Repository, error) {
client, err := storage.NewClient(ctx)
Expand Down

0 comments on commit 7bacd36

Please sign in to comment.