58 lines
1.2 KiB
Go
58 lines
1.2 KiB
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/keegancsmith/rpc"
|
|
|
|
"forge.cadoles.com/arcad/edge/pkg/storage"
|
|
"forge.cadoles.com/arcad/edge/pkg/storage/rpc/server"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
type BlobStore struct {
|
|
client *rpc.Client
|
|
}
|
|
|
|
// DeleteBucket implements storage.BlobStore.
|
|
func (s *BlobStore) DeleteBucket(ctx context.Context, name string) error {
|
|
args := &server.DeleteBucketArgs{
|
|
Name: name,
|
|
}
|
|
|
|
if err := s.client.Call(ctx, "BlobStore.DeleteBucket", args, nil); err != nil {
|
|
return errors.WithStack(err)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// ListBuckets implements storage.BlobStore.
|
|
func (s *BlobStore) ListBuckets(ctx context.Context) ([]string, error) {
|
|
panic("unimplemented")
|
|
}
|
|
|
|
// OpenBucket implements storage.BlobStore.
|
|
func (s *BlobStore) OpenBucket(ctx context.Context, name string) (storage.BlobBucket, error) {
|
|
args := &server.OpenBucketArgs{
|
|
Name: name,
|
|
}
|
|
reply := &server.OpenBucketReply{}
|
|
|
|
if err := s.client.Call(ctx, "BlobStore.OpenBucket", args, reply); err != nil {
|
|
return nil, errors.WithStack(err)
|
|
}
|
|
|
|
return &BlobBucket{
|
|
name: reply.BucketName,
|
|
closed: false,
|
|
client: s.client,
|
|
}, nil
|
|
}
|
|
|
|
func NewBlobStore(client *rpc.Client) *BlobStore {
|
|
return &BlobStore{client}
|
|
}
|
|
|
|
var _ storage.BlobStore = &BlobStore{}
|