-
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.
- Loading branch information
1 parent
3df08bd
commit 3054ef8
Showing
24 changed files
with
1,103 additions
and
725 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.