mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-06-21 05:58:23 +08:00

* feat: get query progress tracker started * feat: flesh out query progress test some more and get first few assertions passing * chore: flesh out query tracker tests and impl some more * feat: add impl for QueryTracker.Subscribe * feat: send latest update if available on subscription * feat: broadcast query progress to all subscribers on update * feat: finish plumbing query tracker happy path * feat: finish with v0 impl for query progress tracker * chore: some cleanup of query progress tracker * feat: hook up query progress tracking for queryRangeV3 * feat: impl for query progress websocket API handler * feat: implement Hijacker iface for loggingResponseWriter for websocket upgrades * chore: some cleanup to query progress websocket API handler * chore: some cleanup * chore: move query progress impl into its own subpackage * chore: separate in-memory tracker impl from interface * chore: some more cleanup of in memory tracker * chore: some more cleanup of query progress tracker * chore: some final cleanups
32 lines
1.3 KiB
Go
32 lines
1.3 KiB
Go
package queryprogress
|
|
|
|
import (
|
|
"github.com/ClickHouse/clickhouse-go/v2"
|
|
"go.signoz.io/signoz/pkg/query-service/model"
|
|
v3 "go.signoz.io/signoz/pkg/query-service/model/v3"
|
|
)
|
|
|
|
type QueryProgressTracker interface {
|
|
// Tells the tracker that query with id `queryId` has started.
|
|
// Progress can only be reported for and tracked for a query that is in progress.
|
|
// Returns a cleanup function that must be called after the query finishes.
|
|
ReportQueryStarted(queryId string) (postQueryCleanup func(), err *model.ApiError)
|
|
|
|
// Report progress stats received from clickhouse for `queryId`
|
|
ReportQueryProgress(queryId string, chProgress *clickhouse.Progress) *model.ApiError
|
|
|
|
// Subscribe to progress updates for `queryId`
|
|
// The returned channel will produce `QueryProgress` instances representing
|
|
// the latest state of query progress stats. Also returns a function that
|
|
// can be called to unsubscribe before the query finishes, if needed.
|
|
SubscribeToQueryProgress(queryId string) (ch <-chan v3.QueryProgress, unsubscribe func(), err *model.ApiError)
|
|
}
|
|
|
|
func NewQueryProgressTracker() QueryProgressTracker {
|
|
// InMemory tracker is useful only for single replica query service setups.
|
|
// Multi replica setups must use a centralized store for tracking and subscribing to query progress
|
|
return &inMemoryQueryProgressTracker{
|
|
queries: map[string]*queryTracker{},
|
|
}
|
|
}
|