-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* cleanup polymorph F[_] * rename package ray.fs2.ftp to fs2.ftp * update doc * cleanup test * add javadoc
- Loading branch information
1 parent
9efc372
commit 63e300d
Showing
15 changed files
with
210 additions
and
109 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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package fs2 | ||
|
||
import cats.effect.{ConcurrentEffect, ContextShift, Resource} | ||
import cats.syntax.EitherSyntax | ||
import fs2.ftp.{FtpClient, FtpSettings, SecureFtp, UnsecureFtp} | ||
import fs2.ftp.FtpSettings.{SecureFtpSettings, UnsecureFtpSettings} | ||
|
||
package object ftp extends EitherSyntax{ | ||
def connect[F[_]: ContextShift: ConcurrentEffect, A](settings: FtpSettings[A]): Resource[F, FtpClient[F, A]] = | ||
settings match { | ||
case s: UnsecureFtpSettings => UnsecureFtp.connect(s) | ||
case s: SecureFtpSettings => SecureFtp.connect(s) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package fs2.ftp | ||
|
||
import fs2.Stream | ||
|
||
/** | ||
* Base trait of FtpClient which expose only safe methods | ||
* `F[_]` represents the effect type will be use | ||
* `A` underlying ftp client instance type | ||
*/ | ||
trait FtpClient[F[_], +A] { | ||
|
||
/** | ||
* Retreive information of a specific ftp resource like a file or directory | ||
* If the resource is not found we are returning an `Option.None` | ||
*/ | ||
def stat(path: String): F[Option[FtpResource]] | ||
|
||
/** | ||
* Read a file from a specific location path | ||
* If the resource is not found the operation will fail and fs2.Stream will Emit an IOException | ||
* in the error channel use `recover/recoverWith` to catch it | ||
*/ | ||
def readFile(path: String, chunkSize: Int = 2048): fs2.Stream[F, Byte] | ||
|
||
/** | ||
* Delete resource from a path | ||
* If the resource is not found the operation will fail and Emit an IOException in the error channel | ||
* use `recover/recoverWith` to catch it | ||
*/ | ||
def rm(path: String): F[Unit] | ||
|
||
/** | ||
* Delete a directory from a path | ||
* | ||
* If the resource is not found the operation will fail and Emit an IOException in the error channel | ||
* use `recover/recoverWith` to catch it | ||
*/ | ||
def rmdir(path: String): F[Unit] | ||
|
||
/** | ||
* Create a directory from a path | ||
* | ||
* If the resource already exist the operation will fail and emit an IOException in the error channel | ||
* use `recover/recoverWith` to catch it | ||
*/ | ||
def mkdir(path: String): F[Unit] | ||
|
||
/** | ||
* List all directories and files of a specific directory, it don't support nested directories | ||
* see `lsDescendant` | ||
* | ||
* If the directory dont exist it emits nothing, | ||
*/ | ||
def ls(path: String): Stream[F, FtpResource] | ||
|
||
/** | ||
* List only files by traversing nested directories | ||
* If the directory dont exist it emits nothing, | ||
*/ | ||
def lsDescendant(path: String): Stream[F, FtpResource] | ||
|
||
/** | ||
* Upload data to a specific location path | ||
* If operation failed it will emit an IOException in the error channel | ||
* use `recover/recoverWith` to catch it | ||
*/ | ||
def upload(path: String, source: fs2.Stream[F, Byte]): F[Unit] | ||
|
||
/** | ||
* Execute safely any operation supported by the underlying ftp client `A` | ||
* If operation failed it will emit an IOException in the error channel | ||
* use `recover/recoverWith` to catch it | ||
*/ | ||
def execute[T](f: A => T): F[T] | ||
} |
2 changes: 1 addition & 1 deletion
2
src/main/scala/ray/fs2/ftp/FtpResource.scala → src/main/scala/fs2/ftp/FtpResource.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
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
Oops, something went wrong.