fix: msgbus get handler

This commit is contained in:
Jon Lundy 2022-08-15 12:25:50 -06:00
parent 5458d35be0
commit 6033437584
Signed by untrusted user who does not match committer: xuu
GPG Key ID: C63E6D61F3035024
2 changed files with 10 additions and 4 deletions

View File

@ -49,6 +49,7 @@ func main() {
} }
} }
func run(ctx context.Context) error { func run(ctx context.Context) error {
ctx, span := logz.Span(ctx)
diskstore.Init(ctx) diskstore.Init(ctx)
memstore.Init(ctx) memstore.Init(ctx)
if err := domain.Init(ctx); err != nil { if err := domain.Init(ctx); err != nil {
@ -98,6 +99,8 @@ func run(ctx context.Context) error {
return s.Shutdown(ctx) return s.Shutdown(ctx)
}) })
span.End()
return g.Wait() return g.Wait()
} }
func env(name, defaultValue string) string { func env(name, defaultValue string) string {

View File

@ -83,10 +83,13 @@ func (s *service) get(w http.ResponseWriter, r *http.Request) {
first = lis[0] first = lis[0]
} }
var pos, count int64 = -1, -99 var pos, count int64 = 0, es.AllEvents
qry := r.URL.Query() qry := r.URL.Query()
if i, err := strconv.ParseInt(qry.Get("index"), 10, 64); err == nil { if i, err := strconv.ParseInt(qry.Get("index"), 10, 64); err == nil && i > 1 {
pos = i - 1
}
if i, err := strconv.ParseInt(qry.Get("pos"), 10, 64); err == nil {
pos = i pos = i
} }
if i, err := strconv.ParseInt(qry.Get("n"), 10, 64); err == nil { if i, err := strconv.ParseInt(qry.Get("n"), 10, 64); err == nil {
@ -236,10 +239,10 @@ func (s *service) websocket(w http.ResponseWriter, r *http.Request) {
first = lis[0] first = lis[0]
} }
var pos int64 = -1 var pos int64 = 0
qry := r.URL.Query() qry := r.URL.Query()
if i, err := strconv.ParseInt(qry.Get("index"), 10, 64); err == nil { if i, err := strconv.ParseInt(qry.Get("index"), 10, 64); err == nil && i > 0 {
pos = i - 1 pos = i - 1
} }