Skip to content

Commit

Permalink
fix(query): set the From and To timestamps if specified (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
aybabtme authored Dec 22, 2024
1 parent 06d4c3a commit 7898622
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 28 deletions.
5 changes: 3 additions & 2 deletions cmd/humanlog/localhost.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net"
"net/http"
"net/url"
"runtime/debug"
"strconv"
"sync"
"time"
Expand Down Expand Up @@ -104,8 +105,8 @@ func startLocalhostServer(
defer func() {
if r := recover(); r != nil {
w.WriteHeader(http.StatusInternalServerError)
fmt.Fprintf(w, "oh noes the sky is falling")
ll.ErrorContext(ctx, "handler panicked!", slog.Any("panic", r))
fmt.Fprintf(w, "oh noes the sky is falling\n\n%s", string(debug.Stack()))
panic(r)
}
}()
hdl.ServeHTTP(w, r)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require (
github.com/google/go-cmp v0.6.0
github.com/google/uuid v1.6.0
github.com/humanlogio/api/go v0.0.0-20241222094300-0b4f4b67d589
github.com/humanlogio/humanlog-pro v0.0.0-20241217115348-251a98ffde3c
github.com/humanlogio/humanlog-pro v0.0.0-20241222102640-7d8e5c5aa73f
github.com/kr/logfmt v0.0.0-20210122060352-19f9bcb100e6
github.com/lrstanley/bubblezone v0.0.0-20240914071701-b48c55a5e78e
github.com/matoous/go-nanoid v1.5.0
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ github.com/humanlogio/api/go v0.0.0-20241222094300-0b4f4b67d589 h1:qN+0Si/PicOj3
github.com/humanlogio/api/go v0.0.0-20241222094300-0b4f4b67d589/go.mod h1:sjMKAl97fvxNckIhcGWAxZwv6+c+I0thx5QvMc1ifaM=
github.com/humanlogio/humanlog-pro v0.0.0-20241217115348-251a98ffde3c h1:FPMln3Ff3WTEiX6z69DxxuxLaZZCNgRbKHtDdXohe0c=
github.com/humanlogio/humanlog-pro v0.0.0-20241217115348-251a98ffde3c/go.mod h1:+DAvLjnurssG0w1mZrGDqAA6ZfHcllzvC97nVGvi4cE=
github.com/humanlogio/humanlog-pro v0.0.0-20241222102200-c967666b42e8 h1:MCJft1BV1zELeR4jld8uvTxiqUE2tGBDskL4T/60z/4=
github.com/humanlogio/humanlog-pro v0.0.0-20241222102200-c967666b42e8/go.mod h1:afYRZoh26KkhLsG/3S+qngpiQW4XkIw/qz6b8Vb56xQ=
github.com/humanlogio/humanlog-pro v0.0.0-20241222102640-7d8e5c5aa73f h1:69NO3TybWWr3TN7P+msYAYk7/P/E5kwYwWU/bTYOyrY=
github.com/humanlogio/humanlog-pro v0.0.0-20241222102640-7d8e5c5aa73f/go.mod h1:afYRZoh26KkhLsG/3S+qngpiQW4XkIw/qz6b8Vb56xQ=
github.com/klauspost/asmfmt v1.3.2 h1:4Ri7ox3EwapiOjCki+hw14RyKk201CN4rzyCJRFLpK4=
github.com/klauspost/asmfmt v1.3.2/go.mod h1:AG8TuvYojzulgDAMCnYn50l/5QV3Bs/tp6j0HLHbNSE=
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
Expand Down
26 changes: 1 addition & 25 deletions internal/localsvc/svc.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,32 +303,8 @@ func (svc *Service) WatchQuery(ctx context.Context, req *connect.Request[qrv1.Wa
ll = ll.With(slog.String("query.to", query.To.AsTime().Format(time.RFC3339Nano)))
}

// ticker := time.NewTicker(time.Second)
// defer ticker.Stop()
// for i := 0; ; i++ {
// select {
// case now := <-ticker.C:

// err := stream.Send(&qrv1.WatchQueryResponse{
// Events: []*typesv1.LogEventGroup{
// {
// MachineId: 1,
// SessionId: 1,
// Logs: []*typesv1.LogEvent{
// {ParsedAt: timestamppb.New(now), Raw: []byte(fmt.Sprintf("it's now %d o-clock", now.Hour()))},
// },
// },
// },
// })
// ll.DebugContext(ctx, "send a message group", slog.Any("err", err))

// case <-ctx.Done():
// return nil
// }
// }

ll.DebugContext(ctx, "running query through storage")
cursors, err := svc.storage.Query(ctx, req.Msg.Query)
cursors, err := svc.storage.Query(ctx, query)
if err != nil {
return connect.NewError(connect.CodeInternal, fmt.Errorf("querying local storage: %v", err))
}
Expand Down

0 comments on commit 7898622

Please sign in to comment.