Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: move some structs out of v3 #5932

Merged
merged 5 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading