filerstore.go 1.8 KB

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