-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(querier): Refactor the store and querier interface. (#15969)
- Loading branch information
1 parent
8cf8e5f
commit 4df8c60
Showing
24 changed files
with
1,095 additions
and
722 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package deletion | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
"github.com/grafana/dskit/tenant" | ||
|
||
"github.com/grafana/loki/v3/pkg/compactor/deletion" | ||
"github.com/grafana/loki/v3/pkg/logproto" | ||
) | ||
|
||
type DeleteGetter interface { | ||
GetAllDeleteRequestsForUser(ctx context.Context, userID string) ([]deletion.DeleteRequest, error) | ||
} | ||
|
||
// DeletesForUserQuery returns the deletes for a user (taken from request context) within a given time range. | ||
func DeletesForUserQuery(ctx context.Context, startT, endT time.Time, g DeleteGetter) ([]*logproto.Delete, error) { | ||
userID, err := tenant.TenantID(ctx) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
d, err := g.GetAllDeleteRequestsForUser(ctx, userID) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
start := startT.UnixNano() | ||
end := endT.UnixNano() | ||
|
||
var deletes []*logproto.Delete | ||
for _, del := range d { | ||
if del.StartTime.UnixNano() <= end && del.EndTime.UnixNano() >= start { | ||
deletes = append(deletes, &logproto.Delete{ | ||
Selector: del.Query, | ||
Start: del.StartTime.UnixNano(), | ||
End: del.EndTime.UnixNano(), | ||
}) | ||
} | ||
} | ||
|
||
return deletes, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.