Added change.Timeline, added change submissions to channel mutations, made all change submissions spin off a goroutine
the build was successful

This commit is contained in:
2018-07-08 13:25:18 +02:00
parent 6f04da49b8
commit 7adcdfe1e0
8 changed files with 200 additions and 15 deletions
+20
View File
@@ -1,6 +1,7 @@
package main
import (
"context"
"encoding/json"
"log"
"net/http"
@@ -8,6 +9,7 @@ import (
"git.aiterp.net/rpdata/api/internal/session"
"git.aiterp.net/rpdata/api/internal/store"
"git.aiterp.net/rpdata/api/loader"
"git.aiterp.net/rpdata/api/model/change"
"git.aiterp.net/rpdata/api/model/file"
logModel "git.aiterp.net/rpdata/api/model/log"
"git.aiterp.net/rpdata/api/resolver"
@@ -89,6 +91,24 @@ func main() {
w.Write(json)
})
change.InitializeTimeline()
go func() {
index := int64(0)
for {
index++
ch, err := change.Timeline.Get(context.Background(), index)
if err == change.ErrExpired {
continue
} else if err != nil {
log.Println("Timeline:", err)
break
}
log.Printf("Change: time=%s model=%s op=%s id=%s author=%s\n", ch.Time.Local().Format("[Mon Jan 02 15:04 MST]"), ch.Model, ch.Op, ch.ObjectID, ch.Author)
}
}()
log.Fatal(http.ListenAndServe(":17000", nil))
}