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

Commit

Permalink
Implement RetroIndex reducer
Browse files Browse the repository at this point in the history
  • Loading branch information
dethi committed Dec 9, 2017
1 parent 5b3e830 commit a380487
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
30 changes: 30 additions & 0 deletions src/main/java/com/epita/guereza/RetroIndex.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.epita.guereza;

import com.epita.domain.Document;
import com.epita.domain.Index;
import com.epita.guereza.eventsourcing.Event;
import com.epita.guereza.eventsourcing.Reducer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class RetroIndex implements Reducer {
private static final Logger LOGGER = LoggerFactory.getLogger(RetroIndex.class);

private final Index index = new Index();

@SuppressWarnings("unchecked")
@Override
public void reduce(final Event<?> event) {
switch (event.type) {
case "ADD_DOCUMENT":
addDocument((Event<Document>) event);
break;
}
}

private void addDocument(Event<Document> event) {
index.docs.add(event.obj);
LOGGER.info("added a document to the index");
}
}

4 changes: 0 additions & 4 deletions src/main/java/com/epita/guereza/RetroIndexApp.java

This file was deleted.

0 comments on commit a380487

Please sign in to comment.