all: sync with master
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
package querylog
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"context"
|
||||
"log/slog"
|
||||
"time"
|
||||
)
|
||||
|
||||
// searchParams represent the search query sent by the client.
|
||||
type searchParams struct {
|
||||
@@ -35,14 +39,23 @@ func newSearchParams() *searchParams {
|
||||
}
|
||||
|
||||
// quickMatchClientFunc is a simplified client finder for quick matches.
|
||||
type quickMatchClientFunc = func(clientID, ip string) (c *Client)
|
||||
type quickMatchClientFunc = func(
|
||||
ctx context.Context,
|
||||
logger *slog.Logger,
|
||||
clientID, ip string,
|
||||
) (c *Client)
|
||||
|
||||
// quickMatch quickly checks if the line matches the given search parameters.
|
||||
// It returns false if the line doesn't match. This method is only here for
|
||||
// optimization purposes.
|
||||
func (s *searchParams) quickMatch(line string, findClient quickMatchClientFunc) (ok bool) {
|
||||
func (s *searchParams) quickMatch(
|
||||
ctx context.Context,
|
||||
logger *slog.Logger,
|
||||
line string,
|
||||
findClient quickMatchClientFunc,
|
||||
) (ok bool) {
|
||||
for _, c := range s.searchCriteria {
|
||||
if !c.quickMatch(line, findClient) {
|
||||
if !c.quickMatch(ctx, logger, line, findClient) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user