-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_test.go
More file actions
49 lines (39 loc) · 1004 Bytes
/
Copy pathexample_test.go
File metadata and controls
49 lines (39 loc) · 1004 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package adk_go_mongo
import (
"os"
"go.mongodb.org/mongo-driver/v2/mongo"
"go.mongodb.org/mongo-driver/v2/mongo/options"
"google.golang.org/adk/cmd/launcher"
"google.golang.org/adk/runner"
"github.com/amammay/adk-go-mongo/mongosession"
)
func Example() {
// create your underlying mongo client
mongoClient, err := mongo.Connect(options.Client().ApplyURI(os.Getenv("MONGO_URI")))
if err != nil {
panic(err)
}
// create the mongo based session service
sessionService, err := mongosession.NewSessionService(mongoClient.Database("mydatabasename"))
if err != nil {
panic(err)
}
// apply indexes
err = mongosession.ApplyIndexes(sessionService)
if err != nil {
panic(err)
}
// use in launcher
config := &launcher.Config{
SessionService: sessionService,
// all other options...
}
_ = config
// or use in runner
r, err := runner.New(runner.Config{
AppName: "...appname",
Agent: nil, // your agent here
SessionService: sessionService,
})
_ = r
}