edge/pkg/storage/rpc/server/blob_store.go

55 lines
1015 B
Go

package server
import (
"context"
"forge.cadoles.com/arcad/edge/pkg/storage"
"github.com/pkg/errors"
"gitlab.com/wpetit/goweb/logger"
)
type BlobStore struct {
store storage.BlobStore
}
type DeleteBucketArgs struct {
Name string
}
type DeleteBucketReply struct {
}
func (s *BlobStore) DeleteBucket(ctx context.Context, args *DeleteBucketArgs, reply *DeleteBucketReply) error {
return nil
}
type OpenBucketArgs struct {
Name string
}
type OpenBucketReply struct {
BucketName string
}
func (s *BlobStore) OpenBucket(ctx context.Context, args *OpenBucketArgs, reply *OpenBucketReply) error {
bucket, err := s.store.OpenBucket(ctx, args.Name)
if err != nil {
return errors.WithStack(err)
}
defer func() {
if err := bucket.Close(); err != nil {
logger.Error(ctx, "could not close bucket", logger.E(errors.WithStack(err)))
}
}()
*reply = OpenBucketReply{
BucketName: bucket.Name(),
}
return nil
}
func NewBlobStore(store storage.BlobStore) *BlobStore {
return &BlobStore{store}
}