mirror of
https://github.com/logos-messaging/telemetry.git
synced 2026-01-02 14:13:05 +00:00
feat: start aggregator
This commit is contained in:
parent
cdce03ca1c
commit
0c60bb544b
1
Makefile
1
Makefile
@ -23,4 +23,3 @@ test:
|
||||
|
||||
build:
|
||||
go build -o ./build/server ./cmd/server/main.go
|
||||
go build -o ./build/aggregator ./cmd/aggregator/main.go
|
||||
@ -1,21 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"time"
|
||||
|
||||
"github.com/status-im/dev-telemetry/telemetry"
|
||||
)
|
||||
|
||||
func main() {
|
||||
seconds := flag.Int("seconds", 3600, "Number of seconds to aggregate")
|
||||
dataSourceName := flag.String("data-source-name", "", "DB URL")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
db := telemetry.OpenDb(*dataSourceName)
|
||||
defer db.Close()
|
||||
|
||||
aggregator := telemetry.NewAggregator(db)
|
||||
aggregator.Run(time.Duration(*seconds) * time.Second)
|
||||
}
|
||||
@ -2,8 +2,11 @@ package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"time"
|
||||
|
||||
"github.com/status-im/dev-telemetry/telemetry"
|
||||
|
||||
"github.com/robfig/cron/v3"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -15,6 +18,14 @@ func main() {
|
||||
db := telemetry.OpenDb(*dataSourceName)
|
||||
defer db.Close()
|
||||
|
||||
aggregator := telemetry.NewAggregator(db)
|
||||
c := cron.New()
|
||||
c.AddFunc("* * * * *", func() {
|
||||
aggregator.Run(time.Hour)
|
||||
})
|
||||
c.Start()
|
||||
defer c.Stop()
|
||||
|
||||
server := telemetry.NewServer(db)
|
||||
server.Start(*port)
|
||||
}
|
||||
|
||||
1
go.mod
1
go.mod
@ -6,5 +6,6 @@ require (
|
||||
github.com/gorilla/mux v1.8.0
|
||||
github.com/lib/pq v1.10.3
|
||||
github.com/mattn/go-sqlite3 v1.14.9
|
||||
github.com/robfig/cron/v3 v3.0.1
|
||||
github.com/stretchr/testify v1.7.0
|
||||
)
|
||||
|
||||
2
go.sum
2
go.sum
@ -8,6 +8,8 @@ github.com/mattn/go-sqlite3 v1.14.9 h1:10HX2Td0ocZpYEjhilsuo6WWtUqttj2Kb0KtD86/K
|
||||
github.com/mattn/go-sqlite3 v1.14.9/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
|
||||
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user