Skip to content

Commit 625e835

Browse files
committed
some refactors
1 parent 54fc957 commit 625e835

File tree

5 files changed

+11
-14
lines changed

5 files changed

+11
-14
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ If you want different refresh intervals from different query, you can add a `Ref
122122
```scala
123123
val readJournal = ReactiveMongoJournalProvider(system).readJournalFor(Seq("Orders"))
124124
readJournal
125-
.currentEventsByTag("TAG", NoOffset, BSONDocument("events.p.customerId" -> customerId), None)
125+
.currentEventsByTags(Seq("TAG"), NoOffset, BSONDocument("events.p.customerId" -> customerId), None)
126126
.mapAsyc(envelope => someEventualWork(envelope))
127127
.run()
128128
```

core/src/main/scala/org/nullvector/query/CustomReadOps.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ trait CustomReadOps {
2121
* an optional hint index to use with filter
2222
* @return
2323
*/
24-
def currentEventsByTag(
24+
def currentEventsByTags(
2525
tag: Seq[String],
2626
offset: Offset,
2727
eventFilter: BSONDocument,

core/src/main/scala/org/nullvector/query/EventsQueries.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ trait EventsQueries
123123
eventsByTagQuery(tags, offset, BSONDocument.empty, None)
124124
}
125125

126-
override def currentEventsByTag(
126+
override def currentEventsByTags(
127127
tag: Seq[String],
128128
offset: Offset,
129129
eventFilter: BSONDocument,

core/src/main/scala/org/nullvector/query/FromMemoryReadJournal.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ class FromMemoryReadJournal(actorSystem: ActorSystem[_]) extends ReactiveMongoSc
158158
* a document filter for events
159159
* @return
160160
*/
161-
override def currentEventsByTag(
161+
override def currentEventsByTags(
162162
tag: Seq[String],
163163
offset: Offset,
164164
eventFilter: BSONDocument,

core/src/test/scala/org/nullvector/queries/ReactiveMongoReadJournalSpec.scala

+7-10
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ class ReactiveMongoReadJournalSpec()
136136
)
137137

138138
{
139-
val future = readJournal.currentEventsByTag(Seq("TAG"), NoOffset, BSONDocument("events.p.customerId" -> "5"), None).runWith(Sink.seq)
139+
val future = readJournal.currentEventsByTags(Seq("TAG"), NoOffset, BSONDocument("events.p.customerId" -> "5"), None).runWith(Sink.seq)
140140
Await.result(future, 1.second).size shouldBe 10
141141
}
142142
}
@@ -270,9 +270,9 @@ class ReactiveMongoReadJournalSpec()
270270
.run(),
271271
14.seconds
272272
)
273-
Thread.sleep(1500)
273+
Thread.sleep(200)
274274
val offset = ObjectIdOffset.newOffset()
275-
Thread.sleep(1000)
275+
Thread.sleep(200)
276276
Await.ready(
277277
Source(1 to 10)
278278
.mapAsync(amountOfCores) { idx =>
@@ -292,7 +292,7 @@ class ReactiveMongoReadJournalSpec()
292292
.run(),
293293
14.seconds
294294
)
295-
Thread.sleep(1500)
295+
Thread.sleep(200)
296296
val eventualDone =
297297
readJournal.currentEventsByTag("event_tag_1", offset).runWith(Sink.seq)
298298
val envelopes = Await.result(eventualDone, 14.seconds)
@@ -400,11 +400,9 @@ class ReactiveMongoReadJournalSpec()
400400
val pId = s"$prefixReadColl-123"
401401
readJournal
402402
.eventsByPersistenceId(pId, 0L, Long.MaxValue)
403-
.addAttributes(RefreshInterval(5.millis))
403+
.addAttributes(RefreshInterval(1.millis))
404404
.runWith(Sink.foreach(e => envelopes.add(e)))
405-
.recover { case e: Throwable =>
406-
e.printStackTrace()
407-
}
405+
408406
Await.ready(
409407
Source(1 to 10)
410408
.mapAsync(amountOfCores) { idx =>
@@ -423,7 +421,6 @@ class ReactiveMongoReadJournalSpec()
423421
.runWith(Sink.ignore),
424422
14.seconds
425423
)
426-
Thread.sleep(1000)
427424
Await.ready(
428425
Source(11 to 20)
429426
.mapAsync(amountOfCores) { idx =>
@@ -442,7 +439,7 @@ class ReactiveMongoReadJournalSpec()
442439
.runWith(Sink.ignore),
443440
14.seconds
444441
)
445-
Thread.sleep(1000)
442+
Thread.sleep(100)
446443
envelopes.peek().persistenceId shouldBe pId
447444
envelopes.size shouldBe 20
448445
}

0 commit comments

Comments
 (0)