Skip to content
Prev Previous commit
Next Next commit
use protos.Task in strategies.Task
  • Loading branch information
salvacorts committed Nov 7, 2024
commit 4ace777822bb1b23065d699e0c03d75e713507a7
20 changes: 6 additions & 14 deletions pkg/bloombuild/planner/strategies/task.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package strategies

import (
"fmt"

"github.com/prometheus/common/model"

"github.com/grafana/loki/v3/pkg/bloombuild/protos"
v1 "github.com/grafana/loki/v3/pkg/storage/bloom/v1"
"github.com/grafana/loki/v3/pkg/storage/config"
"github.com/grafana/loki/v3/pkg/storage/stores/shipper/bloomshipper"
Expand All @@ -19,12 +18,9 @@ type Gap struct {

// Task represents a task that is enqueued in the planner.
type Task struct {
ID string
Table config.DayTable
Tenant string
OwnershipBounds v1.FingerprintBounds
TSDB tsdb.SingleTenantTSDBIdentifier
Gaps []Gap
*protos.Task
// Override the protos.Task.Gaps field with gaps that use model.Fingerprint instead of v1.Series.
Gaps []Gap
}

func NewTask(
Expand All @@ -35,11 +31,7 @@ func NewTask(
gaps []Gap,
) *Task {
return &Task{
ID: fmt.Sprintf("%s-%s-%s-%d", table.Addr(), tenant, bounds.String(), len(gaps)),
Table: table,
Tenant: tenant,
OwnershipBounds: bounds,
TSDB: tsdb,
Gaps: gaps,
Task: protos.NewTask(table, tenant, bounds, tsdb, nil),
Gaps: gaps,
}
}
18 changes: 18 additions & 0 deletions pkg/bloombuild/protos/compat.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,24 @@ type Task struct {
Gaps []Gap
}

func NewTask(
table config.DayTable,
tenant string,
bounds v1.FingerprintBounds,
tsdb tsdb.SingleTenantTSDBIdentifier,
gaps []Gap,
) *Task {
return &Task{
ID: fmt.Sprintf("%s-%s-%s-%d", table.Addr(), tenant, bounds.String(), len(gaps)),

Table: table,
Tenant: tenant,
OwnershipBounds: bounds,
TSDB: tsdb,
Gaps: gaps,
}
}

func FromProtoTask(task *ProtoTask) (*Task, error) {
if task == nil {
return nil, nil
Expand Down
Loading