feat: Add more log

This commit is contained in:
Anthony Laibe 2021-11-08 11:24:01 +01:00
parent 3917099be2
commit cdce03ca1c
3 changed files with 10 additions and 2 deletions

View File

@ -19,4 +19,8 @@ lint:
@golangci-lint --exclude=SA1019 run ./... --deadline=5m
test:
go test -v -failfast ./...
go test -v -failfast ./...
build:
go build -o ./build/server ./cmd/server/main.go
go build -o ./build/aggregator ./cmd/aggregator/main.go

View File

@ -17,5 +17,5 @@ func main() {
defer db.Close()
aggregator := telemetry.NewAggregator(db)
aggregator.Run(time.Duration(*seconds))
aggregator.Run(time.Duration(*seconds) * time.Second)
}

View File

@ -17,6 +17,7 @@ func NewAggregator(db *sql.DB) *Aggregator {
}
func (a *Aggregator) Run(d time.Duration) {
log.Printf("started aggregator for %s\n", d)
// Define the duration starts and end.
// Allow a buffer of the duration to define the start and end.
// This is to ensure we wait for people not being connected or if they received messages with delay
@ -63,6 +64,7 @@ func (a *Aggregator) Run(d time.Duration) {
}
if len(groupedMessages) == 0 {
log.Println("no record found, finishing early")
return
}
@ -103,6 +105,7 @@ func (a *Aggregator) Run(d time.Duration) {
log.Fatalf("could not store received message aggregated: %s", err)
}
}
log.Printf("stored %d chat id records", len(rChatID))
// Calculate the global reliability R = (R(0) + R(1)+ .... + R(n)) / len(Rch)
rChatIDTotal := 0.0
@ -121,4 +124,5 @@ func (a *Aggregator) Run(d time.Duration) {
if err != nil {
log.Fatalf("could not store received message aggregated: %s", err)
}
log.Printf("finished aggregator for %s\n", d)
}