This file contains hidden or 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
| def send(client: SqsAsyncClient, queueUrl: String, msg: String): Task[Unit] = | |
| IO.effectAsync[Any, Throwable, Unit] { cb => | |
| client | |
| .sendMessage(SendMessageRequest.builder.queueUrl(queueUrl).messageBody(msg).build) | |
| .handle[Unit]((_, err) => { | |
| err match { | |
| case null => cb(IO.unit) | |
| case ex => cb(IO.fail(ex)) | |
| } | |
| }) |
This file contains hidden or 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
| import scala.io.{ Codec, Source } | |
| import zio.{ App, console, ZIO } | |
| import zio.blocking._ | |
| object SampleApp extends App { | |
| def getResource(path: String): ZIO[Blocking, Throwable, String] = effectBlocking { | |
| Source.fromResource(path)(Codec.UTF8).getLines.mkString | |
| } |
This file contains hidden or 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
| import java.nio.file.{ Files, Paths } | |
| import zio.IO | |
| def copyFile(path: String, destination: String): IO[Throwable, Unit] = IO.effect { | |
| Files.copy(Paths.get(path), Paths.get(destination)) | |
| } |
NewerOlder