Created
May 15, 2020 00:55
-
-
Save jdegoes/5901dd63b4a0fff8aadc2910d051e9f9 to your computer and use it in GitHub Desktop.
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
package zio.connect | |
import zio._ | |
import zio.stream._ | |
trait S3Connector { | |
// Powered by ZIO S3 | |
type S3Connector | |
type S3Credentials | |
type S3Exception | |
type ConnectionError | |
def s3Layer: ZLayer[S3Credentials, ConnectionError, S3Connector] = ??? | |
sealed case class ObjectId(bucketName: String, key: String) | |
def getObject(bucketName: String, key: String): ZStream[S3Connector, S3Exception, Byte] = ??? | |
def putObject(bucketName: String, key: String): ZSink[S3Connector, S3Exception, Byte, Unit] = | |
??? | |
def deleteObjects: ZSink[S3Connector, S3Exception, ObjectId, Unit] = | |
??? | |
def move(locator: ObjectId => ObjectId): ZSink[S3Connector, S3Exception, ObjectId, Unit] = | |
??? | |
} | |
package object s3 extends S3Connector | |
trait FileConnector { | |
// Powered by ZIO NIO | |
import java.nio.file.Path | |
import java.io.IOException | |
type FileConnector = Has[FileConnector.Service] | |
object FileConnector { | |
trait Service { | |
def listPaths(path: Path): Stream[IOException, Path] | |
} | |
} | |
def listPaths(path: Path): ZStream[FileConnector, IOException, Path] = | |
ZStream.accessStream[FileConnector](_.get.listPaths(path)) | |
def readPath(path: Path): ZStream[FileConnector, IOException, Byte] = ??? | |
def writePath(path: Path): ZSink[FileConnector, IOException, Byte, Unit] = ??? | |
def delete: ZSink[FileConnector, IOException, Path, Unit] = ??? | |
def move(locator: Path => Path): ZSink[FileConnector, IOException, Path, Unit] = ??? | |
} | |
package object file extends FileConnector | |
trait KafkaConnector { | |
// Powered by ZIO Kafka | |
type KafkaSettings | |
type KafkaConnector = Has[KafkaConnector.Service] | |
type ConnectionError | |
object KafkaConnector { | |
trait Service | |
} | |
import java.io.IOException | |
def kafkaLayer: ZLayer[KafkaSettings, ConnectionError, KafkaConnector] = ??? | |
def subscribe(topics: String): ZStream[KafkaConnector, IOException, Byte] = ??? | |
} | |
package object kafka extends KafkaConnector | |
// ZIO S3, ZIO FTP | |
object example { | |
import zio.connect.s3._ | |
getObject("foo", "bar") >>> putObject("baz", "buz") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment