You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.0 KiB

3 years ago
3 years ago
3 years ago
3 years ago
  1. package arangodb
  2. import (
  3. "context"
  4. "github.com/arangodb/go-driver"
  5. "time"
  6. "github.com/chrislusf/seaweedfs/weed/filer"
  7. "github.com/chrislusf/seaweedfs/weed/glog"
  8. )
  9. var _ filer.BucketAware = (*ArangodbStore)(nil)
  10. func (store *ArangodbStore) OnBucketCreation(bucket string) {
  11. timeout, cancel := context.WithTimeout(context.Background(), 10*time.Second)
  12. defer cancel()
  13. // create the collection && add to cache
  14. _, err := store.ensureBucket(timeout, bucket)
  15. if err != nil {
  16. glog.Errorf("bucket create %s: %v", bucket, err)
  17. }
  18. }
  19. func (store *ArangodbStore) OnBucketDeletion(bucket string) {
  20. timeout, cancel := context.WithTimeout(context.Background(), 10*time.Second)
  21. defer cancel()
  22. collection, err := store.ensureBucket(timeout, bucket)
  23. if err != nil {
  24. glog.Errorf("bucket delete %s: %v", bucket, err)
  25. return
  26. }
  27. err = collection.Remove(timeout)
  28. if err != nil && !driver.IsNotFound(err) {
  29. glog.Errorf("bucket delete %s: %v", bucket, err)
  30. return
  31. }
  32. }
  33. func (store *ArangodbStore) CanDropWholeBucket() bool {
  34. return true
  35. }