pub struct RemoteSettingsSuggester {
    suggestions: Arc<DedupedMap<String, (), Suggestion>>,
    metrics_client: StatsdClient,
    resync_task: Option<(JoinHandle<()>, Sender<RemoteSettingsConfig>)>,
}
Expand description

Make suggestions based on data in Remote Settings

Fields

suggestions: Arc<DedupedMap<String, (), Suggestion>>

A map from keywords to suggestions that can be provided.

metrics_client: StatsdClient

The Statsd client used to record statistics.

resync_task: Option<(JoinHandle<()>, Sender<RemoteSettingsConfig>)>

The control handles for the background re-sync task used for reconfiguration.

Implementations

Make and sync a new suggester.

Errors

Returns an error if the settings are invalid for this provider, or if the initial sync fails.

Creat a client to Remote Settings.

Error: a SetupError is returned if the creation fails.

Parses a Proportion from the configuration source.

Error: a SetupError is returned if the parsing fails.

Spawns a new task for resyncing with Remote Settings. It also exposes a MPSC channel sender to support the provider reconfiguration.

Following tasks are done in this task:

  • Resync with Remote Settings if needed. The resync interval is configured by rs_config.resync_interval.
  • Retry if the regular resync fails.
  • Receive the new configurations for provider reconfiguration.

Download suggestions from Remote Settings

This must be called at least once before any suggestions will be provided

Gets the “full keyword” (the suggested completion) for a query. The data from adM doesn’t include this data directly, so we make our own based on the available keywords.

  1. Filter out keywords that don’t start with the value of partial_query.
  2. Find the first keyword phrase that has more words than the query. Use its first query_num_words words as the full keyword. e.g., if the query is "moz" and all_keywords is ["moz", "mozi", "mozil", "mozill", "mozilla", "mozilla firefox"], pick "mozilla firefox", pop off the "firefox" and use "mozilla" as the full keyword.
  3. If there isn’t any keyword phrase with more words, then pick the longest phrase. e.g., pick "mozilla“ in the previous example (assuming the "mozilla firefox" phrase isn’t there). That might be the query itself.

Trait Implementations

Reconfigure the Remote Settings provider.

It only supports reconfiguring the resync_interval and suggestion_score now. As updating the other fields on the fly doesn’t seem useful in practice.

Also note that it will not issue a sync to Remote Settings during the reconfiguration for the performance concerns as reconfigurations will prevent Merino from serving incoming requests due to the exclusive lock held on the provider state. Excessive reconfigurations could make Merino completely irresponsive. Until we find a better way to handle that, let’s make these reconfigurations call run as fast as possible.

An operator-visible name for this suggestion provider.

Generate a set of cache inputs for a given query specific to this provider. Any property of the query that affects how suggestions are generated should be included. Read more

Provide suggested results for query.

Return if this provider is null and can be ignored. Providers that set this to true should be ignored in any place where suggestions are needed. Providers with this set to true likely only serve as a blank space where we may need a provider but can’t otherwise supply one. Read more

Use Self::cache_inputs to generate a single cache key. This function should not normally be overridden by provider implementations. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more