aboutsummaryrefslogtreecommitdiffstats
path: root/src/mongo.go
diff options
context:
space:
mode:
authorWe-unite <3205135446@qq.com>2024-07-29 11:46:02 +0800
committerWe-unite <3205135446@qq.com>2024-07-29 11:46:02 +0800
commita345258c3082903702c81c6c830ff1fd35758861 (patch)
treea8521e954630b299c85adc10182ee3470a982415 /src/mongo.go
parentec260a31927ef77295eaa07ba370b58b416f47f5 (diff)
downloadgodo-a345258c3082903702c81c6c830ff1fd35758861.tar.gz
godo-a345258c3082903702c81c6c830ff1fd35758861.zip
Hear file Open and close, especially O_TRUNC
this commit i successfully catch open/close syscall, and insert them as an independent collection in mongodb otherwise along with pids. and now I've record those open flag "O_TRUNC" as written.
Diffstat (limited to 'src/mongo.go')
-rw-r--r--src/mongo.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/mongo.go b/src/mongo.go
index d00abd2..54f9533 100644
--- a/src/mongo.go
+++ b/src/mongo.go
@@ -15,6 +15,18 @@ type mongoClient struct {
15 col *mongo.Collection 15 col *mongo.Collection
16} 16}
17 17
18func (mc *mongoClient) init(dbName, colName string) error {
19 var err error
20 if err = mc.Connect(dbName, colName); err != nil {
21 return err
22 }
23 if err = mc.Drop(); err != nil {
24 return err
25 }
26
27 return nil
28}
29
18func (mc *mongoClient) Connect(dbName, colName string) error { 30func (mc *mongoClient) Connect(dbName, colName string) error {
19 var err error 31 var err error
20 mc.client, err = mongo.NewClient(options.Client().ApplyURI("mongodb://localhost:27017")) 32 mc.client, err = mongo.NewClient(options.Client().ApplyURI("mongodb://localhost:27017"))