Skip to content
This repository has been archived by the owner on Jun 2, 2019. It is now read-only.

Commit

Permalink
Add reducers to store
Browse files Browse the repository at this point in the history
  • Loading branch information
dethi committed Dec 9, 2017
1 parent 0cd11e7 commit ce90057
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
15 changes: 5 additions & 10 deletions src/main/java/com/epita/guereza/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,16 @@ private static void runIndexer(Scope scope) {

private static void runStore(Scope scope) {
final Function<Scope, UrlStore> newUrlStore = (s) -> new UrlStore(s.instanceOf(EventBusClient.class));
final Function<Scope, RetroIndex> newRetroIndex = (s) -> new RetroIndex();
final Function<Scope, App> newEventStoreApp = (s) -> new EventStoreApp(
s.instanceOf(EventBusClient.class), s.instanceOf(EventStore.class));

scope.scope()
.register(new Singleton<>(EventStore.class, new EventStore()))
.register(new LazySingleton<>(UrlStore.class, newUrlStore)
.register(new LazySingleton<>(UrlStore.class, newUrlStore))
.register(new Singleton<>(RetroIndex.class, new RetroIndex()))
.register(new LazySingleton<>(EventStore.class, (s) -> new EventStore())
.afterCreate((s, obj) -> {
EventStore eventStore = s.instanceOf(EventStore.class);
eventStore.addReducer(obj);
}))
.register(new LazySingleton<>(RetroIndex.class, newRetroIndex)
.afterCreate((s, obj) -> {
EventStore eventStore = s.instanceOf(EventStore.class);
eventStore.addReducer(obj);
obj.addReducer(s.instanceOf(UrlStore.class));
obj.addReducer(s.instanceOf(RetroIndex.class));
}))
.register(new Prototype<>(App.class, newEventStoreApp))
.block(Main::runApp);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/epita/guereza/UrlStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

public class UrlStore implements Reducer {
private static final Logger LOGGER = LoggerFactory.getLogger(CrawlerService.class);
private static final String STARTING_URL = "https://www.wikipedia.org";
private static final String STARTING_URL = "http://www.wikipedia.org";

private final EventBusClient eventBus;

Expand Down

0 comments on commit ce90057

Please sign in to comment.