From 0a8013912090ceef74632507067f09918b8ff74d Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sun, 17 Jun 2018 13:16:14 -0700 Subject: [PATCH] Created Customize Filer Store (markdown) --- Customize-Filer-Store.md | 51 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Customize-Filer-Store.md diff --git a/Customize-Filer-Store.md b/Customize-Filer-Store.md new file mode 100644 index 0000000..d710f5a --- /dev/null +++ b/Customize-Filer-Store.md @@ -0,0 +1,51 @@ +It is fairly easy if you need to store filer metadata with other data store. + +Let's use "yourstore" as the chosen name. + +Here are the steps: +1. add a package under github.com/chrislusf/seaweedfs/weed/filer2/yourstore +2. implement the filer2.FilerStore interface +``` +package filer2 + +import ( + "errors" +) + +type FilerStore interface { + GetName() string + // Initialize initializes the file store + Initialize(configuration Configuration) error + InsertEntry(*Entry) error + UpdateEntry(*Entry) (err error) + FindEntry(FullPath) (entry *Entry, err error) + DeleteEntry(FullPath) (err error) + ListDirectoryEntries(dirPath FullPath, startFileName string, includeStartFile bool, limit int) ([]*Entry, error) +} + +``` +3. Remember to add yourstore to the list of supported stores +``` +func init() { + filer2.Stores = append(filer2.Stores, &YourStore{}) +} +``` +4. Load yourstore. Just import it in github.com/chrislusf/seaweedfs/weed/server/filer_server.go +``` +import ( + "net/http" + "strconv" + "github.com/chrislusf/seaweedfs/weed/filer2" + _ "github.com/chrislusf/seaweedfs/weed/filer2/cassandra" + _ "github.com/chrislusf/seaweedfs/weed/filer2/leveldb" + _ "github.com/chrislusf/seaweedfs/weed/filer2/memdb" + _ "github.com/chrislusf/seaweedfs/weed/filer2/mysql" + _ "github.com/chrislusf/seaweedfs/weed/filer2/postgres" + _ "github.com/chrislusf/seaweedfs/weed/filer2/redis" + _ "github.com/chrislusf/seaweedfs/weed/filer2/yourstore" + // ^^ add here + "github.com/chrislusf/seaweedfs/weed/security" + "github.com/chrislusf/seaweedfs/weed/glog" +) + +``` \ No newline at end of file