-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+per #16541 allow using javadsl implemented journals as-if scaladsl
- Loading branch information
Showing
8 changed files
with
124 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
akka-persistence-query/src/main/java/akka/persistence/query/javadsl/ReadJournalAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (C) 2009-2015 Typesafe Inc. <http://www.typesafe.com> | ||
*/ | ||
|
||
package akka.persistence.query.javadsl; | ||
|
||
import akka.japi.Util; | ||
import akka.persistence.query.Hint; | ||
import akka.persistence.query.Query; | ||
import akka.stream.javadsl.Source; | ||
|
||
/** | ||
* INTERNAL API | ||
* | ||
* Adapter from ScalaDSL {@link akka.persistence.query.scaladsl.ReadJournal} | ||
* to JavaDSL {@link ReadJournal}. | ||
*/ | ||
public final class ReadJournalAdapter implements ReadJournal { | ||
|
||
private final akka.persistence.query.scaladsl.ReadJournal backing; | ||
|
||
public ReadJournalAdapter(akka.persistence.query.scaladsl.ReadJournal backing) { | ||
this.backing = backing; | ||
} | ||
|
||
@Override | ||
public <T, M> Source<T, M> query(Query<T, M> q, Hint... hints) { | ||
return backing.query(q, Util.immutableSeq(hints)).asJava(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
akka-persistence-query/src/test/java/akka/persistence/query/MockJavaReadJournal.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (C) 2009-2015 Typesafe Inc. <http://www.typesafe.com> | ||
*/ | ||
|
||
package akka.persistence.query; | ||
|
||
import akka.persistence.query.javadsl.ReadJournal; | ||
import akka.stream.javadsl.Source; | ||
import com.typesafe.config.Config; | ||
import com.typesafe.config.ConfigFactory; | ||
|
||
import java.util.Iterator; | ||
|
||
/** | ||
* Use for tests only! | ||
* Emits infinite stream of strings (representing queried for events). | ||
*/ | ||
class MockJavaReadJournal implements ReadJournal { | ||
public static final String Identifier = "akka.persistence.query.journal.mock-java"; | ||
|
||
public static final Config config = ConfigFactory.parseString( | ||
Identifier + " { \n" + | ||
" class = \"" + MockJavaReadJournal.class.getCanonicalName() + "\" \n" + | ||
" }\n\n"); | ||
|
||
@Override | ||
@SuppressWarnings("unchecked") | ||
public <T, M> Source<T, M> query(Query<T, M> q, Hint... hints) { | ||
return (Source<T, M>) Source.fromIterator(() -> new Iterator<String>() { | ||
private int i = 0; | ||
@Override public boolean hasNext() { return true; } | ||
|
||
@Override public String next() { | ||
return "" + (i++); | ||
} | ||
}); | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
akka-persistence-query/src/test/java/akka/persistence/query/PersistenceQueryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters