update filer

Chris Lu 2020-09-05 14:19:39 -07:00
parent 9327502047
commit b1f4144771

@ -3,10 +3,10 @@ It is fairly easy if you need to store filer metadata with other data store.
Let's use "yourstore" as the chosen name. Let's use "yourstore" as the chosen name.
Here are the steps: Here are the steps:
1. Add a package under github.com/chrislusf/seaweedfs/weed/filer2/yourstore 1. Add a package under github.com/chrislusf/seaweedfs/weed/filer/yourstore
2. Implement the filer2.FilerStore interface 2. Implement the filer.FilerStore interface
``` ```
package filer2 package filer
import ( import (
"errors" "errors"
@ -16,12 +16,25 @@ type FilerStore interface {
// GetName gets the name to locate the configuration in filer.toml file // GetName gets the name to locate the configuration in filer.toml file
GetName() string GetName() string
// Initialize initializes the file store // Initialize initializes the file store
Initialize(configuration Configuration) error Initialize(configuration util.Configuration, prefix string) error
InsertEntry(*Entry) error InsertEntry(context.Context, *Entry) error
UpdateEntry(*Entry) (err error) UpdateEntry(context.Context, *Entry) (err error)
FindEntry(FullPath) (entry *Entry, err error) // err == filer2.ErrNotFound if not found
DeleteEntry(FullPath) (err error) FindEntry(context.Context, util.FullPath) (entry *Entry, err error)
ListDirectoryEntries(dirPath FullPath, startFileName string, includeStartFile bool, limit int) ([]*Entry, error) DeleteEntry(context.Context, util.FullPath) (err error)
DeleteFolderChildren(context.Context, util.FullPath) (err error)
ListDirectoryEntries(ctx context.Context, dirPath util.FullPath, startFileName string, includeStartFile bool, limit int) ([]*Entry, error)
ListDirectoryPrefixedEntries(ctx context.Context, dirPath util.FullPath, startFileName string, includeStartFile bool, limit int, prefix string) ([]*Entry, error)
BeginTransaction(ctx context.Context) (context.Context, error)
CommitTransaction(ctx context.Context) error
RollbackTransaction(ctx context.Context) error
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)
Shutdown()
} }
``` ```
@ -37,13 +50,13 @@ func init() {
import ( import (
"net/http" "net/http"
"strconv" "strconv"
"github.com/chrislusf/seaweedfs/weed/filer2" "github.com/chrislusf/seaweedfs/weed/filer"
_ "github.com/chrislusf/seaweedfs/weed/filer2/cassandra" _ "github.com/chrislusf/seaweedfs/weed/filer/cassandra"
_ "github.com/chrislusf/seaweedfs/weed/filer2/leveldb" _ "github.com/chrislusf/seaweedfs/weed/filer/leveldb"
_ "github.com/chrislusf/seaweedfs/weed/filer2/mysql" _ "github.com/chrislusf/seaweedfs/weed/filer/mysql"
_ "github.com/chrislusf/seaweedfs/weed/filer2/postgres" _ "github.com/chrislusf/seaweedfs/weed/filer/postgres"
_ "github.com/chrislusf/seaweedfs/weed/filer2/redis" _ "github.com/chrislusf/seaweedfs/weed/filer/redis"
_ "github.com/chrislusf/seaweedfs/weed/filer2/yourstore" _ "github.com/chrislusf/seaweedfs/weed/filer/yourstore"
// ^^ add here // ^^ add here
"github.com/chrislusf/seaweedfs/weed/security" "github.com/chrislusf/seaweedfs/weed/security"
"github.com/chrislusf/seaweedfs/weed/glog" "github.com/chrislusf/seaweedfs/weed/glog"