Skip to content

Commit 97fb150

Browse files
committed
Add scaladocs
1 parent 359f7ae commit 97fb150

12 files changed

Lines changed: 45 additions & 3 deletions

File tree

core/src/main/scala/com/evolutiongaming/kafka/flow/EnhancedFold.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,19 @@ trait EnhancedFold[F[_], S, E] {
2626
}
2727
}
2828

29+
/**
30+
* Returns a fold that discards events for which f returns false
31+
*/
2932
final def filter(f: (S, E) => Boolean)(implicit F: Applicative[F]): EnhancedFold[F, S, E] =
3033
(extras, state0, event) =>
3134
state0 match {
3235
case Some(state) => if (f(state, event)) apply(extras, state0, event) else F.pure(state0)
3336
case None => apply(extras, state0, event)
3437
}
3538

39+
/**
40+
* Similar to `filter`
41+
*/
3642
final def filterM(f: (S, E) => F[Boolean])(implicit F: Monad[F]): EnhancedFold[F, S, E] =
3743
(extras, state0, event) =>
3844
state0 match {

core/src/main/scala/com/evolutiongaming/kafka/flow/Fold.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import cats.Functor
66
import cats.Monad
77
import cats.syntax.all._
88

9-
/** Reads a state and effectfully produces a new one.
9+
/**
10+
* @see [[com.evolutiongaming.kafka.flow.EnhancedFold]]
11+
*
12+
* Reads a state and effectfully produces a new one.
1013
*
1114
* Roughly speaking it is `Kleisli[F, (S, A), S]` with the main additional
1215
* requirement that input and output types are not independent (because `S`

core/src/main/scala/com/evolutiongaming/kafka/flow/FoldOption.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ import cats.Functor
66
import cats.Monad
77
import cats.syntax.all._
88

9-
/** Convenience methods for using `Fold` with optional state */
9+
/**
10+
* @see [[com.evolutiongaming.kafka.flow.EnhancedFold]]
11+
*
12+
* Convenience methods for using `Fold` with optional state
13+
* */
1014
final case class FoldOption[F[_], S, A](value: Fold[F, Option[S], A]) {
1115

1216
/** Alias for `run` */

core/src/main/scala/com/evolutiongaming/kafka/flow/FoldToState.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ import cats.syntax.all._
88
import com.evolutiongaming.kafka.flow.effect.CatsEffectMtlInstances._
99
import com.evolutiongaming.kafka.flow.persistence.Persistence
1010

11-
/** Applies records to a state stored inside and informs the listeners about the changes */
11+
/**
12+
* Applies records to a state stored inside and performs the necessary updates,
13+
* for example, it can persist the state and remove it from memory.
14+
*/
1215
trait FoldToState[F[_], E] {
1316

1417
def apply(records: NonEmptyList[E]): F[Unit]

core/src/main/scala/com/evolutiongaming/kafka/flow/KeyFlowOf.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import com.evolutiongaming.kafka.flow.persistence.Persistence
66
import com.evolutiongaming.kafka.flow.registry.EntityRegistry
77
import com.evolutiongaming.kafka.flow.timer.{TimerContext, TimerFlowOf}
88

9+
/**
10+
* Factory of KeyFlows
11+
*/
912
trait KeyFlowOf[F[_], S, A] {
1013

1114
def apply(

core/src/main/scala/com/evolutiongaming/kafka/flow/KeyStateOf.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import com.evolutiongaming.kafka.journal.ConsRecord
1111
import com.evolutiongaming.skafka.TopicPartition
1212
import com.evolutiongaming.sstream.Stream
1313

14+
/**
15+
* Factory of KeyStates
16+
*/
1417
trait KeyStateOf[F[_]] { self =>
1518

1619
/** Creates or restores a state for a single key */

core/src/main/scala/com/evolutiongaming/kafka/flow/PartitionFlowOf.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import com.evolutiongaming.kafka.flow.PartitionFlow.FilterRecord
77
import com.evolutiongaming.kafka.flow.kafka.ScheduleCommit
88
import com.evolutiongaming.skafka.{Offset, TopicPartition}
99

10+
/**
11+
* Factory of PartitionFlows
12+
*/
1013
trait PartitionFlowOf[F[_]] {
1114

1215
/** Creates partition record handler for assigned partition */

core/src/main/scala/com/evolutiongaming/kafka/flow/Tick.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ import cats.Applicative
44
import cats.syntax.all._
55
import cats.Functor
66

7+
/**
8+
* Updates an aggregate. Tick is similar to [[com.evolutiongaming.kafka.flow.EnhancedFold]],
9+
* but gets triggered by timers instead of incoming events.
10+
* For example, you may want to regularly delete aggregates that haven't been updated for N minutes.
11+
*/
712
case class Tick[F[_], S](run: S => F[S]) {
813

914
/** Alias for `run` */

core/src/main/scala/com/evolutiongaming/kafka/flow/TickOption.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ package com.evolutiongaming.kafka.flow
33
import cats.Applicative
44
import cats.Functor
55

6+
/**
7+
* Similar to [[com.evolutiongaming.kafka.flow.Tick]]
8+
*/
69
case class TickOption[F[_], S](value: Tick[F, Option[S]]) {
710

811
/** Alias for `value.run` */

core/src/main/scala/com/evolutiongaming/kafka/flow/TopicFlowOf.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import com.evolutiongaming.catshelper.{LogOf, Runtime}
66
import com.evolutiongaming.kafka.flow.kafka.Consumer
77
import com.evolutiongaming.skafka.Topic
88

9+
/**
10+
* Factory of TopicFlows
11+
*/
912
trait TopicFlowOf[F[_]] {
1013

1114
def apply(consumer: Consumer[F], topic: Topic): Resource[F, TopicFlow[F]]

0 commit comments

Comments
 (0)