-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
10 changed files
with
344 additions
and
52 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
examples/src/main/scala-2/za.co.absa.kafkacase.examples/reader/UsingsResourceHandling.scala
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,26 @@ | ||
/* | ||
* Copyright 2024 ABSA Group Limited | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package za.co.absa.kafkacase.examples.reader | ||
|
||
import io.circe.Decoder | ||
import java.util.Properties | ||
|
||
object UsingsResourceHandling { | ||
def apply[T: Decoder](readerProps: Properties, topicName: String): Unit = { | ||
println("Scala 3 feature") | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
examples/src/main/scala-2/za.co.absa.kafkacase.examples/writer/UsingsResourceHandling.scala
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,26 @@ | ||
/* | ||
* Copyright 2024 ABSA Group Limited | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package za.co.absa.kafkacase.examples.writer | ||
|
||
import io.circe.Encoder | ||
import java.util.Properties | ||
|
||
object UsingsResourceHandling { | ||
def apply[T: Encoder](writerProps: Properties, topicName: String, sampleMessageToWrite: T): Unit = { | ||
println("Scala 3 feature") | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
examples/src/main/scala-3/za/co/absa/kafkacase/examples/reader/UsingsResourceHandling.scala
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,32 @@ | ||
/* | ||
* Copyright 2024 ABSA Group Limited | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package za.co.absa.kafkacase.examples.reader | ||
|
||
import io.circe.Decoder | ||
import za.co.absa.kafkacase.reader.ReaderImpl | ||
|
||
import java.util.Properties | ||
import scala.util.Using | ||
|
||
object UsingsResourceHandling { | ||
def apply[T: Decoder](readerProps: Properties, topicName: String): Unit = { | ||
Using(new ReaderImpl[T](readerProps, topicName, neverEnding = false)) { reader => | ||
for (item <- reader) | ||
println(item) | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
examples/src/main/scala-3/za/co/absa/kafkacase/examples/writer/UsingsResourceHandling.scala
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,32 @@ | ||
/* | ||
* Copyright 2024 ABSA Group Limited | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package za.co.absa.kafkacase.examples.writer | ||
|
||
import io.circe.Encoder | ||
import za.co.absa.kafkacase.writer.WriterImpl | ||
|
||
import java.util.Properties | ||
import scala.util.Using | ||
|
||
object UsingsResourceHandling { | ||
def apply[T: Encoder](writerProps: Properties, topicName: String, sampleMessageToWrite: T): Unit = { | ||
Using(new WriterImpl[T](writerProps, topicName)) { writer => | ||
writer.Write("sampleMessageKey1", sampleMessageToWrite) | ||
writer.Write("sampleMessageKey2", sampleMessageToWrite) | ||
} | ||
} | ||
} |
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
32 changes: 32 additions & 0 deletions
32
examples/src/main/scala/za/co/absa/kafkacase/examples/reader/CustomResourceHandling.scala
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,32 @@ | ||
/* | ||
* Copyright 2024 ABSA Group Limited | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package za.co.absa.kafkacase.examples.reader | ||
|
||
import io.circe.Decoder | ||
import za.co.absa.kafkacase.models.utils.ResourceHandler.withResource | ||
import za.co.absa.kafkacase.reader.ReaderImpl | ||
|
||
import java.util.Properties | ||
|
||
object CustomResourceHandling { | ||
def apply[T: Decoder](readerProps: Properties, topicName: String): Unit = { | ||
withResource(new ReaderImpl[T](readerProps, topicName, neverEnding = false))(reader => { | ||
for (item <- reader) | ||
println(item) | ||
}) | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
examples/src/main/scala/za/co/absa/kafkacase/examples/reader/ManualResourceHandling.scala
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,34 @@ | ||
/* | ||
* Copyright 2024 ABSA Group Limited | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package za.co.absa.kafkacase.examples.reader | ||
|
||
import io.circe.Decoder | ||
import za.co.absa.kafkacase.reader.ReaderImpl | ||
|
||
import java.util.Properties | ||
|
||
object ManualResourceHandling { | ||
def apply[T: Decoder](readerProps: Properties, topicName: String): Unit = { | ||
val reader = new ReaderImpl[T](readerProps, topicName, neverEnding = false) | ||
try { | ||
for (item <- reader) | ||
println(item) | ||
} finally { | ||
reader.close() | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
examples/src/main/scala/za/co/absa/kafkacase/examples/writer/CustomResourceHandling.scala
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,32 @@ | ||
/* | ||
* Copyright 2024 ABSA Group Limited | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package za.co.absa.kafkacase.examples.writer | ||
|
||
import io.circe.Encoder | ||
import za.co.absa.kafkacase.models.utils.ResourceHandler.withResource | ||
import za.co.absa.kafkacase.writer.WriterImpl | ||
|
||
import java.util.Properties | ||
|
||
object CustomResourceHandling { | ||
def apply[T: Encoder](writerProps: Properties, topicName: String, sampleMessageToWrite: T): Unit = { | ||
withResource(new WriterImpl[T](writerProps, topicName))(writer => { | ||
writer.Write("sampleMessageKey1", sampleMessageToWrite) | ||
writer.Write("sampleMessageKey2", sampleMessageToWrite) | ||
}) | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
examples/src/main/scala/za/co/absa/kafkacase/examples/writer/ManualResourceHandling.scala
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,34 @@ | ||
/* | ||
* Copyright 2024 ABSA Group Limited | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package za.co.absa.kafkacase.examples.writer | ||
|
||
import io.circe.Encoder | ||
import za.co.absa.kafkacase.writer.WriterImpl | ||
|
||
import java.util.Properties | ||
|
||
object ManualResourceHandling { | ||
def apply[T: Encoder](writerProps: Properties, topicName: String, sampleMessageToWrite: T): Unit = { | ||
val writer = new WriterImpl[T](writerProps, topicName) | ||
try { | ||
writer.Write("sampleMessageKey1", sampleMessageToWrite) | ||
writer.Write("sampleMessageKey2", sampleMessageToWrite) | ||
} finally { | ||
writer.close() | ||
} | ||
} | ||
} |
Oops, something went wrong.