diff --git a/build.sbt b/build.sbt index 8bf2df8..8c1a837 100644 --- a/build.sbt +++ b/build.sbt @@ -38,7 +38,7 @@ lazy val models = project .disablePlugins(sbtassembly.AssemblyPlugin) .settings( commonSettings ++ Seq( - name := "KafkaCase-Models", + name := "kafkacase-models", libraryDependencies ++= modelsDependencies, scalacOptions ++= { if (scalaVersion.value.startsWith("2.13")) Seq("-Ymacro-annotations") else Seq("-Xmacro-settings:enable-macro-paradise") }, ), @@ -50,7 +50,7 @@ lazy val reader = project .disablePlugins(sbtassembly.AssemblyPlugin) .settings( commonSettings ++ Seq( - name := "KafkaCase-Reader", + name := "kafkacase-reader", libraryDependencies ++= readerDependencies ) ) @@ -60,7 +60,7 @@ lazy val writer = project .disablePlugins(sbtassembly.AssemblyPlugin) .settings( commonSettings ++ Seq( - name := "KafkaCase-Writer", + name := "kafkacase-writer", libraryDependencies ++= writerDependencies ) ) @@ -69,7 +69,7 @@ lazy val writer = project lazy val examples = project .settings( commonSettings ++ Seq( - name := "KafkaCase-Examples", + name := "kafkacase-examples", libraryDependencies ++= examplesDependencies, mergeStrategy ) diff --git a/examples/src/main/scala/za/co/absa/KafkaCase/Examples/KafkaCase.scala b/examples/src/main/scala/za/co/absa/kafkacase/examples/KafkaCase.scala similarity index 86% rename from examples/src/main/scala/za/co/absa/KafkaCase/Examples/KafkaCase.scala rename to examples/src/main/scala/za/co/absa/kafkacase/examples/KafkaCase.scala index b4dd23f..eb0f80f 100644 --- a/examples/src/main/scala/za/co/absa/KafkaCase/Examples/KafkaCase.scala +++ b/examples/src/main/scala/za/co/absa/kafkacase/examples/KafkaCase.scala @@ -14,27 +14,27 @@ * limitations under the License. */ -package za.co.absa.KafkaCase.Examples +package za.co.absa.kafkacase.examples import org.apache.kafka.clients.consumer.ConsumerConfig import org.apache.kafka.clients.producer.ProducerConfig -import za.co.absa.KafkaCase.Models.EdlaChangeTopic -import za.co.absa.KafkaCase.Reader.ReaderImpl -import za.co.absa.KafkaCase.Writer.WriterImpl +import za.co.absa.kafkacase.models.topics.EdlaChange +import za.co.absa.kafkacase.reader.ReaderImpl +import za.co.absa.kafkacase.writer.WriterImpl import java.util.{Properties, UUID} object KafkaCase { private def writer_use_case(): Unit = { // 0 -> HAVE SOMETHING TO WRITE - val messageToWrite = EdlaChangeTopic( + val messageToWrite = EdlaChange( app_id_snow = "N/A", data_definition_id = "TestingThis", environment = "DEV", format = "FooBar", guid = "DebugId", location = "ether", - operation = EdlaChangeTopic.Operation.CREATE(), + operation = EdlaChange.Operation.Create(), schema_link = "http://not.here", source_app = "ThisCode", timestamp_event = 12345 @@ -47,7 +47,7 @@ object KafkaCase { writerProps.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer") // 2 -> MAKE WRITER - val writer = new WriterImpl[EdlaChangeTopic](writerProps, "KillMePleaseTopic") + val writer = new WriterImpl[EdlaChange](writerProps, "KillMePleaseTopic") try { // 3 -> WRITE writer.Write("sampleMessageKey", messageToWrite) @@ -68,7 +68,7 @@ object KafkaCase { readerProps.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest") // 2 -> MAKE READER (should be in using block for newer versions of scala) - val reader = new ReaderImpl[EdlaChangeTopic](readerProps, "KillMePleaseTopic") + val reader = new ReaderImpl[EdlaChange](readerProps, "KillMePleaseTopic") try { for (item <- reader) println(item) diff --git a/models/src/main/scala/za/co/absa/KafkaCase/Models/EdlaChangeTopic.scala b/models/src/main/scala/za/co/absa/kafkacase/models/topics/EdlaChange.scala similarity index 70% rename from models/src/main/scala/za/co/absa/KafkaCase/Models/EdlaChangeTopic.scala rename to models/src/main/scala/za/co/absa/kafkacase/models/topics/EdlaChange.scala index f162ae9..ded5399 100644 --- a/models/src/main/scala/za/co/absa/KafkaCase/Models/EdlaChangeTopic.scala +++ b/models/src/main/scala/za/co/absa/kafkacase/models/topics/EdlaChange.scala @@ -14,43 +14,43 @@ * limitations under the License. */ -package za.co.absa.KafkaCase.Models +package za.co.absa.kafkacase.models.topics import io.circe.{Decoder, Encoder} import io.circe.generic.JsonCodec @JsonCodec -case class EdlaChangeTopic( +case class EdlaChange( app_id_snow: String, data_definition_id: String, environment: String, format: String, guid: String, location: String, - operation: EdlaChangeTopic.Operation, + operation: EdlaChange.Operation, schema_link: String, source_app: String, timestamp_event: Long ) -object EdlaChangeTopic { +object EdlaChange { sealed trait Operation object Operation { - case class CREATE() extends Operation - case class UPDATE() extends Operation - case class ARCHIVE() extends Operation + case class Create() extends Operation + case class Update() extends Operation + case class Archive() extends Operation implicit val operationEncoder: Encoder[Operation] = Encoder.encodeString.contramap[Operation] { - case CREATE() => s"CREATE" - case UPDATE() => s"UPDATE" - case ARCHIVE() => s"ARCHIVE" + case Create() => s"CREATE" + case Update() => s"UPDATE" + case Archive() => s"ARCHIVE" } implicit val operationDecoder: Decoder[Operation] = Decoder.decodeString.emap { - case "CREATE" => Right(CREATE()) - case "UPDATE" => Right(UPDATE()) - case "ARCHIVE" => Right(ARCHIVE()) + case "CREATE" => Right(Create()) + case "UPDATE" => Right(Update()) + case "ARCHIVE" => Right(Archive()) } } } diff --git a/models/src/main/scala/za/co/absa/KafkaCase/Models/SchemaRunTopic.scala b/models/src/main/scala/za/co/absa/kafkacase/models/topics/SchemaRun.scala similarity index 92% rename from models/src/main/scala/za/co/absa/KafkaCase/Models/SchemaRunTopic.scala rename to models/src/main/scala/za/co/absa/kafkacase/models/topics/SchemaRun.scala index 8ae353f..f1ab0d8 100644 --- a/models/src/main/scala/za/co/absa/KafkaCase/Models/SchemaRunTopic.scala +++ b/models/src/main/scala/za/co/absa/kafkacase/models/topics/SchemaRun.scala @@ -14,13 +14,13 @@ * limitations under the License. */ -package za.co.absa.KafkaCase.Models +package za.co.absa.kafkacase.models.topics import io.circe.{Decoder, Encoder} import io.circe.generic.JsonCodec @JsonCodec -case class SchemaRunTopic( +case class SchemaRun( app_id_snow: String, data_definition_id: String, environment: String, @@ -28,12 +28,12 @@ case class SchemaRunTopic( job_ref: String, message: String, source_app: String, - status: SchemaRunTopic.Status, + status: SchemaRun.Status, timestamp_end: Long, timestamp_start: Long ) -object SchemaRunTopic { +object SchemaRun { sealed trait Status object Status { diff --git a/models/src/test/scala/za/co/absa/KafkaCase/Models/EdlaChangeTopicUnitTests.scala b/models/src/test/scala/za/co/absa/kafkacase/models/topics/EdlaChangeUnitTests.scala similarity index 83% rename from models/src/test/scala/za/co/absa/KafkaCase/Models/EdlaChangeTopicUnitTests.scala rename to models/src/test/scala/za/co/absa/kafkacase/models/topics/EdlaChangeUnitTests.scala index c3cfed4..341c786 100644 --- a/models/src/test/scala/za/co/absa/KafkaCase/Models/EdlaChangeTopicUnitTests.scala +++ b/models/src/test/scala/za/co/absa/kafkacase/models/topics/EdlaChangeUnitTests.scala @@ -14,21 +14,21 @@ * limitations under the License. */ -package za.co.absa.KafkaCase.Models +package za.co.absa.kafkacase.models.topics import io.circe.jawn.decode import io.circe.syntax.EncoderOps import org.scalatest.funsuite.AnyFunSuite -class EdlaChangeTopicUnitTests extends AnyFunSuite { - private val instance = EdlaChangeTopic( +class EdlaChangeUnitTests extends AnyFunSuite { + private val instance = EdlaChange( app_id_snow = "N/A", data_definition_id = "TestingThis", environment = "DEV", format = "FooBar", guid = "DebugId", location = "ether", - operation = EdlaChangeTopic.Operation.CREATE(), + operation = EdlaChange.Operation.Create(), schema_link = "http://not.here", source_app = "ThisCode", timestamp_event = 12345 @@ -53,6 +53,6 @@ class EdlaChangeTopicUnitTests extends AnyFunSuite { } test("Deserializes from JSON properly") { - assertResult(instance)(decode[EdlaChangeTopic](json).getOrElse(throw new Exception("Failed to parse JSON"))) + assertResult(instance)(decode[EdlaChange](json).getOrElse(throw new Exception("Failed to parse JSON"))) } } diff --git a/models/src/test/scala/za/co/absa/KafkaCase/Models/SchemaRunTopicUnitTests.scala b/models/src/test/scala/za/co/absa/kafkacase/models/topics/SchemaRunUnitTests.scala similarity index 83% rename from models/src/test/scala/za/co/absa/KafkaCase/Models/SchemaRunTopicUnitTests.scala rename to models/src/test/scala/za/co/absa/kafkacase/models/topics/SchemaRunUnitTests.scala index c3d9ca8..86a3e6b 100644 --- a/models/src/test/scala/za/co/absa/KafkaCase/Models/SchemaRunTopicUnitTests.scala +++ b/models/src/test/scala/za/co/absa/kafkacase/models/topics/SchemaRunUnitTests.scala @@ -14,14 +14,14 @@ * limitations under the License. */ -package za.co.absa.KafkaCase.Models +package za.co.absa.kafkacase.models.topics import io.circe.jawn.decode import io.circe.syntax.EncoderOps import org.scalatest.funsuite.AnyFunSuite -class SchemaRunTopicUnitTests extends AnyFunSuite { - private val instance = SchemaRunTopic( +class SchemaRunUnitTests extends AnyFunSuite { + private val instance = SchemaRun( app_id_snow = "N/A", data_definition_id = "Foo", environment = "TEST", @@ -29,7 +29,7 @@ class SchemaRunTopicUnitTests extends AnyFunSuite { job_ref = "UnitTestJob", message = "FooBar", source_app = "ThisTest", - status = SchemaRunTopic.Status.Killed(), + status = SchemaRun.Status.Killed(), timestamp_end = 67890, timestamp_start = 12345 ) @@ -53,6 +53,6 @@ class SchemaRunTopicUnitTests extends AnyFunSuite { } test("Deserializes from JSON properly") { - assertResult(instance)(decode[SchemaRunTopic](json).getOrElse(throw new Exception("Failed to parse JSON"))) + assertResult(instance)(decode[SchemaRun](json).getOrElse(throw new Exception("Failed to parse JSON"))) } } diff --git a/reader/src/main/scala/za/co/absa/KafkaCase/Reader/Reader.scala b/reader/src/main/scala/za/co/absa/kafkacase/reader/Reader.scala similarity index 95% rename from reader/src/main/scala/za/co/absa/KafkaCase/Reader/Reader.scala rename to reader/src/main/scala/za/co/absa/kafkacase/reader/Reader.scala index a82ee7f..a93b18c 100644 --- a/reader/src/main/scala/za/co/absa/KafkaCase/Reader/Reader.scala +++ b/reader/src/main/scala/za/co/absa/kafkacase/reader/Reader.scala @@ -14,6 +14,6 @@ * limitations under the License. */ -package za.co.absa.KafkaCase.Reader +package za.co.absa.kafkacase.reader trait Reader[TType] extends Iterator[(String, Either[String, TType])] with AutoCloseable diff --git a/reader/src/main/scala/za/co/absa/KafkaCase/Reader/ReaderImpl.scala b/reader/src/main/scala/za/co/absa/kafkacase/reader/ReaderImpl.scala similarity index 95% rename from reader/src/main/scala/za/co/absa/KafkaCase/Reader/ReaderImpl.scala rename to reader/src/main/scala/za/co/absa/kafkacase/reader/ReaderImpl.scala index 309f773..7d66080 100644 --- a/reader/src/main/scala/za/co/absa/KafkaCase/Reader/ReaderImpl.scala +++ b/reader/src/main/scala/za/co/absa/kafkacase/reader/ReaderImpl.scala @@ -14,13 +14,13 @@ * limitations under the License. */ -package za.co.absa.KafkaCase.Reader +package za.co.absa.kafkacase.reader import io.circe.Decoder import io.circe.jawn.decode import org.slf4j.LoggerFactory import org.apache.kafka.clients.consumer.{ConsumerRecord, KafkaConsumer} -import za.co.absa.KafkaCase.Reader.ReaderImpl.{DEFAULT_TIMEOUT, log} +import za.co.absa.kafkacase.reader.ReaderImpl.{DEFAULT_TIMEOUT, log} import java.time.Duration import java.util diff --git a/writer/src/main/scala/za/co/absa/KafkaCase/Writer/Writer.scala b/writer/src/main/scala/za/co/absa/kafkacase/writer/Writer.scala similarity index 95% rename from writer/src/main/scala/za/co/absa/KafkaCase/Writer/Writer.scala rename to writer/src/main/scala/za/co/absa/kafkacase/writer/Writer.scala index 3170231..b2616a2 100644 --- a/writer/src/main/scala/za/co/absa/KafkaCase/Writer/Writer.scala +++ b/writer/src/main/scala/za/co/absa/kafkacase/writer/Writer.scala @@ -14,7 +14,7 @@ * limitations under the License. */ -package za.co.absa.KafkaCase.Writer +package za.co.absa.kafkacase.writer trait Writer[TType] extends AutoCloseable { def Write(key: String, value: TType): Unit diff --git a/writer/src/main/scala/za/co/absa/KafkaCase/Writer/WriterImpl.scala b/writer/src/main/scala/za/co/absa/kafkacase/writer/WriterImpl.scala similarity index 93% rename from writer/src/main/scala/za/co/absa/KafkaCase/Writer/WriterImpl.scala rename to writer/src/main/scala/za/co/absa/kafkacase/writer/WriterImpl.scala index 47aefef..8f540a8 100644 --- a/writer/src/main/scala/za/co/absa/KafkaCase/Writer/WriterImpl.scala +++ b/writer/src/main/scala/za/co/absa/kafkacase/writer/WriterImpl.scala @@ -14,13 +14,13 @@ * limitations under the License. */ -package za.co.absa.KafkaCase.Writer +package za.co.absa.kafkacase.writer import io.circe.Encoder import io.circe.syntax.EncoderOps import org.slf4j.LoggerFactory import org.apache.kafka.clients.producer.{KafkaProducer, ProducerRecord} -import za.co.absa.KafkaCase.Writer.WriterImpl.log +import za.co.absa.kafkacase.writer.WriterImpl.log import java.util.Properties