2023-03-04 12:19:01 +00:00
|
|
|
package nu.marginalia.search;
|
2022-05-19 15:45:26 +00:00
|
|
|
|
|
|
|
import com.google.inject.AbstractModule;
|
2023-12-26 15:21:40 +00:00
|
|
|
import com.google.inject.Provides;
|
2023-03-04 12:19:01 +00:00
|
|
|
import nu.marginalia.LanguageModels;
|
|
|
|
import nu.marginalia.WebsiteUrl;
|
|
|
|
import nu.marginalia.WmsaHome;
|
2023-12-26 15:21:40 +00:00
|
|
|
import nu.marginalia.model.gson.GsonFactory;
|
2023-11-10 14:26:38 +00:00
|
|
|
import nu.marginalia.renderer.config.HandlebarsConfigurator;
|
2023-12-26 15:21:40 +00:00
|
|
|
import nu.marginalia.feedlot.FeedlotClient;
|
|
|
|
|
|
|
|
import java.time.Duration;
|
2022-05-19 15:45:26 +00:00
|
|
|
|
2023-03-04 12:19:01 +00:00
|
|
|
public class SearchModule extends AbstractModule {
|
2022-05-19 15:45:26 +00:00
|
|
|
|
|
|
|
public void configure() {
|
2023-11-10 14:26:38 +00:00
|
|
|
bind(HandlebarsConfigurator.class).to(SearchHandlebarsConfigurator.class);
|
|
|
|
|
2022-06-03 11:32:05 +00:00
|
|
|
bind(LanguageModels.class).toInstance(WmsaHome.getLanguageModels());
|
2023-11-10 14:26:38 +00:00
|
|
|
|
|
|
|
bind(WebsiteUrl.class).toInstance(new WebsiteUrl(
|
2024-01-13 16:12:18 +00:00
|
|
|
System.getProperty("search.websiteUrl", "https://search.marginalia.nu/")));
|
2022-05-19 15:45:26 +00:00
|
|
|
}
|
|
|
|
|
2023-12-26 15:21:40 +00:00
|
|
|
@Provides
|
|
|
|
public FeedlotClient provideFeedlotClient() {
|
|
|
|
return new FeedlotClient(
|
2024-02-20 10:41:14 +00:00
|
|
|
System.getProperty("ext-svc-feedlot-bindAddress", "feedlot"),
|
2023-12-26 15:21:40 +00:00
|
|
|
Integer.getInteger("ext-svc-feedlot-port", 80),
|
|
|
|
GsonFactory.get(),
|
|
|
|
Duration.ofMillis(250),
|
|
|
|
Duration.ofMillis(100)
|
|
|
|
);
|
|
|
|
}
|
2022-05-19 15:45:26 +00:00
|
|
|
}
|