-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* compiles * config extracted barely compiles * working (apparently) * feature parity * address review * just shove the layers under the carpet * reorder main * Datables don't need the user to define ordering anymore * dateable => timestamped and some scaladoc * Update core/src/main/scala/tamer/Setup.scala Co-authored-by: Julien Jean Paul Sirocchi <[email protected]> * address pr review * cleaned, update docs * Update README.md Co-authored-by: Julien Jean Paul Sirocchi <[email protected]> * final draft after review * final final draft reviewed Co-authored-by: Julien Jean Paul Sirocchi <[email protected]>
- Loading branch information
Showing
19 changed files
with
1,573 additions
and
286 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,7 +78,8 @@ lazy val D = new { | |
val zio = Seq( | ||
"dev.zio" %% "zio-interop-cats" % V.`zio-interop`, | ||
"dev.zio" %% "zio-kafka" % V.`zio-kafka`, | ||
"dev.zio" %% "zio-streams" % V.zio | ||
"dev.zio" %% "zio-streams" % V.zio, | ||
"dev.zio" %% "zio-test" % V.zio | ||
) | ||
} | ||
|
||
|
@@ -135,15 +136,15 @@ lazy val commonSettings = Seq( | |
licenses += "MIT" -> url("http://opensource.org/licenses/MIT"), | ||
developers += Developer("sirocchj", "Julien Sirocchi", "[email protected]", url("https://github.com/sirocchj")), | ||
scalacOptions ++= versionDependent(scalaVersion.value), | ||
resolvers += "confluent" at "https://packages.confluent.io/maven/" | ||
resolvers ++= Seq("confluent" at "https://packages.confluent.io/maven/") | ||
) | ||
|
||
lazy val tamer = project | ||
.in(file("core")) | ||
.settings(commonSettings) | ||
.settings( | ||
name := "tamer", | ||
libraryDependencies ++= (D.cats ++ D.config ++ D.doobie ++ D.kafka ++ D.logs ++ D.refined ++ D.serialization ++ D.silencer ++ D.tests ++ D.zio) | ||
name := "tamer-core", | ||
libraryDependencies ++= (D.cats ++ D.config ++ D.kafka ++ D.logs ++ D.refined ++ D.serialization ++ D.silencer ++ D.tests ++ D.zio) | ||
.map(_.withSources) | ||
.map(_.withJavadoc), | ||
libraryDependencies ++= D.avro, | ||
|
@@ -152,10 +153,19 @@ lazy val tamer = project | |
Test / console / scalacOptions := (Compile / console / scalacOptions).value | ||
) | ||
|
||
lazy val doobie = project | ||
.in(file("doobie")) | ||
.dependsOn(tamer) | ||
.settings(commonSettings) | ||
.settings( | ||
name := "tamer-doobie", | ||
libraryDependencies ++= D.doobie | ||
) | ||
|
||
lazy val example = project | ||
.in(file("example")) | ||
.enablePlugins(JavaAppPackaging) | ||
.dependsOn(tamer) | ||
.dependsOn(tamer, doobie) | ||
.settings(commonSettings) | ||
.settings( | ||
libraryDependencies ++= D.postgres, | ||
|
@@ -164,7 +174,7 @@ lazy val example = project | |
|
||
lazy val root = project | ||
.in(file(".")) | ||
.aggregate(tamer, example) | ||
.aggregate(tamer, example, doobie) | ||
.settings(commonSettings) | ||
.settings( | ||
publish / skip := true, | ||
|
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 |
---|---|---|
@@ -1,48 +1,14 @@ | ||
package tamer | ||
|
||
import com.sksamuel.avro4s._ | ||
import doobie.util.query.Query0 | ||
import tamer.registry.{Registry, Topic} | ||
import zio.UIO | ||
import zio.kafka.serde.Serializer | ||
|
||
final case class ResultMetadata(queryExecutionTime: Long) | ||
final case class QueryResult[V](metadata: ResultMetadata, results: List[V]) | ||
|
||
final case class Setup[K, V, State]( | ||
keySerializer: Serializer[Registry with Topic, K], | ||
valueSerializer: Serializer[Registry with Topic, V], | ||
stateSerde: ZSerde[Registry with Topic, State], | ||
valueToKey: V => K, | ||
defaultState: State, | ||
buildQuery: State => Query0[V], | ||
stateFoldM: State => QueryResult[V] => UIO[State] | ||
) | ||
|
||
object Setup { | ||
final def avro[K <: Product: Decoder: Encoder: SchemaFor, V <: Product: Decoder: Encoder: SchemaFor, State <: Product: Decoder: Encoder: SchemaFor]( | ||
defaultState: State | ||
)( | ||
buildQuery: State => Query0[V] | ||
)( | ||
valueToKey: V => K, | ||
stateFoldM: State => QueryResult[V] => UIO[State] | ||
): Setup[K, V, State] = | ||
Setup(Serde[K](isKey = true).serializer, Serde[V]().serializer, Serde[State]().serde, valueToKey, defaultState, buildQuery, stateFoldM) | ||
|
||
final def avroSimple[K <: Product: Decoder: Encoder: SchemaFor, V <: Product: Decoder: Encoder: SchemaFor]( | ||
defaultState: V | ||
)( | ||
buildQuery: V => Query0[V], | ||
valueToKey: V => K | ||
): Setup[K, V, V] = | ||
Setup( | ||
Serde[K](isKey = true).serializer, | ||
Serde[V]().serializer, | ||
Serde[V]().serde, | ||
valueToKey, | ||
defaultState, | ||
buildQuery, | ||
_ => r => UIO(r.results.last) | ||
) | ||
abstract class Setup[-K, -V, S]( | ||
val keySerializer: Serializer[Registry with Topic, K], | ||
val valueSerializer: Serializer[Registry with Topic, V], | ||
val stateSerde: ZSerde[Registry with Topic, S], | ||
val defaultState: S, | ||
val stateKey: Int | ||
) { | ||
def show: String = "not available, please implement the show method to display setup" | ||
} |
This file was deleted.
Oops, something went wrong.
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.