diff --git a/internal/filtering/safesearch/safesearch.go b/internal/filtering/safesearch/safesearch.go index d422b971..a92e533a 100644 --- a/internal/filtering/safesearch/safesearch.go +++ b/internal/filtering/safesearch/safesearch.go @@ -26,8 +26,8 @@ import ( // Attribute keys and values for logging. const ( - LogPrefix = "safesearch" - LogKey = "client" + LogPrefix = "safesearch" + LogKeyClient = "client" ) // Service is a enum with service names used as search providers. @@ -106,7 +106,8 @@ type Default struct { cacheTTL time.Duration } -// NewDefault returns an initialized default safe search filter. +// NewDefault returns an initialized default safe search filter. ctx is used +// to log the initial refresh. func NewDefault(ctx context.Context, conf *DefaultConfig) (ss *Default, err error) { ss = &Default{ logger: conf.Logger, @@ -118,6 +119,7 @@ func NewDefault(ctx context.Context, conf *DefaultConfig) (ss *Default, err erro cacheTTL: conf.CacheTTL, } + // TODO(s.chzhen): Move to [Default.InitialRefresh]. err = ss.resetEngine(ctx, rulelist.URLFilterIDSafeSearch, conf.ServicesConfig) if err != nil { // Don't wrap the error, because it's informative enough as is. diff --git a/internal/home/clients.go b/internal/home/clients.go index e6fcb99a..c8e7a17e 100644 --- a/internal/home/clients.go +++ b/internal/home/clients.go @@ -216,7 +216,7 @@ func (o *clientObject) toPersistent( if o.SafeSearchConf.Enabled { logger := baseLogger.With( slogutil.KeyPrefix, safesearch.LogPrefix, - safesearch.LogKey, cli.Name, + safesearch.LogKeyClient, cli.Name, ) var ss *safesearch.Default ss, err = safesearch.NewDefault(ctx, &safesearch.DefaultConfig{ diff --git a/internal/home/clientshttp.go b/internal/home/clientshttp.go index 549a078a..3cc5a0c6 100644 --- a/internal/home/clientshttp.go +++ b/internal/home/clientshttp.go @@ -213,7 +213,7 @@ func (clients *clientsContainer) jsonToClient( if c.SafeSearchConf.Enabled { logger := clients.baseLogger.With( slogutil.KeyPrefix, safesearch.LogPrefix, - safesearch.LogKey, c.Name, + safesearch.LogKeyClient, c.Name, ) var ss *safesearch.Default ss, err = safesearch.NewDefault(ctx, &safesearch.DefaultConfig{ diff --git a/internal/home/clientshttp_internal_test.go b/internal/home/clientshttp_internal_test.go index 117b9b6e..c9be42b7 100644 --- a/internal/home/clientshttp_internal_test.go +++ b/internal/home/clientshttp_internal_test.go @@ -108,9 +108,9 @@ func assertPersistentClients(tb testing.TB, clients *clientsContainer, want []*c require.NoError(tb, err) var got []*client.Persistent + ctx := testutil.ContextWithTimeout(tb, testTimeout) for _, cj := range clientList.Clients { var c *client.Persistent - ctx := testutil.ContextWithTimeout(tb, testTimeout) c, err = clients.jsonToClient(ctx, *cj, nil) require.NoError(tb, err) @@ -131,10 +131,10 @@ func assertPersistentClientsData( tb.Helper() var got []*client.Persistent + ctx := testutil.ContextWithTimeout(tb, testTimeout) for _, cm := range data { for _, cj := range cm { var c *client.Persistent - ctx := testutil.ContextWithTimeout(tb, testTimeout) c, err := clients.jsonToClient(ctx, *cj, nil) require.NoError(tb, err)