-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
33 lines (28 loc) · 804 Bytes
/
main.go
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
package main
import (
"time"
backend "github.com/DCSO/balboa/backend/go"
"github.com/DCSO/balboa/observation"
"github.com/satta/balboa-backend-dgraph/handler"
"github.com/dgraph-io/dgo"
"github.com/dgraph-io/dgo/protos/api"
"github.com/patrickmn/go-cache"
log "github.com/sirupsen/logrus"
"google.golang.org/grpc"
)
func main() {
dconn, err := grpc.Dial("localhost:9080", grpc.WithInsecure())
if err != nil {
log.Fatal(err)
}
defer dconn.Close()
dgraphClient := dgo.NewDgraphClient(api.NewDgraphClient(dconn))
h := &handler.DgraphHandler{
Client: dgraphClient,
BufChunks: make([]*observation.InputObservation, 0),
SensorIDCache: cache.New(30*time.Minute, 45*time.Minute),
}
h.CheckAndSetSchema()
backend.Serve("0.0.0.0:4242", h)
log.Info("shutdown complete")
}