filerstore.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package filer
  2. import (
  3. "context"
  4. "errors"
  5. "github.com/seaweedfs/seaweedfs/weed/util"
  6. "io"
  7. )
  8. const CountEntryChunksForGzip = 50
  9. var (
  10. ErrUnsupportedListDirectoryPrefixed = errors.New("unsupported directory prefix listing")
  11. ErrUnsupportedSuperLargeDirectoryListing = errors.New("unsupported super large directory listing")
  12. ErrKvNotImplemented = errors.New("kv not implemented yet")
  13. ErrKvNotFound = errors.New("kv: not found")
  14. )
  15. type ListEachEntryFunc func(entry *Entry) bool
  16. type FilerStore interface {
  17. // GetName gets the name to locate the configuration in filer.toml file
  18. GetName() string
  19. // Initialize initializes the file store
  20. Initialize(configuration util.Configuration, prefix string) error
  21. InsertEntry(context.Context, *Entry) error
  22. UpdateEntry(context.Context, *Entry) (err error)
  23. // err == filer_pb.ErrNotFound if not found
  24. FindEntry(context.Context, util.FullPath) (entry *Entry, err error)
  25. DeleteEntry(context.Context, util.FullPath) (err error)
  26. DeleteFolderChildren(context.Context, util.FullPath) (err error)
  27. ListDirectoryEntries(ctx context.Context, dirPath util.FullPath, startFileName string, includeStartFile bool, limit int64, eachEntryFunc ListEachEntryFunc) (lastFileName string, err error)
  28. ListDirectoryPrefixedEntries(ctx context.Context, dirPath util.FullPath, startFileName string, includeStartFile bool, limit int64, prefix string, eachEntryFunc ListEachEntryFunc) (lastFileName string, err error)
  29. BeginTransaction(ctx context.Context) (context.Context, error)
  30. CommitTransaction(ctx context.Context) error
  31. RollbackTransaction(ctx context.Context) error
  32. KvPut(ctx context.Context, key []byte, value []byte) (err error)
  33. KvGet(ctx context.Context, key []byte) (value []byte, err error)
  34. KvDelete(ctx context.Context, key []byte) (err error)
  35. Shutdown()
  36. }
  37. type BucketAware interface {
  38. OnBucketCreation(bucket string)
  39. OnBucketDeletion(bucket string)
  40. CanDropWholeBucket() bool
  41. }
  42. type Debuggable interface {
  43. Debug(writer io.Writer)
  44. }