aboutsummaryrefslogtreecommitdiff
path: root/weed
diff options
context:
space:
mode:
authorbukton <buk_ton2@hotmail.com>2020-04-18 22:26:57 +0700
committerbukton <buk_ton2@hotmail.com>2020-04-18 22:26:57 +0700
commitfd4576651bc7cedaafb4d26b86d6b5b7ada4710d (patch)
tree8650c1555a22f60ae2fb03ace0bef924c613286a /weed
parentb51d8f03bba24c698ad030ce94e1a20816e5d150 (diff)
downloadseaweedfs-fd4576651bc7cedaafb4d26b86d6b5b7ada4710d.tar.xz
seaweedfs-fd4576651bc7cedaafb4d26b86d6b5b7ada4710d.zip
add new package mongodb and install lib mongodb
Diffstat (limited to 'weed')
-rw-r--r--weed/filer2/mongodb/mongodb_store.go77
1 files changed, 77 insertions, 0 deletions
diff --git a/weed/filer2/mongodb/mongodb_store.go b/weed/filer2/mongodb/mongodb_store.go
new file mode 100644
index 000000000..75df85172
--- /dev/null
+++ b/weed/filer2/mongodb/mongodb_store.go
@@ -0,0 +1,77 @@
+package mongodb
+
+import (
+ "context"
+ "github.com/chrislusf/seaweedfs/weed/filer2"
+ "github.com/chrislusf/seaweedfs/weed/util"
+ "go.mongodb.org/mongo-driver/mongo"
+ "go.mongodb.org/mongo-driver/mongo/options"
+ "time"
+)
+
+func init() {
+ filer2.Stores = append(filer2.Stores, &MongodbStore{})
+}
+
+type MongodbStore struct {
+ connect *mongo.Client
+}
+
+func (store *MongodbStore) GetName() string {
+ return "mongodb"
+}
+
+func (store *MongodbStore) Initialize(configuration util.Configuration, prefix string) (err error) {
+ return store.connection(configuration.GetString(prefix + "uri"))
+}
+
+func (store *MongodbStore) connection(uri string) (err error) {
+ ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
+ client, err := mongo.Connect(ctx, options.Client().ApplyURI(uri))
+ store.connect = client
+ return err
+}
+
+func (store *MongodbStore) BeginTransaction(ctx context.Context) (context.Context, error) {
+ return ctx, nil
+}
+
+func (store *MongodbStore) CommitTransaction(ctx context.Context) error {
+ return nil
+}
+
+func (store *MongodbStore) RollbackTransaction(ctx context.Context) error {
+ return nil
+}
+
+func (store *MongodbStore) InsertEntry(ctx context.Context, entry *filer2.Entry) (err error) {
+ return nil
+}
+
+func (store *MongodbStore) UpdateEntry(ctx context.Context, entry *filer2.Entry) (err error) {
+ return nil
+}
+
+func (store *MongodbStore) FindEntry(ctx context.Context, fullpath util.FullPath) (entry *filer2.Entry, err error) {
+ return nil, nil
+}
+
+func (store *MongodbStore) DeleteEntry(ctx context.Context, fullpath util.FullPath) error {
+
+ return nil
+}
+
+func (store *MongodbStore) DeleteFolderChildren(ctx context.Context, fullpath util.FullPath) error {
+
+ return nil
+}
+
+func (store *MongodbStore) ListDirectoryEntries(ctx context.Context, fullpath util.FullPath, startFileName string, inclusive bool, limit int) (entries []*filer2.Entry, err error) {
+
+ return nil, nil
+}
+
+func (store *MongodbStore) Shutdown() {
+ ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
+ store.connect.Disconnect(ctx)
+}