2020-09-01 00:21:19 -07:00
|
|
|
package filer
|
2018-05-25 23:27:06 -07:00
|
|
|
|
2018-05-26 03:49:46 -07:00
|
|
|
import (
|
2019-03-15 15:55:34 -07:00
|
|
|
"context"
|
2020-09-01 21:58:57 -07:00
|
|
|
"errors"
|
2018-08-19 15:17:55 -07:00
|
|
|
"github.com/chrislusf/seaweedfs/weed/util"
|
2018-05-26 03:49:46 -07:00
|
|
|
)
|
2018-05-25 23:27:06 -07:00
|
|
|
|
2020-09-01 21:58:57 -07:00
|
|
|
var (
|
2020-12-22 02:26:05 -08:00
|
|
|
ErrUnsupportedListDirectoryPrefixed = errors.New("unsupported directory prefix listing")
|
|
|
|
ErrUnsupportedSuperLargeDirectoryListing = errors.New("unsupported super large directory listing")
|
|
|
|
ErrKvNotImplemented = errors.New("kv not implemented yet")
|
|
|
|
ErrKvNotFound = errors.New("kv: not found")
|
2020-09-01 21:58:57 -07:00
|
|
|
)
|
|
|
|
|
2021-01-15 23:56:24 -08:00
|
|
|
type ListEachEntryFunc func(entry *Entry) bool
|
|
|
|
|
2018-05-25 23:27:06 -07:00
|
|
|
type FilerStore interface {
|
2018-06-17 13:24:57 -07:00
|
|
|
// GetName gets the name to locate the configuration in filer.toml file
|
2018-05-26 03:49:46 -07:00
|
|
|
GetName() string
|
2018-06-17 13:01:57 -07:00
|
|
|
// Initialize initializes the file store
|
2020-01-29 09:09:55 -08:00
|
|
|
Initialize(configuration util.Configuration, prefix string) error
|
2019-03-15 15:55:34 -07:00
|
|
|
InsertEntry(context.Context, *Entry) error
|
|
|
|
UpdateEntry(context.Context, *Entry) (err error)
|
2020-09-24 03:06:44 -07:00
|
|
|
// err == filer_pb.ErrNotFound if not found
|
2020-03-23 00:01:34 -07:00
|
|
|
FindEntry(context.Context, util.FullPath) (entry *Entry, err error)
|
|
|
|
DeleteEntry(context.Context, util.FullPath) (err error)
|
2021-07-22 08:23:20 -07:00
|
|
|
DeleteFolderChildren(context.Context, util.FullPath) (err error)
|
2021-01-15 23:56:24 -08:00
|
|
|
ListDirectoryEntries(ctx context.Context, dirPath util.FullPath, startFileName string, includeStartFile bool, limit int64, eachEntryFunc ListEachEntryFunc) (lastFileName string, err error)
|
|
|
|
ListDirectoryPrefixedEntries(ctx context.Context, dirPath util.FullPath, startFileName string, includeStartFile bool, limit int64, prefix string, eachEntryFunc ListEachEntryFunc) (lastFileName string, err error)
|
2019-03-30 23:08:29 -07:00
|
|
|
|
|
|
|
BeginTransaction(ctx context.Context) (context.Context, error)
|
|
|
|
CommitTransaction(ctx context.Context) error
|
|
|
|
RollbackTransaction(ctx context.Context) error
|
2020-03-14 20:30:26 -07:00
|
|
|
|
2020-09-01 21:58:57 -07:00
|
|
|
KvPut(ctx context.Context, key []byte, value []byte) (err error)
|
|
|
|
KvGet(ctx context.Context, key []byte) (value []byte, err error)
|
|
|
|
KvDelete(ctx context.Context, key []byte) (err error)
|
|
|
|
|
2020-03-14 20:30:26 -07:00
|
|
|
Shutdown()
|
2020-07-12 22:13:40 -07:00
|
|
|
}
|
2021-03-13 22:07:39 -08:00
|
|
|
|
|
|
|
type BucketAware interface {
|
|
|
|
OnBucketCreation(bucket string)
|
|
|
|
OnBucketDeletion(bucket string)
|
2021-06-13 07:31:56 -07:00
|
|
|
CanDropWholeBucket() bool
|
2021-03-13 22:07:39 -08:00
|
|
|
}
|