filerstore.go 2.0 KB

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