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

Commit

Permalink
eventstore: refacto
Browse files Browse the repository at this point in the history
  • Loading branch information
T4ze committed Dec 9, 2017
1 parent 07540fa commit 939b7b0
Showing 1 changed file with 16 additions and 24 deletions.
40 changes: 16 additions & 24 deletions src/main/java/com/epita/guereza/EventStoreApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,21 @@ private void extractThen(final EventBusClient.Message msg, final Consumer<Object

@Override
public void run() {
eventBus.subscribe("/request/crawler/url", msg -> {
extractThen(msg, o -> {
Event<String> ev = new Event<>("CRAWLER_REQUEST_URL", String.class, (String) o);
eventStore.dispatch(ev);
});
});
eventBus.subscribe("/request/indexer/url", msg -> {
extractThen(msg, o -> {
Event<String> ev = new Event<>("INDEXER_REQUEST_URL", String.class, (String) o);
eventStore.dispatch(ev);
});
});
eventBus.subscribe("/store/crawler", msg -> {
extractThen(msg, o -> {
Event<String[]> ev = new Event<>("ADD_URLS", String[].class, (String[]) o);
eventStore.dispatch(ev);
});
});
eventBus.subscribe("/store/indexer", msg -> {
extractThen(msg, o -> {
Event<Document> ev = new Event<>("ADD_DOCUMENT", Document.class, (Document) o);
eventStore.dispatch(ev);
});
});
eventBus.subscribe("/request/crawler/url", msg -> extractThen(msg, o -> {
Event<String> ev = new Event<>("CRAWLER_REQUEST_URL", String.class, (String) o);
eventStore.dispatch(ev);
}));
eventBus.subscribe("/request/indexer/url", msg -> extractThen(msg, o -> {
Event<String> ev = new Event<>("INDEXER_REQUEST_URL", String.class, (String) o);
eventStore.dispatch(ev);
}));
eventBus.subscribe("/store/crawler", msg -> extractThen(msg, o -> {
Event<String[]> ev = new Event<>("ADD_URLS", String[].class, (String[]) o);
eventStore.dispatch(ev);
}));
eventBus.subscribe("/store/indexer", msg -> extractThen(msg, o -> {
Event<Document> ev = new Event<>("ADD_DOCUMENT", Document.class, (Document) o);
eventStore.dispatch(ev);
}));
}
}

0 comments on commit 939b7b0

Please sign in to comment.