seaweedfs/weed/filer/arangodb/arangodb_store_bucket.go

41 lines
1 KiB
Go
Raw Normal View History

2022-03-18 02:12:25 +00:00
package arangodb
import (
"context"
"time"
"github.com/arangodb/go-driver"
"github.com/chrislusf/seaweedfs/weed/filer"
2022-03-18 02:12:25 +00:00
"github.com/chrislusf/seaweedfs/weed/glog"
)
var _ filer.BucketAware = (*ArangodbStore)(nil)
func (store *ArangodbStore) OnBucketCreation(bucket string) {
timeout, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
// create the collection && add to cache
_, err := store.ensureBucket(timeout, bucket)
if err != nil {
glog.V(0).Infof("bucket create %s : %w", bucket, err)
}
2022-03-18 02:12:25 +00:00
}
func (store *ArangodbStore) OnBucketDeletion(bucket string) {
timeout, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
collection, err := store.ensureBucket(timeout, bucket)
2022-03-18 02:12:25 +00:00
if err != nil {
glog.V(0).Infof("bucket delete %s : %w", bucket, err)
return
}
err = collection.Remove(timeout)
if err != nil && !driver.IsNotFound(err) {
glog.V(0).Infof("bucket delete %s : %w", bucket, err)
return
2022-03-18 02:12:25 +00:00
}
}
func (store *ArangodbStore) CanDropWholeBucket() bool {
return true
}