Skip to content

Commit

Permalink
chore: move some structs out of v3
Browse files Browse the repository at this point in the history
  • Loading branch information
srikanthccv committed Sep 11, 2024
1 parent 20ac75e commit 22f3aa8
Show file tree
Hide file tree
Showing 17 changed files with 192 additions and 1,257 deletions.
401 changes: 0 additions & 401 deletions ee/query-service/app/db/metrics.go

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/ClickHouse/clickhouse-go/v2"
"github.com/google/uuid"
"go.signoz.io/signoz/pkg/query-service/model"
v3 "go.signoz.io/signoz/pkg/query-service/model/v3"
"go.uber.org/zap"
"golang.org/x/exp/maps"
)
Expand Down Expand Up @@ -52,7 +51,7 @@ func (tracker *inMemoryQueryProgressTracker) ReportQueryProgress(

func (tracker *inMemoryQueryProgressTracker) SubscribeToQueryProgress(
queryId string,
) (<-chan v3.QueryProgress, func(), *model.ApiError) {
) (<-chan model.QueryProgress, func(), *model.ApiError) {
queryTracker, err := tracker.getQueryTracker(queryId)
if err != nil {
return nil, nil, err
Expand Down Expand Up @@ -97,7 +96,7 @@ type queryTracker struct {
queryId string
isFinished bool

progress *v3.QueryProgress
progress *model.QueryProgress
subscriptions map[string]*queryProgressSubscription

lock sync.Mutex
Expand All @@ -124,7 +123,7 @@ func (qt *queryTracker) handleProgressUpdate(p *clickhouse.Progress) {

if qt.progress == nil {
// This is the first update
qt.progress = &v3.QueryProgress{}
qt.progress = &model.QueryProgress{}
}
updateQueryProgress(qt.progress, p)

Expand All @@ -135,7 +134,7 @@ func (qt *queryTracker) handleProgressUpdate(p *clickhouse.Progress) {
}

func (qt *queryTracker) subscribe() (
<-chan v3.QueryProgress, func(), *model.ApiError,
<-chan model.QueryProgress, func(), *model.ApiError,
) {
qt.lock.Lock()
defer qt.lock.Unlock()
Expand Down Expand Up @@ -200,20 +199,20 @@ func (qt *queryTracker) onFinished() {
}

type queryProgressSubscription struct {
ch chan v3.QueryProgress
ch chan model.QueryProgress
isClosed bool
lock sync.Mutex
}

func newQueryProgressSubscription() *queryProgressSubscription {
ch := make(chan v3.QueryProgress, 1000)
ch := make(chan model.QueryProgress, 1000)
return &queryProgressSubscription{
ch: ch,
}
}

// Must not block or panic in any scenario
func (ch *queryProgressSubscription) send(progress v3.QueryProgress) {
func (ch *queryProgressSubscription) send(progress model.QueryProgress) {
ch.lock.Lock()
defer ch.lock.Unlock()

Expand Down Expand Up @@ -248,7 +247,7 @@ func (ch *queryProgressSubscription) close() {
}
}

func updateQueryProgress(qp *v3.QueryProgress, chProgress *clickhouse.Progress) {
func updateQueryProgress(qp *model.QueryProgress, chProgress *clickhouse.Progress) {
qp.ReadRows += chProgress.Rows
qp.ReadBytes += chProgress.Bytes
qp.ElapsedMs += uint64(chProgress.Elapsed.Milliseconds())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ 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 {
Expand All @@ -19,7 +18,7 @@ type QueryProgressTracker interface {
// 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)
SubscribeToQueryProgress(queryId string) (ch <-chan model.QueryProgress, unsubscribe func(), err *model.ApiError)
}

func NewQueryProgressTracker() QueryProgressTracker {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/ClickHouse/clickhouse-go/v2"
"github.com/stretchr/testify/require"
"go.signoz.io/signoz/pkg/query-service/model"
v3 "go.signoz.io/signoz/pkg/query-service/model/v3"
)

func TestQueryProgressTracking(t *testing.T) {
Expand Down Expand Up @@ -45,7 +44,7 @@ func TestQueryProgressTracking(t *testing.T) {
require.NotNil(ch)
require.NotNil(unsubscribe)

expectedProgress := v3.QueryProgress{}
expectedProgress := model.QueryProgress{}
updateQueryProgress(&expectedProgress, testProgress1)
require.Equal(expectedProgress.ReadRows, testProgress1.Rows)
select {
Expand Down
Loading

0 comments on commit 22f3aa8

Please sign in to comment.